comparison src/share/vm/runtime/deoptimization.cpp @ 17810:62c54fcc0a35

Merge
author kvn
date Tue, 25 Mar 2014 17:07:36 -0700
parents a9becfeecd1b 606acabe7b5c
children 78bbf4d43a14
comparison
equal deleted inserted replaced
17809:a433eb716ce1 17810:62c54fcc0a35
1286 1286
1287 // Record this event in the histogram. 1287 // Record this event in the histogram.
1288 gather_statistics(reason, action, trap_bc); 1288 gather_statistics(reason, action, trap_bc);
1289 1289
1290 // Ensure that we can record deopt. history: 1290 // Ensure that we can record deopt. history:
1291 bool create_if_missing = ProfileTraps; 1291 // Need MDO to record RTM code generation state.
1292 bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking );
1292 1293
1293 MethodData* trap_mdo = 1294 MethodData* trap_mdo =
1294 get_method_data(thread, trap_method, create_if_missing); 1295 get_method_data(thread, trap_method, create_if_missing);
1295 1296
1296 // Log a message 1297 // Log a message
1487 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity"); 1488 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity");
1488 uint this_trap_count = 0; 1489 uint this_trap_count = 0;
1489 bool maybe_prior_trap = false; 1490 bool maybe_prior_trap = false;
1490 bool maybe_prior_recompile = false; 1491 bool maybe_prior_recompile = false;
1491 pdata = query_update_method_data(trap_mdo, trap_bci, reason, 1492 pdata = query_update_method_data(trap_mdo, trap_bci, reason,
1493 nm->method(),
1492 //outputs: 1494 //outputs:
1493 this_trap_count, 1495 this_trap_count,
1494 maybe_prior_trap, 1496 maybe_prior_trap,
1495 maybe_prior_recompile); 1497 maybe_prior_recompile);
1496 // Because the interpreter also counts null, div0, range, and class 1498 // Because the interpreter also counts null, div0, range, and class
1532 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.) 1534 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.)
1533 make_not_entrant = true; 1535 make_not_entrant = true;
1534 } 1536 }
1535 1537
1536 // Go back to the compiler if there are too many traps in this method. 1538 // Go back to the compiler if there are too many traps in this method.
1537 if (this_trap_count >= (uint)PerMethodTrapLimit) { 1539 if (this_trap_count >= per_method_trap_limit(reason)) {
1538 // If there are too many traps in this method, force a recompile. 1540 // If there are too many traps in this method, force a recompile.
1539 // This will allow the compiler to see the limit overflow, and 1541 // This will allow the compiler to see the limit overflow, and
1540 // take corrective action, if possible. 1542 // take corrective action, if possible.
1541 // (This condition is an unlikely backstop only, because the 1543 // (This condition is an unlikely backstop only, because the
1542 // PerBytecodeTrapLimit is more likely to take effect first, 1544 // PerBytecodeTrapLimit is more likely to take effect first,
1566 int tstate0 = pdata->trap_state(); 1568 int tstate0 = pdata->trap_state();
1567 int tstate1 = trap_state_set_recompiled(tstate0, true); 1569 int tstate1 = trap_state_set_recompiled(tstate0, true);
1568 if (tstate1 != tstate0) 1570 if (tstate1 != tstate0)
1569 pdata->set_trap_state(tstate1); 1571 pdata->set_trap_state(tstate1);
1570 } 1572 }
1573
1574 #if INCLUDE_RTM_OPT
1575 // Restart collecting RTM locking abort statistic if the method
1576 // is recompiled for a reason other than RTM state change.
1577 // Assume that in new recompiled code the statistic could be different,
1578 // for example, due to different inlining.
1579 if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL) &&
1580 UseRTMDeopt && (nm->rtm_state() != ProfileRTM)) {
1581 trap_mdo->atomic_set_rtm_state(ProfileRTM);
1582 }
1583 #endif
1571 } 1584 }
1572 1585
1573 if (inc_recompile_count) { 1586 if (inc_recompile_count) {
1574 trap_mdo->inc_overflow_recompile_count(); 1587 trap_mdo->inc_overflow_recompile_count();
1575 if ((uint)trap_mdo->overflow_recompile_count() > 1588 if ((uint)trap_mdo->overflow_recompile_count() >
1620 1633
1621 ProfileData* 1634 ProfileData*
1622 Deoptimization::query_update_method_data(MethodData* trap_mdo, 1635 Deoptimization::query_update_method_data(MethodData* trap_mdo,
1623 int trap_bci, 1636 int trap_bci,
1624 Deoptimization::DeoptReason reason, 1637 Deoptimization::DeoptReason reason,
1638 Method* compiled_method,
1625 //outputs: 1639 //outputs:
1626 uint& ret_this_trap_count, 1640 uint& ret_this_trap_count,
1627 bool& ret_maybe_prior_trap, 1641 bool& ret_maybe_prior_trap,
1628 bool& ret_maybe_prior_recompile) { 1642 bool& ret_maybe_prior_recompile) {
1629 uint prior_trap_count = trap_mdo->trap_count(reason); 1643 uint prior_trap_count = trap_mdo->trap_count(reason);
1643 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); 1657 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason);
1644 if (per_bc_reason != Reason_none) { 1658 if (per_bc_reason != Reason_none) {
1645 // Find the profile data for this BCI. If there isn't one, 1659 // Find the profile data for this BCI. If there isn't one,
1646 // try to allocate one from the MDO's set of spares. 1660 // try to allocate one from the MDO's set of spares.
1647 // This will let us detect a repeated trap at this point. 1661 // This will let us detect a repeated trap at this point.
1648 pdata = trap_mdo->allocate_bci_to_data(trap_bci); 1662 pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL);
1649 1663
1650 if (pdata != NULL) { 1664 if (pdata != NULL) {
1665 if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) {
1666 if (LogCompilation && xtty != NULL) {
1667 ttyLocker ttyl;
1668 // no more room for speculative traps in this MDO
1669 xtty->elem("speculative_traps_oom");
1670 }
1671 }
1651 // Query the trap state of this profile datum. 1672 // Query the trap state of this profile datum.
1652 int tstate0 = pdata->trap_state(); 1673 int tstate0 = pdata->trap_state();
1653 if (!trap_state_has_reason(tstate0, per_bc_reason)) 1674 if (!trap_state_has_reason(tstate0, per_bc_reason))
1654 maybe_prior_trap = false; 1675 maybe_prior_trap = false;
1655 if (!trap_state_is_recompiled(tstate0)) 1676 if (!trap_state_is_recompiled(tstate0))
1683 ResourceMark rm; 1704 ResourceMark rm;
1684 // Ignored outputs: 1705 // Ignored outputs:
1685 uint ignore_this_trap_count; 1706 uint ignore_this_trap_count;
1686 bool ignore_maybe_prior_trap; 1707 bool ignore_maybe_prior_trap;
1687 bool ignore_maybe_prior_recompile; 1708 bool ignore_maybe_prior_recompile;
1709 assert(!reason_is_speculate(reason), "reason speculate only used by compiler");
1688 query_update_method_data(trap_mdo, trap_bci, 1710 query_update_method_data(trap_mdo, trap_bci,
1689 (DeoptReason)reason, 1711 (DeoptReason)reason,
1712 NULL,
1690 ignore_this_trap_count, 1713 ignore_this_trap_count,
1691 ignore_maybe_prior_trap, 1714 ignore_maybe_prior_trap,
1692 ignore_maybe_prior_recompile); 1715 ignore_maybe_prior_recompile);
1693 } 1716 }
1694 1717
1812 "unhandled", 1835 "unhandled",
1813 "constraint", 1836 "constraint",
1814 "div0_check", 1837 "div0_check",
1815 "age", 1838 "age",
1816 "predicate", 1839 "predicate",
1817 "loop_limit_check" 1840 "loop_limit_check",
1841 "speculate_class_check",
1842 "rtm_state_change"
1818 }; 1843 };
1819 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { 1844 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
1820 // Note: Keep this in sync. with enum DeoptAction. 1845 // Note: Keep this in sync. with enum DeoptAction.
1821 "none", 1846 "none",
1822 "maybe_recompile", 1847 "maybe_recompile",