Print this page
rev 6865 : 8062169: Multiple OSR compilations issued for same bci
Summary: Fixed 'SimpleThresholdPolicy::event' to always perform OSR if an OSR nmethod is available.
Reviewed-by: kvn, iveresov

Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/runtime/simpleThresholdPolicy.cpp
          +++ new/src/share/vm/runtime/simpleThresholdPolicy.cpp
↓ open down ↓ 188 lines elided ↑ open up ↑
 189  189                                        int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
 190  190    if (comp_level == CompLevel_none &&
 191  191        JvmtiExport::can_post_interpreter_events() &&
 192  192        thread->is_interp_only_mode()) {
 193  193      return NULL;
 194  194    }
 195  195    if (CompileTheWorld || ReplayCompiles) {
 196  196      // Don't trigger other compiles in testing mode
 197  197      return NULL;
 198  198    }
 199      -  nmethod *osr_nm = NULL;
 200  199  
 201  200    handle_counter_overflow(method());
 202  201    if (method() != inlinee()) {
 203  202      handle_counter_overflow(inlinee());
 204  203    }
 205  204  
 206  205    if (PrintTieredEvents) {
 207  206      print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
 208  207    }
 209  208  
 210  209    if (bci == InvocationEntryBci) {
 211  210      method_invocation_event(method, inlinee, comp_level, nm, thread);
 212  211    } else {
 213      -    method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
 214  212      // method == inlinee if the event originated in the main method
 215      -    int highest_level = inlinee->highest_osr_comp_level();
 216      -    if (highest_level > comp_level) {
 217      -      osr_nm = inlinee->lookup_osr_nmethod_for(bci, highest_level, false);
      213 +    method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
      214 +    // Check if event led to a higher level OSR compilation
      215 +    nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false);
      216 +    if (osr_nm != NULL && osr_nm->comp_level() > comp_level) {
      217 +      // Perform OSR with new nmethod
      218 +      return osr_nm;
 218  219      }
 219  220    }
 220      -  return osr_nm;
      221 +  return NULL;
 221  222  }
 222  223  
 223  224  // Check if the method can be compiled, change level if necessary
 224  225  void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
 225  226    assert(level <= TieredStopAtLevel, "Invalid compilation level");
 226  227    if (level == CompLevel_none) {
 227  228      return;
 228  229    }
 229  230    // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 230  231    // in the interpreter and then compile with C2 (the transition function will request that,
↓ open down ↓ 184 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX