void m2n_set_last_frame(M2nFrame * lm2nf) { vm_thread_t vm_thread = jthread_self_vm_thread_unsafe(); vm_thread->last_m2n_frame = lm2nf; }
VMEXPORT // temporary solution for interpreter unplug void m2n_set_last_frame(M2nFrame* lm2nf) { vm_thread_t vm_thread = jthread_self_vm_thread_unsafe(); vm_thread->last_m2n_frame = lm2nf; }
/** * Attaches thread current thread to VM. */ jint vm_attach(JavaVM * java_vm, JNIEnv ** p_jni_env) { // It seems to be reasonable to have suspend enabled state here. // It is unsafe to perform operations which require suspend disabled // mode until current thread is not attaced to VM. assert(hythread_is_suspend_enabled()); vm_thread_t vm_thread = jthread_self_vm_thread_unsafe(); assert(vm_thread); // if the assertion is false we cannot notify the parent thread // that we started and it would hang in waitloop assert(vm_thread); jint status = jthread_allocate_vm_thread_pool(java_vm, vm_thread); if (status != JNI_OK) { return status; } // Create top level M2N frame. M2nFrame *p_m2n = (M2nFrame *) apr_palloc(vm_thread->pool, sizeof(M2nFrame)); if (!p_m2n) { return JNI_ENOMEM; } // Create local handles. ObjectHandles *p_handles = (ObjectHandles *) apr_palloc(vm_thread->pool, sizeof(ObjectHandlesNew)); if (!p_handles) { return JNI_ENOMEM; } vm_thread->jni_env = (JNIEnv *) apr_palloc(vm_thread->pool, sizeof(JNIEnv_Internal)); if (!vm_thread->jni_env) { return JNI_ENOMEM; } // Initialize JNI environment. JNIEnv_Internal *jni_env = (JNIEnv_Internal *) vm_thread->jni_env; jni_env->functions = &jni_vtable; jni_env->vm = (JavaVM_Internal *) java_vm; jni_env->reserved0 = (void *) 0x1234abcd; *p_jni_env = jni_env; m2n_null_init(p_m2n); m2n_set_last_frame(p_m2n); oh_null_init_handles(p_handles); m2n_set_local_handles(p_m2n, p_handles); m2n_set_frame_type(p_m2n, FRAME_NON_UNWINDABLE); gc_thread_init(&vm_thread->_gc_private_information); if (ti_is_enabled()) { vm_thread->jvmti_thread.owned_monitors_size = TM_INITIAL_OWNED_MONITOR_SIZE; vm_thread->jvmti_thread.owned_monitors = (jobject*)apr_palloc(vm_thread->pool, TM_INITIAL_OWNED_MONITOR_SIZE * sizeof(jobject)); void *addr = NULL; apr_status_t UNREF status = port_vmem_allocate(&addr, TM_JVMTI_MAX_BUFFER_SIZE, PORT_VMEM_MODE_READ | PORT_VMEM_MODE_WRITE | PORT_VMEM_MODE_EXECUTE); assert(status == APR_SUCCESS); vm_thread->jvmti_thread.jvmti_jit_breakpoints_handling_buffer = reinterpret_cast<jbyte *>(addr); assert(VM_Global_State::loader_env->TI); VM_Global_State::loader_env->TI->reportLocally(); } ((hythread_t)vm_thread)->java_status = TM_STATUS_INITIALIZED; assert(hythread_is_suspend_enabled()); return JNI_OK; }