1 /*
   2  * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "compiler/compileTask.hpp"
  28 #include "runtime/advancedThresholdPolicy.hpp"
  29 #include "runtime/simpleThresholdPolicy.inline.hpp"
  30 
  31 #ifdef TIERED
  32 // Print an event.
  33 void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh,
  34                                              int bci, CompLevel level) {
  35   tty->print(" rate=");
  36   if (mh->prev_time() == 0) tty->print("n/a");
  37   else tty->print("%f", mh->rate());
  38 
  39   tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback),
  40                                threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback));
  41 
  42 }
  43 
  44 void AdvancedThresholdPolicy::initialize() {
  45   // Turn on ergonomic compiler count selection
  46   if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {
  47     FLAG_SET_DEFAULT(CICompilerCountPerCPU, true);
  48   }
  49   int count = CICompilerCount;
  50   if (CICompilerCountPerCPU) {
  51     // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n
  52     int log_cpu = log2_intptr(os::active_processor_count());
  53     int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
  54     count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2;
  55   }
  56 
  57   set_c1_count(MAX2(count / 3, 1));
  58   set_c2_count(MAX2(count - c1_count(), 1));
  59   FLAG_SET_ERGO(intx, CICompilerCount, c1_count() + c2_count());
  60 
  61   // Some inlining tuning
  62 #ifdef X86
  63   if (FLAG_IS_DEFAULT(InlineSmallCode)) {
  64     FLAG_SET_DEFAULT(InlineSmallCode, 2000);
  65   }
  66 #endif
  67 
  68 #if defined SPARC || defined AARCH64
  69   if (FLAG_IS_DEFAULT(InlineSmallCode)) {
  70     FLAG_SET_DEFAULT(InlineSmallCode, 2500);
  71   }
  72 #endif
  73 
  74   set_increase_threshold_at_ratio();
  75   set_start_time(os::javaTimeMillis());
  76 }
  77 
  78 // update_rate() is called from select_task() while holding a compile queue lock.
  79 void AdvancedThresholdPolicy::update_rate(jlong t, Method* m) {
  80   // Skip update if counters are absent.
  81   // Can't allocate them since we are holding compile queue lock.
  82   if (m->method_counters() == NULL)  return;
  83 
  84   if (is_old(m)) {
  85     // We don't remove old methods from the queue,
  86     // so we can just zero the rate.
  87     m->set_rate(0);
  88     return;
  89   }
  90 
  91   // We don't update the rate if we've just came out of a safepoint.
  92   // delta_s is the time since last safepoint in milliseconds.
  93   jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
  94   jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
  95   // How many events were there since the last time?
  96   int event_count = m->invocation_count() + m->backedge_count();
  97   int delta_e = event_count - m->prev_event_count();
  98 
  99   // We should be running for at least 1ms.
 100   if (delta_s >= TieredRateUpdateMinTime) {
 101     // And we must've taken the previous point at least 1ms before.
 102     if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) {
 103       m->set_prev_time(t);
 104       m->set_prev_event_count(event_count);
 105       m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond
 106     } else {
 107       if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) {
 108         // If nothing happened for 25ms, zero the rate. Don't modify prev values.
 109         m->set_rate(0);
 110       }
 111     }
 112   }
 113 }
 114 
 115 // Check if this method has been stale from a given number of milliseconds.
 116 // See select_task().
 117 bool AdvancedThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) {
 118   jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
 119   jlong delta_t = t - m->prev_time();
 120   if (delta_t > timeout && delta_s > timeout) {
 121     int event_count = m->invocation_count() + m->backedge_count();
 122     int delta_e = event_count - m->prev_event_count();
 123     // Return true if there were no events.
 124     return delta_e == 0;
 125   }
 126   return false;
 127 }
 128 
 129 // We don't remove old methods from the compile queue even if they have
 130 // very low activity. See select_task().
 131 bool AdvancedThresholdPolicy::is_old(Method* method) {
 132   return method->invocation_count() > 50000 || method->backedge_count() > 500000;
 133 }
 134 
 135 double AdvancedThresholdPolicy::weight(Method* method) {
 136   return (double)(method->rate() + 1) *
 137     (method->invocation_count() + 1) * (method->backedge_count() + 1);
 138 }
 139 
 140 // Apply heuristics and return true if x should be compiled before y
 141 bool AdvancedThresholdPolicy::compare_methods(Method* x, Method* y) {
 142   if (x->highest_comp_level() > y->highest_comp_level()) {
 143     // recompilation after deopt
 144     return true;
 145   } else
 146     if (x->highest_comp_level() == y->highest_comp_level()) {
 147       if (weight(x) > weight(y)) {
 148         return true;
 149       }
 150     }
 151   return false;
 152 }
 153 
 154 // Is method profiled enough?
 155 bool AdvancedThresholdPolicy::is_method_profiled(Method* method) {
 156   MethodData* mdo = method->method_data();
 157   if (mdo != NULL) {
 158     int i = mdo->invocation_count_delta();
 159     int b = mdo->backedge_count_delta();
 160     return call_predicate_helper<CompLevel_full_profile>(i, b, 1, method);
 161   }
 162   return false;
 163 }
 164 
 165 // Called with the queue locked and with at least one element
 166 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
 167   CompileTask *max_blocking_task = NULL;
 168   CompileTask *max_task = NULL;
 169   Method* max_method = NULL;
 170   jlong t = os::javaTimeMillis();
 171   // Iterate through the queue and find a method with a maximum rate.
 172   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 173     CompileTask* next_task = task->next();
 174     Method* method = task->method();
 175     update_rate(t, method);
 176     if (max_task == NULL) {
 177       max_task = task;
 178       max_method = method;
 179     } else {
 180       // If a method has been stale for some time, remove it from the queue.
 181       // Blocking tasks don't become stale
 182       if (!task->is_blocking() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
 183         if (PrintTieredEvents) {
 184           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 185         }
 186         task->log_task_dequeued("stale");
 187         compile_queue->remove_and_mark_stale(task);
 188         method->clear_queued_for_compilation();
 189         task = next_task;
 190         continue;
 191       }
 192 
 193       // Select a method with a higher rate
 194       if (compare_methods(method, max_method)) {
 195         max_task = task;
 196         max_method = method;
 197       }
 198     }
 199 
 200     if (task->is_blocking()) {
 201       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
 202         max_blocking_task = task;
 203       }
 204     }
 205 
 206     task = next_task;
 207   }
 208 
 209   if (max_blocking_task != NULL) {
 210     // In blocking compilation mode, the CompileBroker will make
 211     // compilations submitted by a JVMCI compiler thread non-blocking. These
 212     // compilations should be scheduled after all blocking compilations
 213     // to service non-compiler related compilations sooner and reduce the
 214     // chance of such compilations timing out.
 215     max_task = max_blocking_task;
 216     max_method = max_task->method();
 217   }
 218 
 219   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 220       && is_method_profiled(max_method)) {
 221     max_task->set_comp_level(CompLevel_limited_profile);
 222     if (PrintTieredEvents) {
 223       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 224     }
 225   }
 226 
 227   return max_task;
 228 }
 229 
 230 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 231   double queue_size = CompileBroker::queue_size(level);
 232   int comp_count = compiler_count(level);
 233   double k = queue_size / (feedback_k * comp_count) + 1;
 234 
 235   // Increase C1 compile threshold when the code cache is filled more
 236   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 237   // The main intention is to keep enough free space for C2 compiled code
 238   // to achieve peak performance if the code cache is under stress.
 239   if ((TieredStopAtLevel == CompLevel_full_optimization) && (level != CompLevel_full_optimization))  {
 240     double current_reverse_free_ratio = CodeCache::reverse_free_ratio(CodeCache::get_code_blob_type(level));
 241     if (current_reverse_free_ratio > _increase_threshold_at_ratio) {
 242       k *= exp(current_reverse_free_ratio - _increase_threshold_at_ratio);
 243     }
 244   }
 245   return k;
 246 }
 247 
 248 // Call and loop predicates determine whether a transition to a higher
 249 // compilation level should be performed (pointers to predicate functions
 250 // are passed to common()).
 251 // Tier?LoadFeedback is basically a coefficient that determines of
 252 // how many methods per compiler thread can be in the queue before
 253 // the threshold values double.
 254 bool AdvancedThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, Method* method) {
 255   switch(cur_level) {
 256   case CompLevel_none:
 257   case CompLevel_limited_profile: {
 258     double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
 259     return loop_predicate_helper<CompLevel_none>(i, b, k, method);
 260   }
 261   case CompLevel_full_profile: {
 262     double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
 263     return loop_predicate_helper<CompLevel_full_profile>(i, b, k, method);
 264   }
 265   default:
 266     return true;
 267   }
 268 }
 269 
 270 bool AdvancedThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, Method* method) {
 271   switch(cur_level) {
 272   case CompLevel_none:
 273   case CompLevel_limited_profile: {
 274     double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
 275     return call_predicate_helper<CompLevel_none>(i, b, k, method);
 276   }
 277   case CompLevel_full_profile: {
 278     double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
 279     return call_predicate_helper<CompLevel_full_profile>(i, b, k, method);
 280   }
 281   default:
 282     return true;
 283   }
 284 }
 285 
 286 // If a method is old enough and is still in the interpreter we would want to
 287 // start profiling without waiting for the compiled method to arrive.
 288 // We also take the load on compilers into the account.
 289 bool AdvancedThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_level) {
 290   if (cur_level == CompLevel_none &&
 291       CompileBroker::queue_size(CompLevel_full_optimization) <=
 292       Tier3DelayOn * compiler_count(CompLevel_full_optimization)) {
 293     int i = method->invocation_count();
 294     int b = method->backedge_count();
 295     double k = Tier0ProfilingStartPercentage / 100.0;
 296     return call_predicate_helper<CompLevel_none>(i, b, k, method) || loop_predicate_helper<CompLevel_none>(i, b, k, method);
 297   }
 298   return false;
 299 }
 300 
 301 // Inlining control: if we're compiling a profiled method with C1 and the callee
 302 // is known to have OSRed in a C2 version, don't inline it.
 303 bool AdvancedThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) {
 304   CompLevel comp_level = (CompLevel)env->comp_level();
 305   if (comp_level == CompLevel_full_profile ||
 306       comp_level == CompLevel_limited_profile) {
 307     return callee->highest_osr_comp_level() == CompLevel_full_optimization;
 308   }
 309   return false;
 310 }
 311 
 312 // Create MDO if necessary.
 313 void AdvancedThresholdPolicy::create_mdo(methodHandle mh, JavaThread* THREAD) {
 314   if (mh->is_native() ||
 315       mh->is_abstract() ||
 316       mh->is_accessor() ||
 317       mh->is_constant_getter()) {
 318     return;
 319   }
 320   if (mh->method_data() == NULL) {
 321     Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR);
 322   }
 323 }
 324 
 325 
 326 /*
 327  * Method states:
 328  *   0 - interpreter (CompLevel_none)
 329  *   1 - pure C1 (CompLevel_simple)
 330  *   2 - C1 with invocation and backedge counting (CompLevel_limited_profile)
 331  *   3 - C1 with full profiling (CompLevel_full_profile)
 332  *   4 - C2 (CompLevel_full_optimization)
 333  *
 334  * Common state transition patterns:
 335  * a. 0 -> 3 -> 4.
 336  *    The most common path. But note that even in this straightforward case
 337  *    profiling can start at level 0 and finish at level 3.
 338  *
 339  * b. 0 -> 2 -> 3 -> 4.
 340  *    This case occurs when the load on C2 is deemed too high. So, instead of transitioning
 341  *    into state 3 directly and over-profiling while a method is in the C2 queue we transition to
 342  *    level 2 and wait until the load on C2 decreases. This path is disabled for OSRs.
 343  *
 344  * c. 0 -> (3->2) -> 4.
 345  *    In this case we enqueue a method for compilation at level 3, but the C1 queue is long enough
 346  *    to enable the profiling to fully occur at level 0. In this case we change the compilation level
 347  *    of the method to 2 while the request is still in-queue, because it'll allow it to run much faster
 348  *    without full profiling while c2 is compiling.
 349  *
 350  * d. 0 -> 3 -> 1 or 0 -> 2 -> 1.
 351  *    After a method was once compiled with C1 it can be identified as trivial and be compiled to
 352  *    level 1. These transition can also occur if a method can't be compiled with C2 but can with C1.
 353  *
 354  * e. 0 -> 4.
 355  *    This can happen if a method fails C1 compilation (it will still be profiled in the interpreter)
 356  *    or because of a deopt that didn't require reprofiling (compilation won't happen in this case because
 357  *    the compiled version already exists).
 358  *
 359  * Note that since state 0 can be reached from any other state via deoptimization different loops
 360  * are possible.
 361  *
 362  */
 363 
 364 // Common transition function. Given a predicate determines if a method should transition to another level.
 365 CompLevel AdvancedThresholdPolicy::common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback) {
 366   CompLevel next_level = cur_level;
 367   int i = method->invocation_count();
 368   int b = method->backedge_count();
 369 
 370   if (is_trivial(method)) {
 371     next_level = CompLevel_simple;
 372   } else {
 373     switch(cur_level) {
 374     case CompLevel_none:
 375       // If we were at full profile level, would we switch to full opt?
 376       if (common(p, method, CompLevel_full_profile, disable_feedback) == CompLevel_full_optimization) {
 377         next_level = CompLevel_full_optimization;
 378       } else if ((this->*p)(i, b, cur_level, method)) {
 379 #if INCLUDE_JVMCI
 380         if (UseJVMCICompiler) {
 381           // Since JVMCI takes a while to warm up, its queue inevitably backs up during
 382           // early VM execution.
 383           next_level = CompLevel_full_profile;
 384           break;
 385         }
 386 #endif
 387         // C1-generated fully profiled code is about 30% slower than the limited profile
 388         // code that has only invocation and backedge counters. The observation is that
 389         // if C2 queue is large enough we can spend too much time in the fully profiled code
 390         // while waiting for C2 to pick the method from the queue. To alleviate this problem
 391         // we introduce a feedback on the C2 queue size. If the C2 queue is sufficiently long
 392         // we choose to compile a limited profiled version and then recompile with full profiling
 393         // when the load on C2 goes down.
 394         if (!disable_feedback && CompileBroker::queue_size(CompLevel_full_optimization) >
 395             Tier3DelayOn * compiler_count(CompLevel_full_optimization)) {
 396           next_level = CompLevel_limited_profile;
 397         } else {
 398           next_level = CompLevel_full_profile;
 399         }
 400       }
 401       break;
 402     case CompLevel_limited_profile:
 403       if (is_method_profiled(method)) {
 404         // Special case: we got here because this method was fully profiled in the interpreter.
 405         next_level = CompLevel_full_optimization;
 406       } else {
 407         MethodData* mdo = method->method_data();
 408         if (mdo != NULL) {
 409           if (mdo->would_profile()) {
 410             if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <=
 411                                      Tier3DelayOff * compiler_count(CompLevel_full_optimization) &&
 412                                      (this->*p)(i, b, cur_level, method))) {
 413               next_level = CompLevel_full_profile;
 414             }
 415           } else {
 416             next_level = CompLevel_full_optimization;
 417           }
 418         }
 419       }
 420       break;
 421     case CompLevel_full_profile:
 422       {
 423         MethodData* mdo = method->method_data();
 424         if (mdo != NULL) {
 425           if (mdo->would_profile()) {
 426             int mdo_i = mdo->invocation_count_delta();
 427             int mdo_b = mdo->backedge_count_delta();
 428             if ((this->*p)(mdo_i, mdo_b, cur_level, method)) {
 429               next_level = CompLevel_full_optimization;
 430             }
 431           } else {
 432             next_level = CompLevel_full_optimization;
 433           }
 434         }
 435       }
 436       break;
 437     }
 438   }
 439   return MIN2(next_level, (CompLevel)TieredStopAtLevel);
 440 }
 441 
 442 // Determine if a method should be compiled with a normal entry point at a different level.
 443 CompLevel AdvancedThresholdPolicy::call_event(Method* method, CompLevel cur_level) {
 444   CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(),
 445                              common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true));
 446   CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level);
 447 
 448   // If OSR method level is greater than the regular method level, the levels should be
 449   // equalized by raising the regular method level in order to avoid OSRs during each
 450   // invocation of the method.
 451   if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) {
 452     MethodData* mdo = method->method_data();
 453     guarantee(mdo != NULL, "MDO should not be NULL");
 454     if (mdo->invocation_count() >= 1) {
 455       next_level = CompLevel_full_optimization;
 456     }
 457   } else {
 458     next_level = MAX2(osr_level, next_level);
 459   }
 460   return next_level;
 461 }
 462 
 463 // Determine if we should do an OSR compilation of a given method.
 464 CompLevel AdvancedThresholdPolicy::loop_event(Method* method, CompLevel cur_level) {
 465   CompLevel next_level = common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true);
 466   if (cur_level == CompLevel_none) {
 467     // If there is a live OSR method that means that we deopted to the interpreter
 468     // for the transition.
 469     CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level);
 470     if (osr_level > CompLevel_none) {
 471       return osr_level;
 472     }
 473   }
 474   return next_level;
 475 }
 476 
 477 // Update the rate and submit compile
 478 void AdvancedThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
 479   int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
 480   update_rate(os::javaTimeMillis(), mh());
 481   CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread);
 482 }
 483 
 484 // Handle the invocation event.
 485 void AdvancedThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh,
 486                                                       CompLevel level, nmethod* nm, JavaThread* thread) {
 487   if (should_create_mdo(mh(), level)) {
 488     create_mdo(mh, thread);
 489   }
 490   if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) {
 491     CompLevel next_level = call_event(mh(), level);
 492     if (next_level != level) {
 493       compile(mh, InvocationEntryBci, next_level, thread);
 494     }
 495   }
 496 }
 497 
 498 // Handle the back branch event. Notice that we can compile the method
 499 // with a regular entry from here.
 500 void AdvancedThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh,
 501                                                        int bci, CompLevel level, nmethod* nm, JavaThread* thread) {
 502   if (should_create_mdo(mh(), level)) {
 503     create_mdo(mh, thread);
 504   }
 505   // Check if MDO should be created for the inlined method
 506   if (should_create_mdo(imh(), level)) {
 507     create_mdo(imh, thread);
 508   }
 509 
 510   if (is_compilation_enabled()) {
 511     CompLevel next_osr_level = loop_event(imh(), level);
 512     CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level();
 513     // At the very least compile the OSR version
 514     if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) {
 515       compile(imh, bci, next_osr_level, thread);
 516     }
 517 
 518     // Use loop event as an opportunity to also check if there's been
 519     // enough calls.
 520     CompLevel cur_level, next_level;
 521     if (mh() != imh()) { // If there is an enclosing method
 522       guarantee(nm != NULL, "Should have nmethod here");
 523       cur_level = comp_level(mh());
 524       next_level = call_event(mh(), cur_level);
 525 
 526       if (max_osr_level == CompLevel_full_optimization) {
 527         // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts
 528         bool make_not_entrant = false;
 529         if (nm->is_osr_method()) {
 530           // This is an osr method, just make it not entrant and recompile later if needed
 531           make_not_entrant = true;
 532         } else {
 533           if (next_level != CompLevel_full_optimization) {
 534             // next_level is not full opt, so we need to recompile the
 535             // enclosing method without the inlinee
 536             cur_level = CompLevel_none;
 537             make_not_entrant = true;
 538           }
 539         }
 540         if (make_not_entrant) {
 541           if (PrintTieredEvents) {
 542             int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
 543             print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
 544           }
 545           nm->make_not_entrant();
 546         }
 547       }
 548       if (!CompileBroker::compilation_is_in_queue(mh)) {
 549         // Fix up next_level if necessary to avoid deopts
 550         if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) {
 551           next_level = CompLevel_full_profile;
 552         }
 553         if (cur_level != next_level) {
 554           compile(mh, InvocationEntryBci, next_level, thread);
 555         }
 556       }
 557     } else {
 558       cur_level = comp_level(imh());
 559       next_level = call_event(imh(), cur_level);
 560       if (!CompileBroker::compilation_is_in_queue(imh) && (next_level != cur_level)) {
 561         compile(imh, InvocationEntryBci, next_level, thread);
 562       }
 563     }
 564   }
 565 }
 566 
 567 #endif // TIERED