Mercurial > hg > truffle
diff src/share/vm/code/nmethod.cpp @ 2195:bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
Summary: Defer posting events from the compiler thread: use service thread
Reviewed-by: coleenp, dholmes, never, dcubed
author | kamg |
---|---|
date | Wed, 02 Feb 2011 14:38:01 -0500 |
parents | 3582bf76420e |
children | 0cd39a385a72 1b4e6a5d98e0 |
line wrap: on
line diff
--- a/src/share/vm/code/nmethod.cpp Wed Feb 02 18:38:40 2011 -0500 +++ b/src/share/vm/code/nmethod.cpp Wed Feb 02 14:38:01 2011 -0500 @@ -34,6 +34,7 @@ #include "interpreter/bytecode.hpp" #include "oops/methodDataOop.hpp" #include "prims/jvmtiRedefineClassesTrace.hpp" +#include "prims/jvmtiImpl.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/sweeper.hpp" #include "utilities/dtrace.hpp" @@ -1533,7 +1534,10 @@ } if (JvmtiExport::should_post_compiled_method_load()) { - JvmtiExport::post_compiled_method_load(this); + // Let the Service thread (which is a real Java thread) post the event + MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); + JvmtiDeferredEventQueue::enqueue( + JvmtiDeferredEvent::compiled_method_load_event(this)); } } @@ -1566,8 +1570,17 @@ // ref will have been cleared. if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) { assert(!unload_reported(), "already unloaded"); - HandleMark hm; - JvmtiExport::post_compiled_method_unload(_jmethod_id, insts_begin()); + JvmtiDeferredEvent event = + JvmtiDeferredEvent::compiled_method_unload_event( + _jmethod_id, insts_begin()); + if (SafepointSynchronize::is_at_safepoint()) { + // Don't want to take the queueing lock. Add it as pending and + // it will get enqueued later. + JvmtiDeferredEventQueue::add_pending_event(event); + } else { + MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); + JvmtiDeferredEventQueue::enqueue(event); + } } // The JVMTI CompiledMethodUnload event can be enabled or disabled at