Mercurial > hg > graal-compiler
comparison src/share/vm/code/nmethod.cpp @ 14412:e2722a66aba7
Merge
author | kvn |
---|---|
date | Thu, 05 Sep 2013 11:04:39 -0700 |
parents | bdd155477289 5888334c9c24 |
children | 2b8e28fdf503 |
comparison
equal
deleted
inserted
replaced
14411:bdd155477289 | 14412:e2722a66aba7 |
---|---|
685 _pc_desc_cache.reset_to(NULL); | 685 _pc_desc_cache.reset_to(NULL); |
686 | 686 |
687 code_buffer->copy_values_to(this); | 687 code_buffer->copy_values_to(this); |
688 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { | 688 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { |
689 CodeCache::add_scavenge_root_nmethod(this); | 689 CodeCache::add_scavenge_root_nmethod(this); |
690 Universe::heap()->register_nmethod(this); | |
690 } | 691 } |
691 debug_only(verify_scavenge_root_oops()); | 692 debug_only(verify_scavenge_root_oops()); |
692 CodeCache::commit(this); | 693 CodeCache::commit(this); |
693 } | 694 } |
694 | 695 |
879 code_buffer->copy_values_to(this); | 880 code_buffer->copy_values_to(this); |
880 debug_info->copy_to(this); | 881 debug_info->copy_to(this); |
881 dependencies->copy_to(this); | 882 dependencies->copy_to(this); |
882 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { | 883 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { |
883 CodeCache::add_scavenge_root_nmethod(this); | 884 CodeCache::add_scavenge_root_nmethod(this); |
885 Universe::heap()->register_nmethod(this); | |
884 } | 886 } |
885 debug_only(verify_scavenge_root_oops()); | 887 debug_only(verify_scavenge_root_oops()); |
886 | 888 |
887 CodeCache::commit(this); | 889 CodeCache::commit(this); |
888 | 890 |
1298 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. | 1300 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. |
1299 nmethodLocker nml(this); | 1301 nmethodLocker nml(this); |
1300 methodHandle the_method(method()); | 1302 methodHandle the_method(method()); |
1301 No_Safepoint_Verifier nsv; | 1303 No_Safepoint_Verifier nsv; |
1302 | 1304 |
1305 // during patching, depending on the nmethod state we must notify the GC that | |
1306 // code has been unloaded, unregistering it. We cannot do this right while | |
1307 // holding the Patching_lock because we need to use the CodeCache_lock. This | |
1308 // would be prone to deadlocks. | |
1309 // This flag is used to remember whether we need to later lock and unregister. | |
1310 bool nmethod_needs_unregister = false; | |
1311 | |
1303 { | 1312 { |
1304 // invalidate osr nmethod before acquiring the patching lock since | 1313 // invalidate osr nmethod before acquiring the patching lock since |
1305 // they both acquire leaf locks and we don't want a deadlock. | 1314 // they both acquire leaf locks and we don't want a deadlock. |
1306 // This logic is equivalent to the logic below for patching the | 1315 // This logic is equivalent to the logic below for patching the |
1307 // verified entry point of regular methods. | 1316 // verified entry point of regular methods. |
1328 | 1337 |
1329 if (is_in_use()) { | 1338 if (is_in_use()) { |
1330 // It's a true state change, so mark the method as decompiled. | 1339 // It's a true state change, so mark the method as decompiled. |
1331 // Do it only for transition from alive. | 1340 // Do it only for transition from alive. |
1332 inc_decompile_count(); | 1341 inc_decompile_count(); |
1342 } | |
1343 | |
1344 // If the state is becoming a zombie, signal to unregister the nmethod with | |
1345 // the heap. | |
1346 // This nmethod may have already been unloaded during a full GC. | |
1347 if ((state == zombie) && !is_unloaded()) { | |
1348 nmethod_needs_unregister = true; | |
1333 } | 1349 } |
1334 | 1350 |
1335 // Change state | 1351 // Change state |
1336 _state = state; | 1352 _state = state; |
1337 | 1353 |
1365 { | 1381 { |
1366 // Flushing dependecies must be done before any possible | 1382 // Flushing dependecies must be done before any possible |
1367 // safepoint can sneak in, otherwise the oops used by the | 1383 // safepoint can sneak in, otherwise the oops used by the |
1368 // dependency logic could have become stale. | 1384 // dependency logic could have become stale. |
1369 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | 1385 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1386 if (nmethod_needs_unregister) { | |
1387 Universe::heap()->unregister_nmethod(this); | |
1388 } | |
1370 flush_dependencies(NULL); | 1389 flush_dependencies(NULL); |
1371 } | 1390 } |
1372 | 1391 |
1373 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload | 1392 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload |
1374 // event and it hasn't already been reported for this nmethod then | 1393 // event and it hasn't already been reported for this nmethod then |
1815 | 1834 |
1816 // Call function Method*, not embedded in these other places. | 1835 // Call function Method*, not embedded in these other places. |
1817 if (_method != NULL) f(_method); | 1836 if (_method != NULL) f(_method); |
1818 } | 1837 } |
1819 | 1838 |
1820 | 1839 void nmethod::oops_do(OopClosure* f, bool allow_zombie) { |
1821 // This method is called twice during GC -- once while | |
1822 // tracing the "active" nmethods on thread stacks during | |
1823 // the (strong) marking phase, and then again when walking | |
1824 // the code cache contents during the weak roots processing | |
1825 // phase. The two uses are distinguished by means of the | |
1826 // 'do_strong_roots_only' flag, which is true in the first | |
1827 // case. We want to walk the weak roots in the nmethod | |
1828 // only in the second case. The weak roots in the nmethod | |
1829 // are the oops in the ExceptionCache and the InlineCache | |
1830 // oops. | |
1831 void nmethod::oops_do(OopClosure* f, bool do_strong_roots_only) { | |
1832 // make sure the oops ready to receive visitors | 1840 // make sure the oops ready to receive visitors |
1833 assert(!is_zombie() && !is_unloaded(), | 1841 assert(allow_zombie || !is_zombie(), "should not call follow on zombie nmethod"); |
1834 "should not call follow on zombie or unloaded nmethod"); | 1842 assert(!is_unloaded(), "should not call follow on unloaded nmethod"); |
1835 | 1843 |
1836 // If the method is not entrant or zombie then a JMP is plastered over the | 1844 // If the method is not entrant or zombie then a JMP is plastered over the |
1837 // first few bytes. If an oop in the old code was there, that oop | 1845 // first few bytes. If an oop in the old code was there, that oop |
1838 // should not get GC'd. Skip the first few bytes of oops on | 1846 // should not get GC'd. Skip the first few bytes of oops on |
1839 // not-entrant methods. | 1847 // not-entrant methods. |