1.1 --- a/src/share/vm/code/nmethod.cpp Fri Sep 27 08:39:19 2013 +0200 1.2 +++ b/src/share/vm/code/nmethod.cpp Fri Sep 27 10:50:55 2013 +0200 1.3 @@ -462,7 +462,6 @@ 1.4 _state = alive; 1.5 _marked_for_reclamation = 0; 1.6 _has_flushed_dependencies = 0; 1.7 - _speculatively_disconnected = 0; 1.8 _has_unsafe_access = 0; 1.9 _has_method_handle_invokes = 0; 1.10 _lazy_critical_native = 0; 1.11 @@ -481,7 +480,6 @@ 1.12 _osr_link = NULL; 1.13 _scavenge_root_link = NULL; 1.14 _scavenge_root_state = 0; 1.15 - _saved_nmethod_link = NULL; 1.16 _compiler = NULL; 1.17 1.18 #ifdef HAVE_DTRACE_H 1.19 @@ -686,6 +684,7 @@ 1.20 _osr_entry_point = NULL; 1.21 _exception_cache = NULL; 1.22 _pc_desc_cache.reset_to(NULL); 1.23 + _hotness_counter = NMethodSweeper::hotness_counter_reset_val(); 1.24 1.25 code_buffer->copy_values_to(this); 1.26 if (ScavengeRootsInCode && detect_scavenge_root_oops()) { 1.27 @@ -770,6 +769,7 @@ 1.28 _osr_entry_point = NULL; 1.29 _exception_cache = NULL; 1.30 _pc_desc_cache.reset_to(NULL); 1.31 + _hotness_counter = NMethodSweeper::hotness_counter_reset_val(); 1.32 1.33 code_buffer->copy_values_to(this); 1.34 debug_only(verify_scavenge_root_oops()); 1.35 @@ -842,6 +842,7 @@ 1.36 _comp_level = comp_level; 1.37 _compiler = compiler; 1.38 _orig_pc_offset = orig_pc_offset; 1.39 + _hotness_counter = NMethodSweeper::hotness_counter_reset_val(); 1.40 1.41 // Section offsets 1.42 _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts()); 1.43 @@ -1176,7 +1177,7 @@ 1.44 1.45 // This is a private interface with the sweeper. 1.46 void nmethod::mark_as_seen_on_stack() { 1.47 - assert(is_not_entrant(), "must be a non-entrant method"); 1.48 + assert(is_alive(), "Must be an alive method"); 1.49 // Set the traversal mark to ensure that the sweeper does 2 1.50 // cleaning passes before moving to zombie. 1.51 set_stack_traversal_mark(NMethodSweeper::traversal_count()); 1.52 @@ -1261,7 +1262,7 @@ 1.53 1.54 set_osr_link(NULL); 1.55 //set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods 1.56 - NMethodSweeper::notify(this); 1.57 + NMethodSweeper::notify(); 1.58 } 1.59 1.60 void nmethod::invalidate_osr_method() { 1.61 @@ -1351,6 +1352,15 @@ 1.62 nmethod_needs_unregister = true; 1.63 } 1.64 1.65 + // Must happen before state change. Otherwise we have a race condition in 1.66 + // nmethod::can_not_entrant_be_converted(). I.e., a method can immediately 1.67 + // transition its state from 'not_entrant' to 'zombie' without having to wait 1.68 + // for stack scanning. 1.69 + if (state == not_entrant) { 1.70 + mark_as_seen_on_stack(); 1.71 + OrderAccess::storestore(); 1.72 + } 1.73 + 1.74 // Change state 1.75 _state = state; 1.76 1.77 @@ -1369,11 +1379,6 @@ 1.78 HandleMark hm; 1.79 method()->clear_code(); 1.80 } 1.81 - 1.82 - if (state == not_entrant) { 1.83 - mark_as_seen_on_stack(); 1.84 - } 1.85 - 1.86 } // leave critical region under Patching_lock 1.87 1.88 // When the nmethod becomes zombie it is no longer alive so the 1.89 @@ -1416,7 +1421,7 @@ 1.90 } 1.91 1.92 // Make sweeper aware that there is a zombie method that needs to be removed 1.93 - NMethodSweeper::notify(this); 1.94 + NMethodSweeper::notify(); 1.95 1.96 return true; 1.97 } 1.98 @@ -1451,10 +1456,6 @@ 1.99 CodeCache::drop_scavenge_root_nmethod(this); 1.100 } 1.101 1.102 - if (is_speculatively_disconnected()) { 1.103 - CodeCache::remove_saved_code(this); 1.104 - } 1.105 - 1.106 #ifdef SHARK 1.107 ((SharkCompiler *) compiler())->free_compiled_method(insts_begin()); 1.108 #endif // SHARK