1.1 --- a/src/share/vm/oops/method.cpp Thu Apr 04 21:15:43 2013 -0700 1.2 +++ b/src/share/vm/oops/method.cpp Tue Apr 09 17:17:41 2013 -0400 1.3 @@ -91,7 +91,7 @@ 1.4 set_hidden(false); 1.5 set_dont_inline(false); 1.6 set_method_data(NULL); 1.7 - set_interpreter_throwout_count(0); 1.8 + set_method_counters(NULL); 1.9 set_vtable_index(Method::garbage_vtable_index); 1.10 1.11 // Fix and bury in Method* 1.12 @@ -105,16 +105,6 @@ 1.13 } 1.14 1.15 NOT_PRODUCT(set_compiled_invocation_count(0);) 1.16 - set_interpreter_invocation_count(0); 1.17 - invocation_counter()->init(); 1.18 - backedge_counter()->init(); 1.19 - clear_number_of_breakpoints(); 1.20 - 1.21 -#ifdef TIERED 1.22 - set_rate(0); 1.23 - set_prev_event_count(0); 1.24 - set_prev_time(0); 1.25 -#endif 1.26 } 1.27 1.28 // Release Method*. The nmethod will be gone when we get here because 1.29 @@ -124,6 +114,8 @@ 1.30 set_constMethod(NULL); 1.31 MetadataFactory::free_metadata(loader_data, method_data()); 1.32 set_method_data(NULL); 1.33 + MetadataFactory::free_metadata(loader_data, method_counters()); 1.34 + set_method_counters(NULL); 1.35 // The nmethod will be gone when we get here. 1.36 if (code() != NULL) _code = NULL; 1.37 } 1.38 @@ -323,7 +315,10 @@ 1.39 // compiler does not bump invocation counter of compiled methods 1.40 return true; 1.41 } 1.42 - else if (_invocation_counter.carry() || (method_data() != NULL && method_data()->invocation_counter()->carry())) { 1.43 + else if ((method_counters() != NULL && 1.44 + method_counters()->invocation_counter()->carry()) || 1.45 + (method_data() != NULL && 1.46 + method_data()->invocation_counter()->carry())) { 1.47 // The carry bit is set when the counter overflows and causes 1.48 // a compilation to occur. We don't know how many times 1.49 // the counter has been reset, so we simply assume it has 1.50 @@ -387,6 +382,18 @@ 1.51 } 1.52 } 1.53 1.54 +MethodCounters* Method::build_method_counters(Method* m, TRAPS) { 1.55 + methodHandle mh(m); 1.56 + ClassLoaderData* loader_data = mh->method_holder()->class_loader_data(); 1.57 + MethodCounters* counters = MethodCounters::allocate(loader_data, CHECK_NULL); 1.58 + if (mh->method_counters() == NULL) { 1.59 + mh->set_method_counters(counters); 1.60 + } else { 1.61 + MetadataFactory::free_metadata(loader_data, counters); 1.62 + } 1.63 + return mh->method_counters(); 1.64 +} 1.65 + 1.66 void Method::cleanup_inline_caches() { 1.67 // The current system doesn't use inline caches in the interpreter 1.68 // => nothing to do (keep this method around for future use) 1.69 @@ -794,8 +801,6 @@ 1.70 set_signature_handler(NULL); 1.71 } 1.72 NOT_PRODUCT(set_compiled_invocation_count(0);) 1.73 - invocation_counter()->reset(); 1.74 - backedge_counter()->reset(); 1.75 _adapter = NULL; 1.76 _from_compiled_entry = NULL; 1.77 1.78 @@ -808,8 +813,7 @@ 1.79 assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?"); 1.80 1.81 set_method_data(NULL); 1.82 - set_interpreter_throwout_count(0); 1.83 - set_interpreter_invocation_count(0); 1.84 + set_method_counters(NULL); 1.85 } 1.86 1.87 // Called when the method_holder is getting linked. Setup entrypoints so the method 1.88 @@ -1545,28 +1549,34 @@ 1.89 1.90 1.91 int Method::invocation_count() { 1.92 + MethodCounters *mcs = method_counters(); 1.93 if (TieredCompilation) { 1.94 MethodData* const mdo = method_data(); 1.95 - if (invocation_counter()->carry() || ((mdo != NULL) ? mdo->invocation_counter()->carry() : false)) { 1.96 + if (((mcs != NULL) ? mcs->invocation_counter()->carry() : false) || 1.97 + ((mdo != NULL) ? mdo->invocation_counter()->carry() : false)) { 1.98 return InvocationCounter::count_limit; 1.99 } else { 1.100 - return invocation_counter()->count() + ((mdo != NULL) ? mdo->invocation_counter()->count() : 0); 1.101 + return ((mcs != NULL) ? mcs->invocation_counter()->count() : 0) + 1.102 + ((mdo != NULL) ? mdo->invocation_counter()->count() : 0); 1.103 } 1.104 } else { 1.105 - return invocation_counter()->count(); 1.106 + return (mcs == NULL) ? 0 : mcs->invocation_counter()->count(); 1.107 } 1.108 } 1.109 1.110 int Method::backedge_count() { 1.111 + MethodCounters *mcs = method_counters(); 1.112 if (TieredCompilation) { 1.113 MethodData* const mdo = method_data(); 1.114 - if (backedge_counter()->carry() || ((mdo != NULL) ? mdo->backedge_counter()->carry() : false)) { 1.115 + if (((mcs != NULL) ? mcs->backedge_counter()->carry() : false) || 1.116 + ((mdo != NULL) ? mdo->backedge_counter()->carry() : false)) { 1.117 return InvocationCounter::count_limit; 1.118 } else { 1.119 - return backedge_counter()->count() + ((mdo != NULL) ? mdo->backedge_counter()->count() : 0); 1.120 + return ((mcs != NULL) ? mcs->backedge_counter()->count() : 0) + 1.121 + ((mdo != NULL) ? mdo->backedge_counter()->count() : 0); 1.122 } 1.123 } else { 1.124 - return backedge_counter()->count(); 1.125 + return (mcs == NULL) ? 0 : mcs->backedge_counter()->count(); 1.126 } 1.127 } 1.128 1.129 @@ -1621,12 +1631,12 @@ 1.130 assert(orig_bytecode() == code, "original bytecode must be the same"); 1.131 } 1.132 #endif 1.133 + Thread *thread = Thread::current(); 1.134 *method->bcp_from(_bci) = Bytecodes::_breakpoint; 1.135 - method->incr_number_of_breakpoints(); 1.136 + method->incr_number_of_breakpoints(thread); 1.137 SystemDictionary::notice_modification(); 1.138 { 1.139 // Deoptimize all dependents on this method 1.140 - Thread *thread = Thread::current(); 1.141 HandleMark hm(thread); 1.142 methodHandle mh(thread, method); 1.143 Universe::flush_dependents_on_method(mh); 1.144 @@ -1636,7 +1646,7 @@ 1.145 void BreakpointInfo::clear(Method* method) { 1.146 *method->bcp_from(_bci) = orig_bytecode(); 1.147 assert(method->number_of_breakpoints() > 0, "must not go negative"); 1.148 - method->decr_number_of_breakpoints(); 1.149 + method->decr_number_of_breakpoints(Thread::current()); 1.150 } 1.151 1.152 // jmethodID handling