hotspot/src/share/vm/runtime/deoptimization.cpp
changeset 6453 970dc585ab63
parent 6187 4fa7845f7c14
child 6740 2bc601284215
equal deleted inserted replaced
6452:cc624b341ab2 6453:970dc585ab63
  1299     // The other actions cause immediate removal of the present code.
  1299     // The other actions cause immediate removal of the present code.
  1300 
  1300 
  1301     bool update_trap_state = true;
  1301     bool update_trap_state = true;
  1302     bool make_not_entrant = false;
  1302     bool make_not_entrant = false;
  1303     bool make_not_compilable = false;
  1303     bool make_not_compilable = false;
  1304     bool reset_counters = false;
  1304     bool reprofile = false;
  1305     switch (action) {
  1305     switch (action) {
  1306     case Action_none:
  1306     case Action_none:
  1307       // Keep the old code.
  1307       // Keep the old code.
  1308       update_trap_state = false;
  1308       update_trap_state = false;
  1309       break;
  1309       break;
  1326       // Note that the compiler will track null_check, null_assert,
  1326       // Note that the compiler will track null_check, null_assert,
  1327       // range_check, and class_check events and log them as if they
  1327       // range_check, and class_check events and log them as if they
  1328       // had been traps taken from compiled code.  This will update
  1328       // had been traps taken from compiled code.  This will update
  1329       // the MDO trap history so that the next compilation will
  1329       // the MDO trap history so that the next compilation will
  1330       // properly detect hot trap sites.
  1330       // properly detect hot trap sites.
  1331       reset_counters = true;
  1331       reprofile = true;
  1332       break;
  1332       break;
  1333     case Action_make_not_entrant:
  1333     case Action_make_not_entrant:
  1334       // Request immediate recompilation, and get rid of the old code.
  1334       // Request immediate recompilation, and get rid of the old code.
  1335       // Make them not entrant, so next time they are called they get
  1335       // Make them not entrant, so next time they are called they get
  1336       // recompiled.  Unloaded classes are loaded now so recompile before next
  1336       // recompiled.  Unloaded classes are loaded now so recompile before next
  1420 
  1420 
  1421       // Here's more hysteresis:  If there has been a recompile at
  1421       // Here's more hysteresis:  If there has been a recompile at
  1422       // this trap point already, run the method in the interpreter
  1422       // this trap point already, run the method in the interpreter
  1423       // for a while to exercise it more thoroughly.
  1423       // for a while to exercise it more thoroughly.
  1424       if (make_not_entrant && maybe_prior_recompile && maybe_prior_trap) {
  1424       if (make_not_entrant && maybe_prior_recompile && maybe_prior_trap) {
  1425         reset_counters = true;
  1425         reprofile = true;
  1426       }
  1426       }
  1427 
  1427 
  1428     }
  1428     }
  1429 
  1429 
  1430     // Take requested actions on the method:
  1430     // Take requested actions on the method:
  1450           (uint)PerBytecodeRecompilationCutoff) {
  1450           (uint)PerBytecodeRecompilationCutoff) {
  1451         // Give up on the method containing the bad BCI.
  1451         // Give up on the method containing the bad BCI.
  1452         if (trap_method() == nm->method()) {
  1452         if (trap_method() == nm->method()) {
  1453           make_not_compilable = true;
  1453           make_not_compilable = true;
  1454         } else {
  1454         } else {
  1455           trap_method->set_not_compilable();
  1455           trap_method->set_not_compilable(CompLevel_full_optimization);
  1456           // But give grace to the enclosing nm->method().
  1456           // But give grace to the enclosing nm->method().
  1457         }
  1457         }
  1458       }
  1458       }
  1459     }
  1459     }
  1460 
  1460 
  1461     // Reset invocation counters
  1461     // Reprofile
  1462     if (reset_counters) {
  1462     if (reprofile) {
  1463       if (nm->is_osr_method())
  1463       CompilationPolicy::policy()->reprofile(trap_scope, nm->is_osr_method());
  1464         reset_invocation_counter(trap_scope, CompileThreshold);
       
  1465       else
       
  1466         reset_invocation_counter(trap_scope);
       
  1467     }
  1464     }
  1468 
  1465 
  1469     // Give up compiling
  1466     // Give up compiling
  1470     if (make_not_compilable && !nm->method()->is_not_compilable()) {
  1467     if (make_not_compilable && !nm->method()->is_not_compilable(CompLevel_full_optimization)) {
  1471       assert(make_not_entrant, "consistent");
  1468       assert(make_not_entrant, "consistent");
  1472       nm->method()->set_not_compilable();
  1469       nm->method()->set_not_compilable(CompLevel_full_optimization);
  1473     }
  1470     }
  1474 
  1471 
  1475   } // Free marked resources
  1472   } // Free marked resources
  1476 
  1473 
  1477 }
  1474 }
  1565   query_update_method_data(trap_mdo, trap_bci,
  1562   query_update_method_data(trap_mdo, trap_bci,
  1566                            (DeoptReason)reason,
  1563                            (DeoptReason)reason,
  1567                            ignore_this_trap_count,
  1564                            ignore_this_trap_count,
  1568                            ignore_maybe_prior_trap,
  1565                            ignore_maybe_prior_trap,
  1569                            ignore_maybe_prior_recompile);
  1566                            ignore_maybe_prior_recompile);
  1570 }
       
  1571 
       
  1572 void Deoptimization::reset_invocation_counter(ScopeDesc* trap_scope, jint top_count) {
       
  1573   ScopeDesc* sd = trap_scope;
       
  1574   for (; !sd->is_top(); sd = sd->sender()) {
       
  1575     // Reset ICs of inlined methods, since they can trigger compilations also.
       
  1576     sd->method()->invocation_counter()->reset();
       
  1577   }
       
  1578   InvocationCounter* c = sd->method()->invocation_counter();
       
  1579   if (top_count != _no_count) {
       
  1580     // It was an OSR method, so bump the count higher.
       
  1581     c->set(c->state(), top_count);
       
  1582   } else {
       
  1583     c->reset();
       
  1584   }
       
  1585   sd->method()->backedge_counter()->reset();
       
  1586 }
  1567 }
  1587 
  1568 
  1588 Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* thread, jint trap_request) {
  1569 Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* thread, jint trap_request) {
  1589 
  1570 
  1590   // Still in Java no safepoints
  1571   // Still in Java no safepoints