hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
changeset 10250 0794cd144834
parent 10014 a5c2141ee857
child 11192 ff37c2093a0d
equal deleted inserted replaced
10031:e81ae8b523dc 10250:0794cd144834
   204   return osr_nm;
   204   return osr_nm;
   205 }
   205 }
   206 
   206 
   207 // Check if the method can be compiled, change level if necessary
   207 // Check if the method can be compiled, change level if necessary
   208 void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, TRAPS) {
   208 void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, TRAPS) {
   209   // Take the given ceiling into the account.
   209   assert(level <= TieredStopAtLevel, "Invalid compilation level");
   210   // NOTE: You can set it to 1 to get a pure C1 version.
       
   211   if ((CompLevel)TieredStopAtLevel < level) {
       
   212     level = (CompLevel)TieredStopAtLevel;
       
   213   }
       
   214   if (level == CompLevel_none) {
   210   if (level == CompLevel_none) {
   215     return;
   211     return;
   216   }
   212   }
   217   // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
   213   // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
   218   // in the interpreter and then compile with C2 (the transition function will request that,
   214   // in the interpreter and then compile with C2 (the transition function will request that,
   225     return;
   221     return;
   226   }
   222   }
   227   if (bci != InvocationEntryBci && mh->is_not_osr_compilable()) {
   223   if (bci != InvocationEntryBci && mh->is_not_osr_compilable()) {
   228     return;
   224     return;
   229   }
   225   }
   230   if (PrintTieredEvents) {
       
   231     print_event(COMPILE, mh, mh, bci, level);
       
   232   }
       
   233   if (!CompileBroker::compilation_is_in_queue(mh, bci)) {
   226   if (!CompileBroker::compilation_is_in_queue(mh, bci)) {
       
   227     if (PrintTieredEvents) {
       
   228       print_event(COMPILE, mh, mh, bci, level);
       
   229     }
   234     submit_compile(mh, bci, level, THREAD);
   230     submit_compile(mh, bci, level, THREAD);
   235   }
   231   }
   236 }
   232 }
   237 
   233 
   238 // Tell the broker to compile the method
   234 // Tell the broker to compile the method
   286   return false;
   282   return false;
   287 }
   283 }
   288 
   284 
   289 // Common transition function. Given a predicate determines if a method should transition to another level.
   285 // Common transition function. Given a predicate determines if a method should transition to another level.
   290 CompLevel SimpleThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) {
   286 CompLevel SimpleThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) {
   291   if (is_trivial(method)) return CompLevel_simple;
       
   292 
       
   293   CompLevel next_level = cur_level;
   287   CompLevel next_level = cur_level;
   294   int i = method->invocation_count();
   288   int i = method->invocation_count();
   295   int b = method->backedge_count();
   289   int b = method->backedge_count();
   296 
   290 
   297   switch(cur_level) {
   291   if (is_trivial(method)) {
   298   case CompLevel_none:
   292     next_level = CompLevel_simple;
   299     // If we were at full profile level, would we switch to full opt?
   293   } else {
   300     if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) {
   294     switch(cur_level) {
   301       next_level = CompLevel_full_optimization;
   295     case CompLevel_none:
   302     } else if ((this->*p)(i, b, cur_level)) {
   296       // If we were at full profile level, would we switch to full opt?
   303       next_level = CompLevel_full_profile;
   297       if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) {
   304     }
   298         next_level = CompLevel_full_optimization;
   305     break;
   299       } else if ((this->*p)(i, b, cur_level)) {
   306   case CompLevel_limited_profile:
   300         next_level = CompLevel_full_profile;
   307   case CompLevel_full_profile:
   301       }
   308     {
   302       break;
   309       methodDataOop mdo = method->method_data();
   303     case CompLevel_limited_profile:
   310       if (mdo != NULL) {
   304     case CompLevel_full_profile:
   311         if (mdo->would_profile()) {
   305       {
   312           int mdo_i = mdo->invocation_count_delta();
   306         methodDataOop mdo = method->method_data();
   313           int mdo_b = mdo->backedge_count_delta();
   307         if (mdo != NULL) {
   314           if ((this->*p)(mdo_i, mdo_b, cur_level)) {
   308           if (mdo->would_profile()) {
       
   309             int mdo_i = mdo->invocation_count_delta();
       
   310             int mdo_b = mdo->backedge_count_delta();
       
   311             if ((this->*p)(mdo_i, mdo_b, cur_level)) {
       
   312               next_level = CompLevel_full_optimization;
       
   313             }
       
   314           } else {
   315             next_level = CompLevel_full_optimization;
   315             next_level = CompLevel_full_optimization;
   316           }
   316           }
   317         } else {
       
   318           next_level = CompLevel_full_optimization;
       
   319         }
   317         }
   320       }
   318       }
   321     }
   319       break;
   322     break;
   320     }
   323   }
   321   }
   324   return next_level;
   322   return MIN2(next_level, (CompLevel)TieredStopAtLevel);
   325 }
   323 }
   326 
   324 
   327 // Determine if a method should be compiled with a normal entry point at a different level.
   325 // Determine if a method should be compiled with a normal entry point at a different level.
   328 CompLevel SimpleThresholdPolicy::call_event(methodOop method,  CompLevel cur_level) {
   326 CompLevel SimpleThresholdPolicy::call_event(methodOop method,  CompLevel cur_level) {
   329   CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(),
   327   CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(),