diff --git a/vm/vmcore/src/class_support/C_Interface.cpp b/vm/vmcore/src/class_support/C_Interface.cpp index 56ad5d2..680ca71 100644 --- a/vm/vmcore/src/class_support/C_Interface.cpp +++ b/vm/vmcore/src/class_support/C_Interface.cpp @@ -2427,10 +2427,25 @@ void vm_gc_lock_init() void vm_gc_lock_enum() { - int disable_count = hythread_reset_suspend_disable(); - IDATA UNUSED status = hymutex_lock(&vm_gc_lock); - assert(status == TM_ERROR_NONE); - hythread_set_suspend_disable(disable_count); + hythread_t self = tm_self_tls; + int disable_count = self->disable_count; + self->disable_count = 0; + + while (true) { + IDATA UNUSED status = hymutex_lock(&vm_gc_lock); + assert(status == TM_ERROR_NONE); + + self->disable_count = disable_count; + if (disable_count && self->suspend_count) { + status = hymutex_unlock(&vm_gc_lock); + assert(status == TM_ERROR_NONE); + + self->disable_count = 0; + hythread_safe_point_other(self); + } else { + break; + } + } } // vm_gc_lock_enum void vm_gc_unlock_enum() diff --git a/vm/vmcore/src/thread/thread_generic.cpp b/vm/vmcore/src/thread/thread_generic.cpp index a96f2a8..0edffdd 100644 --- a/vm/vmcore/src/thread/thread_generic.cpp +++ b/vm/vmcore/src/thread/thread_generic.cpp @@ -255,8 +255,6 @@ jint vm_detach(jobject java_thread) jvmti_send_thread_start_end_event(p_vm_thread, 0); } - hythread_suspend_disable(); - // change java_status for native thread native_thread->java_status = TM_STATUS_ALLOCATED; @@ -283,8 +281,6 @@ jint vm_detach(jobject java_thread) // Destroy current VM_thread pool and zero VM_thread structure jthread_deallocate_vm_thread_pool(p_vm_thread); - hythread_suspend_enable(); - return JNI_OK; }