Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/runtime/simpleThresholdPolicy.cpp
          +++ new/src/share/vm/runtime/simpleThresholdPolicy.cpp
↓ open down ↓ 198 lines elided ↑ open up ↑
 199  199      int highest_level = inlinee->highest_osr_comp_level();
 200  200      if (highest_level > comp_level) {
 201  201        osr_nm = inlinee->lookup_osr_nmethod_for(bci, highest_level, false);
 202  202      }
 203  203    }
 204  204    return osr_nm;
 205  205  }
 206  206  
 207  207  // Check if the method can be compiled, change level if necessary
 208  208  void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, TRAPS) {
 209      -  // Take the given ceiling into the account.
 210      -  // NOTE: You can set it to 1 to get a pure C1 version.
 211      -  if ((CompLevel)TieredStopAtLevel < level) {
 212      -    level = (CompLevel)TieredStopAtLevel;
 213      -  }
      209 +  assert(level <= TieredStopAtLevel, "Invalid compilation level");
 214  210    if (level == CompLevel_none) {
 215  211      return;
 216  212    }
 217  213    // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 218  214    // in the interpreter and then compile with C2 (the transition function will request that,
 219  215    // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 220  216    // pure C1.
 221  217    if (!can_be_compiled(mh, level)) {
 222  218      if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 223  219          compile(mh, bci, CompLevel_simple, THREAD);
 224  220      }
 225  221      return;
 226  222    }
 227  223    if (bci != InvocationEntryBci && mh->is_not_osr_compilable()) {
 228  224      return;
 229  225    }
 230      -  if (PrintTieredEvents) {
 231      -    print_event(COMPILE, mh, mh, bci, level);
 232      -  }
 233  226    if (!CompileBroker::compilation_is_in_queue(mh, bci)) {
      227 +    if (PrintTieredEvents) {
      228 +      print_event(COMPILE, mh, mh, bci, level);
      229 +    }
 234  230      submit_compile(mh, bci, level, THREAD);
 235  231    }
 236  232  }
 237  233  
 238  234  // Tell the broker to compile the method
 239  235  void SimpleThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) {
 240  236    int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
 241  237    CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD);
 242  238  }
 243  239  
↓ open down ↓ 37 lines elided ↑ open up ↑
 281  277      int b = mdo->backedge_count();
 282  278      double k = ProfileMaturityPercentage / 100.0;
 283  279      return call_predicate_helper<CompLevel_full_profile>(i, b, k) ||
 284  280             loop_predicate_helper<CompLevel_full_profile>(i, b, k);
 285  281    }
 286  282    return false;
 287  283  }
 288  284  
 289  285  // Common transition function. Given a predicate determines if a method should transition to another level.
 290  286  CompLevel SimpleThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) {
 291      -  if (is_trivial(method)) return CompLevel_simple;
 292      -
 293  287    CompLevel next_level = cur_level;
 294  288    int i = method->invocation_count();
 295  289    int b = method->backedge_count();
 296  290  
 297      -  switch(cur_level) {
 298      -  case CompLevel_none:
 299      -    // If we were at full profile level, would we switch to full opt?
 300      -    if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) {
 301      -      next_level = CompLevel_full_optimization;
 302      -    } else if ((this->*p)(i, b, cur_level)) {
 303      -      next_level = CompLevel_full_profile;
 304      -    }
 305      -    break;
 306      -  case CompLevel_limited_profile:
 307      -  case CompLevel_full_profile:
 308      -    {
 309      -      methodDataOop mdo = method->method_data();
 310      -      if (mdo != NULL) {
 311      -        if (mdo->would_profile()) {
 312      -          int mdo_i = mdo->invocation_count_delta();
 313      -          int mdo_b = mdo->backedge_count_delta();
 314      -          if ((this->*p)(mdo_i, mdo_b, cur_level)) {
      291 +  if (is_trivial(method)) {
      292 +    next_level = CompLevel_simple;
      293 +  } else {
      294 +    switch(cur_level) {
      295 +    case CompLevel_none:
      296 +      // If we were at full profile level, would we switch to full opt?
      297 +      if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) {
      298 +        next_level = CompLevel_full_optimization;
      299 +      } else if ((this->*p)(i, b, cur_level)) {
      300 +        next_level = CompLevel_full_profile;
      301 +      }
      302 +      break;
      303 +    case CompLevel_limited_profile:
      304 +    case CompLevel_full_profile:
      305 +      {
      306 +        methodDataOop mdo = method->method_data();
      307 +        if (mdo != NULL) {
      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  315              next_level = CompLevel_full_optimization;
 316  316            }
 317      -        } else {
 318      -          next_level = CompLevel_full_optimization;
 319  317          }
 320  318        }
      319 +      break;
 321  320      }
 322      -    break;
 323  321    }
 324      -  return next_level;
      322 +  return MIN2(next_level, (CompLevel)TieredStopAtLevel);
 325  323  }
 326  324  
 327  325  // Determine if a method should be compiled with a normal entry point at a different level.
 328  326  CompLevel SimpleThresholdPolicy::call_event(methodOop method,  CompLevel cur_level) {
 329  327    CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(),
 330  328                               common(&SimpleThresholdPolicy::loop_predicate, method, cur_level));
 331  329    CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level);
 332  330  
 333  331    // If OSR method level is greater than the regular method level, the levels should be
 334  332    // equalized by raising the regular method level in order to avoid OSRs during each
↓ open down ↓ 66 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX