Mercurial > hg > truffle
comparison src/share/vm/code/nmethod.cpp @ 1644:2a47bd84841f
6965184: possible races in make_not_entrant_or_zombie
Reviewed-by: kvn
author | never |
---|---|
date | Thu, 08 Jul 2010 14:29:44 -0700 |
parents | 38e8278318ca |
children | 4a665be40fd3 |
comparison
equal
deleted
inserted
replaced
1635:a693e51ac197 | 1644:2a47bd84841f |
---|---|
395 | 395 |
396 | 396 |
397 //-------------end of code for ExceptionCache-------------- | 397 //-------------end of code for ExceptionCache-------------- |
398 | 398 |
399 | 399 |
400 void nmFlags::clear() { | |
401 assert(sizeof(nmFlags) == sizeof(int), "using more than one word for nmFlags"); | |
402 *(jint*)this = 0; | |
403 } | |
404 | |
405 int nmethod::total_size() const { | 400 int nmethod::total_size() const { |
406 return | 401 return |
407 code_size() + | 402 code_size() + |
408 stub_size() + | 403 stub_size() + |
409 consts_size() + | 404 consts_size() + |
417 if (is_osr_method()) return "osr"; | 412 if (is_osr_method()) return "osr"; |
418 if (method() != NULL && is_native_method()) return "c2n"; | 413 if (method() != NULL && is_native_method()) return "c2n"; |
419 return NULL; | 414 return NULL; |
420 } | 415 } |
421 | 416 |
422 // %%% This variable is no longer used? | 417 // Fill in default values for various flag fields |
423 int nmethod::_zombie_instruction_size = NativeJump::instruction_size; | 418 void nmethod::init_defaults() { |
419 _state = alive; | |
420 _marked_for_reclamation = 0; | |
421 _has_flushed_dependencies = 0; | |
422 _speculatively_disconnected = 0; | |
423 _has_unsafe_access = 0; | |
424 _has_method_handle_invokes = 0; | |
425 _marked_for_deoptimization = 0; | |
426 _lock_count = 0; | |
427 _stack_traversal_mark = 0; | |
428 _unload_reported = false; // jvmti state | |
429 | |
430 NOT_PRODUCT(_has_debug_info = false); | |
431 _oops_do_mark_link = NULL; | |
432 _jmethod_id = NULL; | |
433 _osr_link = NULL; | |
434 _scavenge_root_link = NULL; | |
435 _scavenge_root_state = 0; | |
436 _saved_nmethod_link = NULL; | |
437 _compiler = NULL; | |
438 | |
439 #ifdef HAVE_DTRACE_H | |
440 _trap_offset = 0; | |
441 #endif // def HAVE_DTRACE_H | |
442 } | |
424 | 443 |
425 | 444 |
426 nmethod* nmethod::new_native_nmethod(methodHandle method, | 445 nmethod* nmethod::new_native_nmethod(methodHandle method, |
427 CodeBuffer *code_buffer, | 446 CodeBuffer *code_buffer, |
428 int vep_offset, | 447 int vep_offset, |
578 { | 597 { |
579 { | 598 { |
580 debug_only(No_Safepoint_Verifier nsv;) | 599 debug_only(No_Safepoint_Verifier nsv;) |
581 assert_locked_or_safepoint(CodeCache_lock); | 600 assert_locked_or_safepoint(CodeCache_lock); |
582 | 601 |
583 NOT_PRODUCT(_has_debug_info = false); | 602 init_defaults(); |
584 _oops_do_mark_link = NULL; | |
585 _method = method; | 603 _method = method; |
586 _entry_bci = InvocationEntryBci; | 604 _entry_bci = InvocationEntryBci; |
587 _jmethod_id = NULL; | |
588 _osr_link = NULL; | |
589 _scavenge_root_link = NULL; | |
590 _scavenge_root_state = 0; | |
591 _saved_nmethod_link = NULL; | |
592 _compiler = NULL; | |
593 // We have no exception handler or deopt handler make the | 605 // We have no exception handler or deopt handler make the |
594 // values something that will never match a pc like the nmethod vtable entry | 606 // values something that will never match a pc like the nmethod vtable entry |
595 _exception_offset = 0; | 607 _exception_offset = 0; |
596 _deoptimize_offset = 0; | 608 _deoptimize_offset = 0; |
597 _deoptimize_mh_offset = 0; | 609 _deoptimize_mh_offset = 0; |
598 _orig_pc_offset = 0; | 610 _orig_pc_offset = 0; |
599 #ifdef HAVE_DTRACE_H | 611 |
600 _trap_offset = 0; | |
601 #endif // def HAVE_DTRACE_H | |
602 _stub_offset = data_offset(); | 612 _stub_offset = data_offset(); |
603 _consts_offset = data_offset(); | 613 _consts_offset = data_offset(); |
604 _oops_offset = data_offset(); | 614 _oops_offset = data_offset(); |
605 _scopes_data_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize); | 615 _scopes_data_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize); |
606 _scopes_pcs_offset = _scopes_data_offset; | 616 _scopes_pcs_offset = _scopes_data_offset; |
614 _verified_entry_point = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry); | 624 _verified_entry_point = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry); |
615 _osr_entry_point = NULL; | 625 _osr_entry_point = NULL; |
616 _exception_cache = NULL; | 626 _exception_cache = NULL; |
617 _pc_desc_cache.reset_to(NULL); | 627 _pc_desc_cache.reset_to(NULL); |
618 | 628 |
619 flags.clear(); | |
620 flags.state = alive; | |
621 _markedForDeoptimization = 0; | |
622 | |
623 _lock_count = 0; | |
624 _stack_traversal_mark = 0; | |
625 | |
626 code_buffer->copy_oops_to(this); | 629 code_buffer->copy_oops_to(this); |
627 debug_only(verify_scavenge_root_oops()); | 630 debug_only(verify_scavenge_root_oops()); |
628 CodeCache::commit(this); | 631 CodeCache::commit(this); |
629 VTune::create_nmethod(this); | |
630 } | 632 } |
631 | 633 |
632 if (PrintNativeNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) { | 634 if (PrintNativeNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) { |
633 ttyLocker ttyl; // keep the following output all in one block | 635 ttyLocker ttyl; // keep the following output all in one block |
634 // This output goes directly to the tty, not the compiler log. | 636 // This output goes directly to the tty, not the compiler log. |
672 { | 674 { |
673 { | 675 { |
674 debug_only(No_Safepoint_Verifier nsv;) | 676 debug_only(No_Safepoint_Verifier nsv;) |
675 assert_locked_or_safepoint(CodeCache_lock); | 677 assert_locked_or_safepoint(CodeCache_lock); |
676 | 678 |
677 NOT_PRODUCT(_has_debug_info = false); | 679 init_defaults(); |
678 _oops_do_mark_link = NULL; | |
679 _method = method; | 680 _method = method; |
680 _entry_bci = InvocationEntryBci; | 681 _entry_bci = InvocationEntryBci; |
681 _jmethod_id = NULL; | |
682 _osr_link = NULL; | |
683 _scavenge_root_link = NULL; | |
684 _scavenge_root_state = 0; | |
685 _compiler = NULL; | |
686 // We have no exception handler or deopt handler make the | 682 // We have no exception handler or deopt handler make the |
687 // values something that will never match a pc like the nmethod vtable entry | 683 // values something that will never match a pc like the nmethod vtable entry |
688 _exception_offset = 0; | 684 _exception_offset = 0; |
689 _deoptimize_offset = 0; | 685 _deoptimize_offset = 0; |
690 _deoptimize_mh_offset = 0; | 686 _deoptimize_mh_offset = 0; |
706 _verified_entry_point = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry); | 702 _verified_entry_point = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry); |
707 _osr_entry_point = NULL; | 703 _osr_entry_point = NULL; |
708 _exception_cache = NULL; | 704 _exception_cache = NULL; |
709 _pc_desc_cache.reset_to(NULL); | 705 _pc_desc_cache.reset_to(NULL); |
710 | 706 |
711 flags.clear(); | |
712 flags.state = alive; | |
713 _markedForDeoptimization = 0; | |
714 | |
715 _lock_count = 0; | |
716 _stack_traversal_mark = 0; | |
717 | |
718 code_buffer->copy_oops_to(this); | 707 code_buffer->copy_oops_to(this); |
719 debug_only(verify_scavenge_root_oops()); | 708 debug_only(verify_scavenge_root_oops()); |
720 CodeCache::commit(this); | 709 CodeCache::commit(this); |
721 VTune::create_nmethod(this); | |
722 } | 710 } |
723 | 711 |
724 if (PrintNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) { | 712 if (PrintNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) { |
725 ttyLocker ttyl; // keep the following output all in one block | 713 ttyLocker ttyl; // keep the following output all in one block |
726 // This output goes directly to the tty, not the compiler log. | 714 // This output goes directly to the tty, not the compiler log. |
781 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); | 769 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); |
782 { | 770 { |
783 debug_only(No_Safepoint_Verifier nsv;) | 771 debug_only(No_Safepoint_Verifier nsv;) |
784 assert_locked_or_safepoint(CodeCache_lock); | 772 assert_locked_or_safepoint(CodeCache_lock); |
785 | 773 |
786 NOT_PRODUCT(_has_debug_info = false); | 774 init_defaults(); |
787 _oops_do_mark_link = NULL; | |
788 _method = method; | 775 _method = method; |
789 _jmethod_id = NULL; | 776 _entry_bci = entry_bci; |
790 _compile_id = compile_id; | 777 _compile_id = compile_id; |
791 _comp_level = comp_level; | 778 _comp_level = comp_level; |
792 _entry_bci = entry_bci; | |
793 _osr_link = NULL; | |
794 _scavenge_root_link = NULL; | |
795 _scavenge_root_state = 0; | |
796 _compiler = compiler; | 779 _compiler = compiler; |
797 _orig_pc_offset = orig_pc_offset; | 780 _orig_pc_offset = orig_pc_offset; |
798 #ifdef HAVE_DTRACE_H | |
799 _trap_offset = 0; | |
800 #endif // def HAVE_DTRACE_H | |
801 _stub_offset = instructions_offset() + code_buffer->total_offset_of(code_buffer->stubs()->start()); | 781 _stub_offset = instructions_offset() + code_buffer->total_offset_of(code_buffer->stubs()->start()); |
802 | 782 |
803 // Exception handler and deopt handler are in the stub section | 783 // Exception handler and deopt handler are in the stub section |
804 _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); | 784 _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); |
805 _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); | 785 _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); |
822 _verified_entry_point = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry); | 802 _verified_entry_point = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry); |
823 _osr_entry_point = instructions_begin() + offsets->value(CodeOffsets::OSR_Entry); | 803 _osr_entry_point = instructions_begin() + offsets->value(CodeOffsets::OSR_Entry); |
824 _exception_cache = NULL; | 804 _exception_cache = NULL; |
825 _pc_desc_cache.reset_to(scopes_pcs_begin()); | 805 _pc_desc_cache.reset_to(scopes_pcs_begin()); |
826 | 806 |
827 flags.clear(); | |
828 flags.state = alive; | |
829 _markedForDeoptimization = 0; | |
830 | |
831 _unload_reported = false; // jvmti state | |
832 | |
833 _lock_count = 0; | |
834 _stack_traversal_mark = 0; | |
835 | |
836 // Copy contents of ScopeDescRecorder to nmethod | 807 // Copy contents of ScopeDescRecorder to nmethod |
837 code_buffer->copy_oops_to(this); | 808 code_buffer->copy_oops_to(this); |
838 debug_info->copy_to(this); | 809 debug_info->copy_to(this); |
839 dependencies->copy_to(this); | 810 dependencies->copy_to(this); |
840 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { | 811 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { |
841 CodeCache::add_scavenge_root_nmethod(this); | 812 CodeCache::add_scavenge_root_nmethod(this); |
842 } | 813 } |
843 debug_only(verify_scavenge_root_oops()); | 814 debug_only(verify_scavenge_root_oops()); |
844 | 815 |
845 CodeCache::commit(this); | 816 CodeCache::commit(this); |
846 | |
847 VTune::create_nmethod(this); | |
848 | 817 |
849 // Copy contents of ExceptionHandlerTable to nmethod | 818 // Copy contents of ExceptionHandlerTable to nmethod |
850 handler_table->copy_to(this); | 819 handler_table->copy_to(this); |
851 nul_chk_table->copy_to(this); | 820 nul_chk_table->copy_to(this); |
852 | 821 |
986 print_nul_chk_table(); | 955 print_nul_chk_table(); |
987 } | 956 } |
988 if (xtty != NULL) { | 957 if (xtty != NULL) { |
989 xtty->tail("print_nmethod"); | 958 xtty->tail("print_nmethod"); |
990 } | 959 } |
991 } | |
992 | |
993 | |
994 void nmethod::set_version(int v) { | |
995 flags.version = v; | |
996 } | 960 } |
997 | 961 |
998 | 962 |
999 // Promote one word from an assembly-time handle to a live embedded oop. | 963 // Promote one word from an assembly-time handle to a live embedded oop. |
1000 inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) { | 964 inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) { |
1140 } | 1104 } |
1141 | 1105 |
1142 // This is a private interface with the sweeper. | 1106 // This is a private interface with the sweeper. |
1143 void nmethod::mark_as_seen_on_stack() { | 1107 void nmethod::mark_as_seen_on_stack() { |
1144 assert(is_not_entrant(), "must be a non-entrant method"); | 1108 assert(is_not_entrant(), "must be a non-entrant method"); |
1109 // Set the traversal mark to ensure that the sweeper does 2 | |
1110 // cleaning passes before moving to zombie. | |
1145 set_stack_traversal_mark(NMethodSweeper::traversal_count()); | 1111 set_stack_traversal_mark(NMethodSweeper::traversal_count()); |
1146 } | 1112 } |
1147 | 1113 |
1148 // Tell if a non-entrant method can be converted to a zombie (i.e., there is no activations on the stack) | 1114 // Tell if a non-entrant method can be converted to a zombie (i.e., there is no activations on the stack) |
1149 bool nmethod::can_not_entrant_be_converted() { | 1115 bool nmethod::can_not_entrant_be_converted() { |
1208 // Transitioning directly from live to unloaded -- so | 1174 // Transitioning directly from live to unloaded -- so |
1209 // we need to force a cache clean-up; remember this | 1175 // we need to force a cache clean-up; remember this |
1210 // for later on. | 1176 // for later on. |
1211 CodeCache::set_needs_cache_clean(true); | 1177 CodeCache::set_needs_cache_clean(true); |
1212 } | 1178 } |
1213 flags.state = unloaded; | 1179 _state = unloaded; |
1214 | 1180 |
1215 // Log the unloading. | 1181 // Log the unloading. |
1216 log_state_change(); | 1182 log_state_change(); |
1217 | 1183 |
1218 // The methodOop is gone at this point | 1184 // The methodOop is gone at this point |
1234 | 1200 |
1235 void nmethod::log_state_change() const { | 1201 void nmethod::log_state_change() const { |
1236 if (LogCompilation) { | 1202 if (LogCompilation) { |
1237 if (xtty != NULL) { | 1203 if (xtty != NULL) { |
1238 ttyLocker ttyl; // keep the following output all in one block | 1204 ttyLocker ttyl; // keep the following output all in one block |
1239 if (flags.state == unloaded) { | 1205 if (_state == unloaded) { |
1240 xtty->begin_elem("make_unloaded thread='" UINTX_FORMAT "'", | 1206 xtty->begin_elem("make_unloaded thread='" UINTX_FORMAT "'", |
1241 os::current_thread_id()); | 1207 os::current_thread_id()); |
1242 } else { | 1208 } else { |
1243 xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s", | 1209 xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s", |
1244 os::current_thread_id(), | 1210 os::current_thread_id(), |
1245 (flags.state == zombie ? " zombie='1'" : "")); | 1211 (_state == zombie ? " zombie='1'" : "")); |
1246 } | 1212 } |
1247 log_identity(xtty); | 1213 log_identity(xtty); |
1248 xtty->stamp(); | 1214 xtty->stamp(); |
1249 xtty->end_elem(); | 1215 xtty->end_elem(); |
1250 } | 1216 } |
1251 } | 1217 } |
1252 if (PrintCompilation && flags.state != unloaded) { | 1218 if (PrintCompilation && _state != unloaded) { |
1253 print_on(tty, flags.state == zombie ? "made zombie " : "made not entrant "); | 1219 print_on(tty, _state == zombie ? "made zombie " : "made not entrant "); |
1254 tty->cr(); | 1220 tty->cr(); |
1255 } | 1221 } |
1256 } | 1222 } |
1257 | 1223 |
1258 // Common functionality for both make_not_entrant and make_zombie | 1224 // Common functionality for both make_not_entrant and make_zombie |
1259 bool nmethod::make_not_entrant_or_zombie(unsigned int state) { | 1225 bool nmethod::make_not_entrant_or_zombie(unsigned int state) { |
1260 assert(state == zombie || state == not_entrant, "must be zombie or not_entrant"); | 1226 assert(state == zombie || state == not_entrant, "must be zombie or not_entrant"); |
1261 | 1227 |
1262 bool was_alive = false; | 1228 bool was_alive = false; |
1263 | 1229 |
1264 // Make sure the nmethod is not flushed in case of a safepoint in code below. | 1230 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. |
1265 nmethodLocker nml(this); | 1231 nmethodLocker nml(this); |
1232 methodHandle the_method(method()); | |
1266 | 1233 |
1267 { | 1234 { |
1268 // If the method is already zombie there is nothing to do | 1235 // If the method is already zombie there is nothing to do |
1269 if (is_zombie()) { | 1236 if (is_zombie()) { |
1270 return false; | 1237 return false; |
1280 } | 1247 } |
1281 | 1248 |
1282 // Enter critical section. Does not block for safepoint. | 1249 // Enter critical section. Does not block for safepoint. |
1283 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); | 1250 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
1284 | 1251 |
1285 if (flags.state == state) { | 1252 if (_state == state) { |
1286 // another thread already performed this transition so nothing | 1253 // another thread already performed this transition so nothing |
1287 // to do, but return false to indicate this. | 1254 // to do, but return false to indicate this. |
1288 return false; | 1255 return false; |
1289 } | 1256 } |
1290 | 1257 |
1291 // The caller can be calling the method statically or through an inline | 1258 // The caller can be calling the method statically or through an inline |
1292 // cache call. | 1259 // cache call. |
1293 if (!is_osr_method() && !is_not_entrant()) { | 1260 if (!is_osr_method() && !is_not_entrant()) { |
1294 NativeJump::patch_verified_entry(entry_point(), verified_entry_point(), | 1261 NativeJump::patch_verified_entry(entry_point(), verified_entry_point(), |
1295 SharedRuntime::get_handle_wrong_method_stub()); | 1262 SharedRuntime::get_handle_wrong_method_stub()); |
1296 assert (NativeJump::instruction_size == nmethod::_zombie_instruction_size, ""); | 1263 } |
1297 } | 1264 |
1298 | 1265 if (is_in_use()) { |
1299 was_alive = is_in_use(); // Read state under lock | 1266 // It's a true state change, so mark the method as decompiled. |
1267 // Do it only for transition from alive. | |
1268 inc_decompile_count(); | |
1269 } | |
1300 | 1270 |
1301 // Change state | 1271 // Change state |
1302 flags.state = state; | 1272 _state = state; |
1303 | 1273 |
1304 // Log the transition once | 1274 // Log the transition once |
1305 log_state_change(); | 1275 log_state_change(); |
1276 | |
1277 // Remove nmethod from method. | |
1278 // We need to check if both the _code and _from_compiled_code_entry_point | |
1279 // refer to this nmethod because there is a race in setting these two fields | |
1280 // in methodOop as seen in bugid 4947125. | |
1281 // If the vep() points to the zombie nmethod, the memory for the nmethod | |
1282 // could be flushed and the compiler and vtable stubs could still call | |
1283 // through it. | |
1284 if (method() != NULL && (method()->code() == this || | |
1285 method()->from_compiled_entry() == verified_entry_point())) { | |
1286 HandleMark hm; | |
1287 method()->clear_code(); | |
1288 } | |
1289 | |
1290 if (state == not_entrant) { | |
1291 mark_as_seen_on_stack(); | |
1292 } | |
1306 | 1293 |
1307 } // leave critical region under Patching_lock | 1294 } // leave critical region under Patching_lock |
1308 | 1295 |
1309 // When the nmethod becomes zombie it is no longer alive so the | 1296 // When the nmethod becomes zombie it is no longer alive so the |
1310 // dependencies must be flushed. nmethods in the not_entrant | 1297 // dependencies must be flushed. nmethods in the not_entrant |
1311 // state will be flushed later when the transition to zombie | 1298 // state will be flushed later when the transition to zombie |
1312 // happens or they get unloaded. | 1299 // happens or they get unloaded. |
1313 if (state == zombie) { | 1300 if (state == zombie) { |
1301 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event | |
1302 // and it hasn't already been reported for this nmethod then report it now. | |
1303 // (the event may have been reported earilier if the GC marked it for unloading). | |
1304 post_compiled_method_unload(); | |
1305 | |
1314 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | 1306 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1315 flush_dependencies(NULL); | 1307 flush_dependencies(NULL); |
1316 } else { | 1308 } else { |
1317 assert(state == not_entrant, "other cases may need to be handled differently"); | 1309 assert(state == not_entrant, "other cases may need to be handled differently"); |
1318 } | 1310 } |
1319 | 1311 |
1320 if (state == not_entrant) { | |
1321 Events::log("Make nmethod not entrant " INTPTR_FORMAT, this); | |
1322 } else { | |
1323 Events::log("Make nmethod zombie " INTPTR_FORMAT, this); | |
1324 } | |
1325 | |
1326 if (TraceCreateZombies) { | 1312 if (TraceCreateZombies) { |
1327 tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie"); | 1313 tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie"); |
1328 } | 1314 } |
1329 | 1315 |
1330 // Make sweeper aware that there is a zombie method that needs to be removed | 1316 // Make sweeper aware that there is a zombie method that needs to be removed |
1331 NMethodSweeper::notify(this); | 1317 NMethodSweeper::notify(this); |
1332 | |
1333 // not_entrant only stuff | |
1334 if (state == not_entrant) { | |
1335 mark_as_seen_on_stack(); | |
1336 } | |
1337 | |
1338 if (was_alive) { | |
1339 // It's a true state change, so mark the method as decompiled. | |
1340 // Do it only for transition from alive. | |
1341 inc_decompile_count(); | |
1342 } | |
1343 | |
1344 // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event | |
1345 // and it hasn't already been reported for this nmethod then report it now. | |
1346 // (the event may have been reported earilier if the GC marked it for unloading). | |
1347 if (state == zombie) { | |
1348 post_compiled_method_unload(); | |
1349 } | |
1350 | |
1351 | |
1352 // Zombie only stuff | |
1353 if (state == zombie) { | |
1354 VTune::delete_nmethod(this); | |
1355 } | |
1356 | |
1357 // Check whether method got unloaded at a safepoint before this, | |
1358 // if so we can skip the flushing steps below | |
1359 if (method() == NULL) return true; | |
1360 | |
1361 // Remove nmethod from method. | |
1362 // We need to check if both the _code and _from_compiled_code_entry_point | |
1363 // refer to this nmethod because there is a race in setting these two fields | |
1364 // in methodOop as seen in bugid 4947125. | |
1365 // If the vep() points to the zombie nmethod, the memory for the nmethod | |
1366 // could be flushed and the compiler and vtable stubs could still call | |
1367 // through it. | |
1368 if (method()->code() == this || | |
1369 method()->from_compiled_entry() == verified_entry_point()) { | |
1370 HandleMark hm; | |
1371 method()->clear_code(); | |
1372 } | |
1373 | 1318 |
1374 return true; | 1319 return true; |
1375 } | 1320 } |
1376 | 1321 |
1377 void nmethod::flush() { | 1322 void nmethod::flush() { |
2107 | 2052 |
2108 | 2053 |
2109 | 2054 |
2110 void nmethod_init() { | 2055 void nmethod_init() { |
2111 // make sure you didn't forget to adjust the filler fields | 2056 // make sure you didn't forget to adjust the filler fields |
2112 assert(sizeof(nmFlags) <= 4, "nmFlags occupies more than a word"); | |
2113 assert(sizeof(nmethod) % oopSize == 0, "nmethod size must be multiple of a word"); | 2057 assert(sizeof(nmethod) % oopSize == 0, "nmethod size must be multiple of a word"); |
2114 } | 2058 } |
2115 | 2059 |
2116 | 2060 |
2117 //------------------------------------------------------------------------------------------- | 2061 //------------------------------------------------------------------------------------------- |
2343 tty->cr(); | 2287 tty->cr(); |
2344 if (WizardMode) { | 2288 if (WizardMode) { |
2345 tty->print("((nmethod*) "INTPTR_FORMAT ") ", this); | 2289 tty->print("((nmethod*) "INTPTR_FORMAT ") ", this); |
2346 tty->print(" for method " INTPTR_FORMAT , (address)method()); | 2290 tty->print(" for method " INTPTR_FORMAT , (address)method()); |
2347 tty->print(" { "); | 2291 tty->print(" { "); |
2348 if (version()) tty->print("v%d ", version()); | |
2349 if (is_in_use()) tty->print("in_use "); | 2292 if (is_in_use()) tty->print("in_use "); |
2350 if (is_not_entrant()) tty->print("not_entrant "); | 2293 if (is_not_entrant()) tty->print("not_entrant "); |
2351 if (is_zombie()) tty->print("zombie "); | 2294 if (is_zombie()) tty->print("zombie "); |
2352 if (is_unloaded()) tty->print("unloaded "); | 2295 if (is_unloaded()) tty->print("unloaded "); |
2353 if (on_scavenge_root_list()) tty->print("scavenge_root "); | 2296 if (on_scavenge_root_list()) tty->print("scavenge_root "); |