< prev index next >

src/share/vm/runtime/compilationPolicy.cpp

Print this page




 295     if (mcs != NULL) {
 296       mcs->invocation_counter()->decay();
 297     }
 298   }
 299 public:
 300   static void decay();
 301   static bool is_decay_needed() {
 302     return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength;
 303   }
 304 };
 305 
 306 jlong CounterDecay::_last_timestamp = 0;
 307 
 308 void CounterDecay::decay() {
 309   _last_timestamp = os::javaTimeMillis();
 310 
 311   // This operation is going to be performed only at the end of a safepoint
 312   // and hence GC's will not be going on, all Java mutators are suspended
 313   // at this point and hence SystemDictionary_lock is also not needed.
 314   assert(SafepointSynchronize::is_at_safepoint(), "can only be executed at a safepoint");
 315   int nclasses = SystemDictionary::number_of_classes();
 316   double classes_per_tick = nclasses * (CounterDecayMinIntervalLength * 1e-3 /
 317                                         CounterHalfLifeTime);
 318   for (int i = 0; i < classes_per_tick; i++) {
 319     Klass* k = SystemDictionary::try_get_next_class();
 320     if (k != NULL && k->is_instance_klass()) {
 321       InstanceKlass::cast(k)->methods_do(do_method);
 322     }
 323   }
 324 }
 325 
 326 // Called at the end of the safepoint
 327 void NonTieredCompPolicy::do_safepoint_work() {
 328   if(UseCounterDecay && CounterDecay::is_decay_needed()) {
 329     CounterDecay::decay();
 330   }
 331 }
 332 
 333 void NonTieredCompPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
 334   ScopeDesc* sd = trap_scope;
 335   MethodCounters* mcs;
 336   InvocationCounter* c;
 337   for (; !sd->is_top(); sd = sd->sender()) {
 338     mcs = sd->method()->method_counters();
 339     if (mcs != NULL) {
 340       // Reset ICs of inlined methods, since they can trigger compilations also.
 341       mcs->invocation_counter()->reset();




 295     if (mcs != NULL) {
 296       mcs->invocation_counter()->decay();
 297     }
 298   }
 299 public:
 300   static void decay();
 301   static bool is_decay_needed() {
 302     return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength;
 303   }
 304 };
 305 
 306 jlong CounterDecay::_last_timestamp = 0;
 307 
 308 void CounterDecay::decay() {
 309   _last_timestamp = os::javaTimeMillis();
 310 
 311   // This operation is going to be performed only at the end of a safepoint
 312   // and hence GC's will not be going on, all Java mutators are suspended
 313   // at this point and hence SystemDictionary_lock is also not needed.
 314   assert(SafepointSynchronize::is_at_safepoint(), "can only be executed at a safepoint");
 315   int nclasses = InstanceKlass::number_of_instance_classes();
 316   double classes_per_tick = nclasses * (CounterDecayMinIntervalLength * 1e-3 /
 317                                         CounterHalfLifeTime);
 318   for (int i = 0; i < classes_per_tick; i++) {
 319     InstanceKlass* k = ClassLoaderDataGraph::try_get_next_class();
 320     if (k != NULL) {
 321       k->methods_do(do_method);
 322     }
 323   }
 324 }
 325 
 326 // Called at the end of the safepoint
 327 void NonTieredCompPolicy::do_safepoint_work() {
 328   if(UseCounterDecay && CounterDecay::is_decay_needed()) {
 329     CounterDecay::decay();
 330   }
 331 }
 332 
 333 void NonTieredCompPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
 334   ScopeDesc* sd = trap_scope;
 335   MethodCounters* mcs;
 336   InvocationCounter* c;
 337   for (; !sd->is_top(); sd = sd->sender()) {
 338     mcs = sd->method()->method_counters();
 339     if (mcs != NULL) {
 340       // Reset ICs of inlined methods, since they can trigger compilations also.
 341       mcs->invocation_counter()->reset();


< prev index next >