src/share/vm/runtime/compilationPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/compilationPolicy.cpp

Print this page
rev 5732 : [mq]: comments2


 216 #endif
 217 
 218   return 0;
 219 }
 220 
 221 void NonTieredCompPolicy::reset_counter_for_invocation_event(methodHandle m) {
 222   // Make sure invocation and backedge counter doesn't overflow again right away
 223   // as would be the case for native methods.
 224 
 225   // BUT also make sure the method doesn't look like it was never executed.
 226   // Set carry bit and reduce counter's value to min(count, CompileThreshold/2).
 227   MethodCounters* mcs = m->method_counters();
 228   assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
 229   mcs->invocation_counter()->set_carry();
 230   mcs->backedge_counter()->set_carry();
 231 
 232   assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed");
 233 }
 234 
 235 void NonTieredCompPolicy::reset_counter_for_back_branch_event(methodHandle m) {
 236   // Delay next back-branch event but pump up invocation counter to triger
 237   // whole method compilation.
 238   MethodCounters* mcs = m->method_counters();
 239   assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
 240   InvocationCounter* i = mcs->invocation_counter();
 241   InvocationCounter* b = mcs->backedge_counter();
 242 
 243   // Don't set invocation_counter's value too low otherwise the method will
 244   // look like immature (ic < ~5300) which prevents the inlining based on
 245   // the type profiling.
 246   i->set(i->state(), CompileThreshold);
 247   // Don't reset counter too low - it is used to check if OSR method is ready.
 248   b->set(b->state(), CompileThreshold / 2);
 249 }
 250 
 251 //
 252 // CounterDecay
 253 //
 254 // Interates through invocation counters and decrements them. This
 255 // is done at each safepoint.
 256 //
 257 class CounterDecay : public AllStatic {
 258   static jlong _last_timestamp;
 259   static void do_method(Method* m) {
 260     MethodCounters* mcs = m->method_counters();
 261     if (mcs != NULL) {
 262       mcs->invocation_counter()->decay();
 263     }
 264   }
 265 public:
 266   static void decay();
 267   static bool is_decay_needed() {
 268     return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength;
 269   }
 270 };
 271 
 272 jlong CounterDecay::_last_timestamp = 0;
 273 
 274 void CounterDecay::decay() {


 304     mcs = sd->method()->method_counters();
 305     if (mcs != NULL) {
 306       // Reset ICs of inlined methods, since they can trigger compilations also.
 307       mcs->invocation_counter()->reset();
 308     }
 309   }
 310   mcs = sd->method()->method_counters();
 311   if (mcs != NULL) {
 312     c = mcs->invocation_counter();
 313     if (is_osr) {
 314       // It was an OSR method, so bump the count higher.
 315       c->set(c->state(), CompileThreshold);
 316     } else {
 317       c->reset();
 318     }
 319     mcs->backedge_counter()->reset();
 320   }
 321 }
 322 
 323 // This method can be called by any component of the runtime to notify the policy
 324 // that it's recommended to delay the complation of this method.
 325 void NonTieredCompPolicy::delay_compilation(Method* method) {
 326   MethodCounters* mcs = method->method_counters();
 327   if (mcs != NULL) {
 328     mcs->invocation_counter()->decay();
 329     mcs->backedge_counter()->decay();
 330   }
 331 }
 332 
 333 void NonTieredCompPolicy::disable_compilation(Method* method) {
 334   MethodCounters* mcs = method->method_counters();
 335   if (mcs != NULL) {
 336     mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing);
 337     mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing);
 338   }
 339 }
 340 
 341 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) {
 342   return compile_queue->first();
 343 }
 344 




 216 #endif
 217 
 218   return 0;
 219 }
 220 
 221 void NonTieredCompPolicy::reset_counter_for_invocation_event(methodHandle m) {
 222   // Make sure invocation and backedge counter doesn't overflow again right away
 223   // as would be the case for native methods.
 224 
 225   // BUT also make sure the method doesn't look like it was never executed.
 226   // Set carry bit and reduce counter's value to min(count, CompileThreshold/2).
 227   MethodCounters* mcs = m->method_counters();
 228   assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
 229   mcs->invocation_counter()->set_carry();
 230   mcs->backedge_counter()->set_carry();
 231 
 232   assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed");
 233 }
 234 
 235 void NonTieredCompPolicy::reset_counter_for_back_branch_event(methodHandle m) {
 236   // Delay next back-branch event but pump up invocation counter to trigger
 237   // whole method compilation.
 238   MethodCounters* mcs = m->method_counters();
 239   assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
 240   InvocationCounter* i = mcs->invocation_counter();
 241   InvocationCounter* b = mcs->backedge_counter();
 242 
 243   // Don't set invocation_counter's value too low otherwise the method will
 244   // look like immature (ic < ~5300) which prevents the inlining based on
 245   // the type profiling.
 246   i->set(i->state(), CompileThreshold);
 247   // Don't reset counter too low - it is used to check if OSR method is ready.
 248   b->set(b->state(), CompileThreshold / 2);
 249 }
 250 
 251 //
 252 // CounterDecay
 253 //
 254 // Iterates through invocation counters and decrements them. This
 255 // is done at each safepoint.
 256 //
 257 class CounterDecay : public AllStatic {
 258   static jlong _last_timestamp;
 259   static void do_method(Method* m) {
 260     MethodCounters* mcs = m->method_counters();
 261     if (mcs != NULL) {
 262       mcs->invocation_counter()->decay();
 263     }
 264   }
 265 public:
 266   static void decay();
 267   static bool is_decay_needed() {
 268     return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength;
 269   }
 270 };
 271 
 272 jlong CounterDecay::_last_timestamp = 0;
 273 
 274 void CounterDecay::decay() {


 304     mcs = sd->method()->method_counters();
 305     if (mcs != NULL) {
 306       // Reset ICs of inlined methods, since they can trigger compilations also.
 307       mcs->invocation_counter()->reset();
 308     }
 309   }
 310   mcs = sd->method()->method_counters();
 311   if (mcs != NULL) {
 312     c = mcs->invocation_counter();
 313     if (is_osr) {
 314       // It was an OSR method, so bump the count higher.
 315       c->set(c->state(), CompileThreshold);
 316     } else {
 317       c->reset();
 318     }
 319     mcs->backedge_counter()->reset();
 320   }
 321 }
 322 
 323 // This method can be called by any component of the runtime to notify the policy
 324 // that it's recommended to delay the compilation of this method.
 325 void NonTieredCompPolicy::delay_compilation(Method* method) {
 326   MethodCounters* mcs = method->method_counters();
 327   if (mcs != NULL) {
 328     mcs->invocation_counter()->decay();
 329     mcs->backedge_counter()->decay();
 330   }
 331 }
 332 
 333 void NonTieredCompPolicy::disable_compilation(Method* method) {
 334   MethodCounters* mcs = method->method_counters();
 335   if (mcs != NULL) {
 336     mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing);
 337     mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing);
 338   }
 339 }
 340 
 341 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) {
 342   return compile_queue->first();
 343 }
 344 


src/share/vm/runtime/compilationPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File