Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/deoptimization.cpp @ 17728:b8413a9cbb84
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 | 69dc1be43fce |
children | 606acabe7b5c |
comparison
equal
deleted
inserted
replaced
17727:cfd4aac53239 | 17728:b8413a9cbb84 |
---|---|
1484 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity"); | 1484 assert(trap_mdo == get_method_data(thread, trap_method, false), "sanity"); |
1485 uint this_trap_count = 0; | 1485 uint this_trap_count = 0; |
1486 bool maybe_prior_trap = false; | 1486 bool maybe_prior_trap = false; |
1487 bool maybe_prior_recompile = false; | 1487 bool maybe_prior_recompile = false; |
1488 pdata = query_update_method_data(trap_mdo, trap_bci, reason, | 1488 pdata = query_update_method_data(trap_mdo, trap_bci, reason, |
1489 nm->method(), | |
1489 //outputs: | 1490 //outputs: |
1490 this_trap_count, | 1491 this_trap_count, |
1491 maybe_prior_trap, | 1492 maybe_prior_trap, |
1492 maybe_prior_recompile); | 1493 maybe_prior_recompile); |
1493 // Because the interpreter also counts null, div0, range, and class | 1494 // Because the interpreter also counts null, div0, range, and class |
1529 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.) | 1530 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.) |
1530 make_not_entrant = true; | 1531 make_not_entrant = true; |
1531 } | 1532 } |
1532 | 1533 |
1533 // Go back to the compiler if there are too many traps in this method. | 1534 // Go back to the compiler if there are too many traps in this method. |
1534 if (this_trap_count >= (uint)PerMethodTrapLimit) { | 1535 if (this_trap_count >= per_method_trap_limit(reason)) { |
1535 // If there are too many traps in this method, force a recompile. | 1536 // If there are too many traps in this method, force a recompile. |
1536 // This will allow the compiler to see the limit overflow, and | 1537 // This will allow the compiler to see the limit overflow, and |
1537 // take corrective action, if possible. | 1538 // take corrective action, if possible. |
1538 // (This condition is an unlikely backstop only, because the | 1539 // (This condition is an unlikely backstop only, because the |
1539 // PerBytecodeTrapLimit is more likely to take effect first, | 1540 // PerBytecodeTrapLimit is more likely to take effect first, |
1617 | 1618 |
1618 ProfileData* | 1619 ProfileData* |
1619 Deoptimization::query_update_method_data(MethodData* trap_mdo, | 1620 Deoptimization::query_update_method_data(MethodData* trap_mdo, |
1620 int trap_bci, | 1621 int trap_bci, |
1621 Deoptimization::DeoptReason reason, | 1622 Deoptimization::DeoptReason reason, |
1623 Method* compiled_method, | |
1622 //outputs: | 1624 //outputs: |
1623 uint& ret_this_trap_count, | 1625 uint& ret_this_trap_count, |
1624 bool& ret_maybe_prior_trap, | 1626 bool& ret_maybe_prior_trap, |
1625 bool& ret_maybe_prior_recompile) { | 1627 bool& ret_maybe_prior_recompile) { |
1626 uint prior_trap_count = trap_mdo->trap_count(reason); | 1628 uint prior_trap_count = trap_mdo->trap_count(reason); |
1640 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); | 1642 DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); |
1641 if (per_bc_reason != Reason_none) { | 1643 if (per_bc_reason != Reason_none) { |
1642 // Find the profile data for this BCI. If there isn't one, | 1644 // Find the profile data for this BCI. If there isn't one, |
1643 // try to allocate one from the MDO's set of spares. | 1645 // try to allocate one from the MDO's set of spares. |
1644 // This will let us detect a repeated trap at this point. | 1646 // This will let us detect a repeated trap at this point. |
1645 pdata = trap_mdo->allocate_bci_to_data(trap_bci); | 1647 pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL); |
1646 | 1648 |
1647 if (pdata != NULL) { | 1649 if (pdata != NULL) { |
1650 if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) { | |
1651 if (LogCompilation && xtty != NULL) { | |
1652 ttyLocker ttyl; | |
1653 // no more room for speculative traps in this MDO | |
1654 xtty->elem("speculative_traps_oom"); | |
1655 } | |
1656 } | |
1648 // Query the trap state of this profile datum. | 1657 // Query the trap state of this profile datum. |
1649 int tstate0 = pdata->trap_state(); | 1658 int tstate0 = pdata->trap_state(); |
1650 if (!trap_state_has_reason(tstate0, per_bc_reason)) | 1659 if (!trap_state_has_reason(tstate0, per_bc_reason)) |
1651 maybe_prior_trap = false; | 1660 maybe_prior_trap = false; |
1652 if (!trap_state_is_recompiled(tstate0)) | 1661 if (!trap_state_is_recompiled(tstate0)) |
1680 ResourceMark rm; | 1689 ResourceMark rm; |
1681 // Ignored outputs: | 1690 // Ignored outputs: |
1682 uint ignore_this_trap_count; | 1691 uint ignore_this_trap_count; |
1683 bool ignore_maybe_prior_trap; | 1692 bool ignore_maybe_prior_trap; |
1684 bool ignore_maybe_prior_recompile; | 1693 bool ignore_maybe_prior_recompile; |
1694 assert(!reason_is_speculate(reason), "reason speculate only used by compiler"); | |
1685 query_update_method_data(trap_mdo, trap_bci, | 1695 query_update_method_data(trap_mdo, trap_bci, |
1686 (DeoptReason)reason, | 1696 (DeoptReason)reason, |
1697 NULL, | |
1687 ignore_this_trap_count, | 1698 ignore_this_trap_count, |
1688 ignore_maybe_prior_trap, | 1699 ignore_maybe_prior_trap, |
1689 ignore_maybe_prior_recompile); | 1700 ignore_maybe_prior_recompile); |
1690 } | 1701 } |
1691 | 1702 |
1809 "unhandled", | 1820 "unhandled", |
1810 "constraint", | 1821 "constraint", |
1811 "div0_check", | 1822 "div0_check", |
1812 "age", | 1823 "age", |
1813 "predicate", | 1824 "predicate", |
1814 "loop_limit_check" | 1825 "loop_limit_check", |
1826 "speculate_class_check" | |
1815 }; | 1827 }; |
1816 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { | 1828 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { |
1817 // Note: Keep this in sync. with enum DeoptAction. | 1829 // Note: Keep this in sync. with enum DeoptAction. |
1818 "none", | 1830 "none", |
1819 "maybe_recompile", | 1831 "maybe_recompile", |