Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
2194:face83fc8882 | 2195:bf8517f4e4d0 |
---|---|
32 #include "compiler/compilerOracle.hpp" | 32 #include "compiler/compilerOracle.hpp" |
33 #include "compiler/disassembler.hpp" | 33 #include "compiler/disassembler.hpp" |
34 #include "interpreter/bytecode.hpp" | 34 #include "interpreter/bytecode.hpp" |
35 #include "oops/methodDataOop.hpp" | 35 #include "oops/methodDataOop.hpp" |
36 #include "prims/jvmtiRedefineClassesTrace.hpp" | 36 #include "prims/jvmtiRedefineClassesTrace.hpp" |
37 #include "prims/jvmtiImpl.hpp" | |
37 #include "runtime/sharedRuntime.hpp" | 38 #include "runtime/sharedRuntime.hpp" |
38 #include "runtime/sweeper.hpp" | 39 #include "runtime/sweeper.hpp" |
39 #include "utilities/dtrace.hpp" | 40 #include "utilities/dtrace.hpp" |
40 #include "utilities/events.hpp" | 41 #include "utilities/events.hpp" |
41 #include "utilities/xmlstream.hpp" | 42 #include "utilities/xmlstream.hpp" |
1531 JvmtiExport::should_post_compiled_method_unload()) { | 1532 JvmtiExport::should_post_compiled_method_unload()) { |
1532 get_and_cache_jmethod_id(); | 1533 get_and_cache_jmethod_id(); |
1533 } | 1534 } |
1534 | 1535 |
1535 if (JvmtiExport::should_post_compiled_method_load()) { | 1536 if (JvmtiExport::should_post_compiled_method_load()) { |
1536 JvmtiExport::post_compiled_method_load(this); | 1537 // Let the Service thread (which is a real Java thread) post the event |
1538 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); | |
1539 JvmtiDeferredEventQueue::enqueue( | |
1540 JvmtiDeferredEvent::compiled_method_load_event(this)); | |
1537 } | 1541 } |
1538 } | 1542 } |
1539 | 1543 |
1540 jmethodID nmethod::get_and_cache_jmethod_id() { | 1544 jmethodID nmethod::get_and_cache_jmethod_id() { |
1541 if (_jmethod_id == NULL) { | 1545 if (_jmethod_id == NULL) { |
1564 // that the jmethodID is a weak reference to the methodOop so if | 1568 // that the jmethodID is a weak reference to the methodOop so if |
1565 // it's being unloaded there's no way to look it up since the weak | 1569 // it's being unloaded there's no way to look it up since the weak |
1566 // ref will have been cleared. | 1570 // ref will have been cleared. |
1567 if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) { | 1571 if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) { |
1568 assert(!unload_reported(), "already unloaded"); | 1572 assert(!unload_reported(), "already unloaded"); |
1569 HandleMark hm; | 1573 JvmtiDeferredEvent event = |
1570 JvmtiExport::post_compiled_method_unload(_jmethod_id, insts_begin()); | 1574 JvmtiDeferredEvent::compiled_method_unload_event( |
1575 _jmethod_id, insts_begin()); | |
1576 if (SafepointSynchronize::is_at_safepoint()) { | |
1577 // Don't want to take the queueing lock. Add it as pending and | |
1578 // it will get enqueued later. | |
1579 JvmtiDeferredEventQueue::add_pending_event(event); | |
1580 } else { | |
1581 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); | |
1582 JvmtiDeferredEventQueue::enqueue(event); | |
1583 } | |
1571 } | 1584 } |
1572 | 1585 |
1573 // The JVMTI CompiledMethodUnload event can be enabled or disabled at | 1586 // The JVMTI CompiledMethodUnload event can be enabled or disabled at |
1574 // any time. As the nmethod is being unloaded now we mark it has | 1587 // any time. As the nmethod is being unloaded now we mark it has |
1575 // having the unload event reported - this will ensure that we don't | 1588 // having the unload event reported - this will ensure that we don't |