comparison src/share/vm/runtime/deoptimization.cpp @ 14500:fdad2932c73f

8031752: Failed speculative optimizations should be reattempted when root of compilation is different Summary: support for speculative traps that keep track of the root of the compilation in which a trap occurs. Reviewed-by: kvn, twisti
author roland
date Tue, 25 Feb 2014 18:16:24 +0100
parents 8a9bb7821e28
children d8041d695d19
comparison
equal deleted inserted replaced
14498:04e7587c97dc 14500:fdad2932c73f
1487 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity"); 1487 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity");
1488 uint this_trap_count = 0; 1488 uint this_trap_count = 0;
1489 bool maybe_prior_trap = false; 1489 bool maybe_prior_trap = false;
1490 bool maybe_prior_recompile = false; 1490 bool maybe_prior_recompile = false;
1491 pdata = query_update_method_data(trap_mdo, trap_bci, reason, 1491 pdata = query_update_method_data(trap_mdo, trap_bci, reason,
1492 nm->method(),
1492 //outputs: 1493 //outputs:
1493 this_trap_count, 1494 this_trap_count,
1494 maybe_prior_trap, 1495 maybe_prior_trap,
1495 maybe_prior_recompile); 1496 maybe_prior_recompile);
1496 // Because the interpreter also counts null, div0, range, and class 1497 // Because the interpreter also counts null, div0, range, and class
1532 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.) 1533 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.)
1533 make_not_entrant = true; 1534 make_not_entrant = true;
1534 } 1535 }
1535 1536
1536 // Go back to the compiler if there are too many traps in this method. 1537 // Go back to the compiler if there are too many traps in this method.
1537 if (this_trap_count >= (uint)PerMethodTrapLimit) { 1538 if (this_trap_count >= per_method_trap_limit(reason)) {
1538 // If there are too many traps in this method, force a recompile. 1539 // If there are too many traps in this method, force a recompile.
1539 // This will allow the compiler to see the limit overflow, and 1540 // This will allow the compiler to see the limit overflow, and
1540 // take corrective action, if possible. 1541 // take corrective action, if possible.
1541 // (This condition is an unlikely backstop only, because the 1542 // (This condition is an unlikely backstop only, because the
1542 // PerBytecodeTrapLimit is more likely to take effect first, 1543 // PerBytecodeTrapLimit is more likely to take effect first,
1620 1621
1621 ProfileData* 1622 ProfileData*
1622 Deoptimization::query_update_method_data(MethodData* trap_mdo, 1623 Deoptimization::query_update_method_data(MethodData* trap_mdo,
1623 int trap_bci, 1624 int trap_bci,
1624 Deoptimization::DeoptReason reason, 1625 Deoptimization::DeoptReason reason,
1626 Method* compiled_method,
1625 //outputs: 1627 //outputs:
1626 uint& ret_this_trap_count, 1628 uint& ret_this_trap_count,
1627 bool& ret_maybe_prior_trap, 1629 bool& ret_maybe_prior_trap,
1628 bool& ret_maybe_prior_recompile) { 1630 bool& ret_maybe_prior_recompile) {
1629 uint prior_trap_count = trap_mdo->trap_count(reason); 1631 uint prior_trap_count = trap_mdo->trap_count(reason);
1643 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); 1645 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason);
1644 if (per_bc_reason != Reason_none) { 1646 if (per_bc_reason != Reason_none) {
1645 // Find the profile data for this BCI. If there isn't one, 1647 // Find the profile data for this BCI. If there isn't one,
1646 // try to allocate one from the MDO's set of spares. 1648 // try to allocate one from the MDO's set of spares.
1647 // This will let us detect a repeated trap at this point. 1649 // This will let us detect a repeated trap at this point.
1648 pdata = trap_mdo->allocate_bci_to_data(trap_bci); 1650 pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL);
1649 1651
1650 if (pdata != NULL) { 1652 if (pdata != NULL) {
1653 if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) {
1654 if (LogCompilation && xtty != NULL) {
1655 ttyLocker ttyl;
1656 // no more room for speculative traps in this MDO
1657 xtty->elem("speculative_traps_oom");
1658 }
1659 }
1651 // Query the trap state of this profile datum. 1660 // Query the trap state of this profile datum.
1652 int tstate0 = pdata->trap_state(); 1661 int tstate0 = pdata->trap_state();
1653 if (!trap_state_has_reason(tstate0, per_bc_reason)) 1662 if (!trap_state_has_reason(tstate0, per_bc_reason))
1654 maybe_prior_trap = false; 1663 maybe_prior_trap = false;
1655 if (!trap_state_is_recompiled(tstate0)) 1664 if (!trap_state_is_recompiled(tstate0))
1683 ResourceMark rm; 1692 ResourceMark rm;
1684 // Ignored outputs: 1693 // Ignored outputs:
1685 uint ignore_this_trap_count; 1694 uint ignore_this_trap_count;
1686 bool ignore_maybe_prior_trap; 1695 bool ignore_maybe_prior_trap;
1687 bool ignore_maybe_prior_recompile; 1696 bool ignore_maybe_prior_recompile;
1697 assert(!reason_is_speculate(reason), "reason speculate only used by compiler");
1688 query_update_method_data(trap_mdo, trap_bci, 1698 query_update_method_data(trap_mdo, trap_bci,
1689 (DeoptReason)reason, 1699 (DeoptReason)reason,
1700 NULL,
1690 ignore_this_trap_count, 1701 ignore_this_trap_count,
1691 ignore_maybe_prior_trap, 1702 ignore_maybe_prior_trap,
1692 ignore_maybe_prior_recompile); 1703 ignore_maybe_prior_recompile);
1693 } 1704 }
1694 1705
1812 "unhandled", 1823 "unhandled",
1813 "constraint", 1824 "constraint",
1814 "div0_check", 1825 "div0_check",
1815 "age", 1826 "age",
1816 "predicate", 1827 "predicate",
1817 "loop_limit_check" 1828 "loop_limit_check",
1829 "speculate_class_check"
1818 }; 1830 };
1819 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { 1831 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
1820 // Note: Keep this in sync. with enum DeoptAction. 1832 // Note: Keep this in sync. with enum DeoptAction.
1821 "none", 1833 "none",
1822 "maybe_recompile", 1834 "maybe_recompile",