Index: vm/vmcore/src/jvmti/jvmti_thread.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_thread.cpp (revision 449113) +++ vm/vmcore/src/jvmti/jvmti_thread.cpp (working copy) @@ -128,7 +128,7 @@ return err; } for (i=0;iNewLocalRef(jthread_iterator_next(&iterator)); } *threads_count_ptr = java_thread_count; *threads_ptr = java_threads; Index: vm/vmcore/src/jvmti/jvmti_event.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_event.cpp (revision 449113) +++ vm/vmcore/src/jvmti/jvmti_event.cpp (working copy) @@ -1498,8 +1498,8 @@ case JVMTI_EVENT_MONITOR_WAITED: { jobject monitor = va_arg(args, jobject); - jboolean is_timed_out = va_arg(args, jint); //jboolean); - ((jvmtiEventMonitorWait)callback_func)((jvmtiEnv*)ti_env, jni_env, + jboolean is_timed_out = va_arg(args, jint); + ((jvmtiEventMonitorWaited)callback_func)((jvmtiEnv*)ti_env, jni_env, jthread_get_java_thread(hythread_self()), monitor, is_timed_out); break; } @@ -1524,8 +1524,18 @@ TIEnv *ti_env, *next_env; DebugUtilsTI *ti = VM_Global_State::loader_env->TI; void *callback_func; + bool unwindable; + jthrowable excn = NULL; + + if (! ti->isEnabled()) return; + unwindable = set_unwindable(false); - if (! ti->isEnabled()) return; + if (!unwindable) { + if (excn = exn_get()) { + exn_clear(); + } + } + ti_env = ti->getEnvironments(); va_start(args, per_thread); while(ti_env) { @@ -1534,15 +1544,20 @@ && (!per_thread || !is_interested_thread(ti_env, event_type))) { ti_env = ti_env->next; continue; - } + } callback_func = ti_env->get_event_callback(event_type); if (callback_func) call_callback(event_type, jni_env, ti_env, callback_func, args); ti_env = next_env; - } + } + + assert(!exn_get()); + + if (excn) exn_raise_object(excn); + + set_unwindable(unwindable); va_end(args); - - } +} void jvmti_send_thread_start_end_event(int is_start) { Index: vm/thread/src/thread_java_monitors.c =================================================================== --- vm/thread/src/thread_java_monitors.c (revision 449113) +++ vm/thread/src/thread_java_monitors.c (working copy) @@ -314,6 +314,7 @@ set_wait_monitor(monitor); set_contended_monitor(monitor); jvmti_send_wait_monitor_event(monitor, (jlong)millis); + jvmti_send_contended_enter_or_entered_monitor_event(monitor, 1); set_suspend_disable(disable_count); // should be moved to event handler @@ -347,6 +348,7 @@ if (ti_is_enabled()){ add_owned_monitor(monitor); disable_count = reset_suspend_disable(); + jvmti_send_contended_enter_or_entered_monitor_event(monitor, 0); jvmti_send_waited_monitor_event(monitor, (status == APR_TIMEUP)?(jboolean)1:(jboolean)0); // should be moved to event handler set_suspend_disable(disable_count); Index: vm/thread/src/thread_native_fat_monitor.c =================================================================== --- vm/thread/src/thread_native_fat_monitor.c (revision 449113) +++ vm/thread/src/thread_native_fat_monitor.c (working copy) @@ -207,6 +207,12 @@ status = condvar_wait_impl(mon_ptr->condition, mon_ptr->mutex, ms, nano, interruptable); //printf("finishing wait: %x, %x \n", mon_ptr->condition, hythread_self()); #endif + if(self->suspend_request) { + hymutex_unlock(mon_ptr->mutex); + hythread_safe_point(); + hymutex_lock(mon_ptr->mutex); + } + mon_ptr->recursion_count = saved_recursion; mon_ptr->owner = self; assert(mon_ptr->owner); Index: vm/thread/src/thread_ti_monitors.c =================================================================== --- vm/thread/src/thread_ti_monitors.c (revision 449113) +++ vm/thread/src/thread_ti_monitors.c (working copy) @@ -177,13 +177,12 @@ */ IDATA VMCALL jthread_raw_monitor_wait(jrawMonitorID mon_ptr, I_64 millis) { hythread_monitor_t monitor; - IDATA stat; + if (!(monitor = (hythread_monitor_t)array_get(jvmti_monitor_table, (UDATA)mon_ptr))) { return TM_ERROR_INVALID_MONITOR; } - stat = hythread_monitor_wait_interruptable(monitor, millis, 0); - hythread_safe_point(); - return stat; + + return hythread_monitor_wait_interruptable(monitor, millis, 0); } /** Index: vm/thread/src/thread_java_basic.c =================================================================== --- vm/thread/src/thread_java_basic.c (revision 449113) +++ vm/thread/src/thread_java_basic.c (working copy) @@ -417,6 +417,7 @@ tm_native_thread = hythread_self(); tm_java_thread = hythread_get_private_data(tm_native_thread); excn = tm_java_thread->stop_exception; + tm_native_thread->suspend_request = 0; jthread_throw_exception_object(excn); } Index: vm/thread/src/thread_ti_timing.c =================================================================== --- vm/thread/src/thread_ti_timing.c (revision 449113) +++ vm/thread/src/thread_ti_timing.c (working copy) @@ -62,7 +62,8 @@ assert(java_thread); assert(nanos_ptr); tm_native_thread = vm_jthread_get_tm_data(java_thread); - return CONVERT_ERROR(apr_get_thread_time(tm_native_thread->os_handle,nanos_ptr)); + return CONVERT_ERROR(apr_get_thread_time(tm_native_thread->os_handle, + (apr_int64_t*) nanos_ptr)); } /** Index: vm/thread/src/thread_native_suspend.c =================================================================== --- vm/thread/src/thread_native_suspend.c (revision 449113) +++ vm/thread/src/thread_native_suspend.c (working copy) @@ -333,6 +333,7 @@ * @param[in] callback callback function */ IDATA hythread_set_safepoint_callback(hythread_t thread, tm_thread_event_callback_proc callback) { + IDATA status; while (apr_atomic_casptr((volatile void **)&thread->safepoint_callback, (void *)callback, (void *)NULL) != NULL); if(tm_self_tls == thread) { int old_status = thread->suspend_disable_count; @@ -346,8 +347,14 @@ send_suspend_request(thread); //let the thread execute safe point in the case it's already suspended //// - hysem_post(thread->resume_event); + status = hysem_post(thread->resume_event); + assert (status == TM_ERROR_NONE); } + + if (thread->current_condition) { + status=hycond_notify(thread->current_condition); + assert (status == TM_ERROR_NONE); + } return TM_ERROR_NONE; }