comparison src/share/vm/runtime/deoptimization.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents ada0a7729b6f 0bf37f737702
children 2a69cbe850a8
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
80 # include "adfiles/ad_zero.hpp" 80 # include "adfiles/ad_zero.hpp"
81 #endif 81 #endif
82 #ifdef TARGET_ARCH_MODEL_arm 82 #ifdef TARGET_ARCH_MODEL_arm
83 # include "adfiles/ad_arm.hpp" 83 # include "adfiles/ad_arm.hpp"
84 #endif 84 #endif
85 #ifdef TARGET_ARCH_MODEL_ppc 85 #ifdef TARGET_ARCH_MODEL_ppc_32
86 # include "adfiles/ad_ppc.hpp" 86 # include "adfiles/ad_ppc_32.hpp"
87 #endif 87 #endif
88 #endif 88 #ifdef TARGET_ARCH_MODEL_ppc_64
89 # include "adfiles/ad_ppc_64.hpp"
90 #endif
91 #endif // COMPILER2
92
93 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
89 94
90 #ifdef GRAAL 95 #ifdef GRAAL
91 #include "graal/graalRuntime.hpp" 96 #include "graal/graalRuntime.hpp"
92 #include "graal/graalJavaAccess.hpp" 97 #include "graal/graalJavaAccess.hpp"
93 #endif 98 #endif
437 int callee_locals = 0; 442 int callee_locals = 0;
438 for (int index = 0; index < array->frames(); index++ ) { 443 for (int index = 0; index < array->frames(); index++ ) {
439 // frame[number_of_frames - 1 ] = on_stack_size(youngest) 444 // frame[number_of_frames - 1 ] = on_stack_size(youngest)
440 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest)) 445 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest))
441 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest))) 446 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest)))
442 int caller_parms = callee_parameters; 447 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(callee_parameters,
443 if ((index == array->frames() - 1) && caller_was_method_handle) {
444 caller_parms = 0;
445 }
446 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms,
447 callee_parameters,
448 callee_locals, 448 callee_locals,
449 index == 0, 449 index == 0,
450 index == array->frames() - 1,
451 popframe_extra_args); 450 popframe_extra_args);
452 // This pc doesn't have to be perfect just good enough to identify the frame 451 // This pc doesn't have to be perfect just good enough to identify the frame
453 // as interpreted so the skeleton frame will be walkable 452 // as interpreted so the skeleton frame will be walkable
454 // The correct pc will be set when the skeleton frame is completely filled out 453 // The correct pc will be set when the skeleton frame is completely filled out
455 // The final pc we store in the loop is wrong and will be overwritten below 454 // The final pc we store in the loop is wrong and will be overwritten below
1293 void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index) { 1292 void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index) {
1294 EXCEPTION_MARK; 1293 EXCEPTION_MARK;
1295 load_class_by_index(constant_pool, index, THREAD); 1294 load_class_by_index(constant_pool, index, THREAD);
1296 if (HAS_PENDING_EXCEPTION) { 1295 if (HAS_PENDING_EXCEPTION) {
1297 // Exception happened during classloading. We ignore the exception here, since it 1296 // Exception happened during classloading. We ignore the exception here, since it
1298 // is going to be rethrown since the current activation is going to be deoptimzied and 1297 // is going to be rethrown since the current activation is going to be deoptimized and
1299 // the interpreter will re-execute the bytecode. 1298 // the interpreter will re-execute the bytecode.
1300 CLEAR_PENDING_EXCEPTION; 1299 CLEAR_PENDING_EXCEPTION;
1300 // Class loading called java code which may have caused a stack
1301 // overflow. If the exception was thrown right before the return
1302 // to the runtime the stack is no longer guarded. Reguard the
1303 // stack otherwise if we return to the uncommon trap blob and the
1304 // stack bang causes a stack overflow we crash.
1305 assert(THREAD->is_Java_thread(), "only a java thread can be here");
1306 JavaThread* thread = (JavaThread*)THREAD;
1307 bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
1308 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
1309 assert(guard_pages_enabled, "stack banging in uncommon trap blob may cause crash");
1301 } 1310 }
1302 } 1311 }
1303 1312
1304 JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint trap_request)) { 1313 JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint trap_request)) {
1305 HandleMark hm; 1314 HandleMark hm;
1414 1423
1415 // Record this event in the histogram. 1424 // Record this event in the histogram.
1416 gather_statistics(reason, action, trap_bc); 1425 gather_statistics(reason, action, trap_bc);
1417 1426
1418 // Ensure that we can record deopt. history: 1427 // Ensure that we can record deopt. history:
1419 bool create_if_missing = ProfileTraps; 1428 // Need MDO to record RTM code generation state.
1429 bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking );
1420 1430
1421 methodHandle profiled_method; 1431 methodHandle profiled_method;
1422 #ifdef GRAAL 1432 #ifdef GRAAL
1423 if (nm->is_compiled_by_graal()) { 1433 if (nm->is_compiled_by_graal()) {
1424 profiled_method = nm->method(); 1434 profiled_method = nm->method();
1649 bool maybe_prior_recompile = false; 1659 bool maybe_prior_recompile = false;
1650 pdata = query_update_method_data(trap_mdo, trap_bci, reason, true, 1660 pdata = query_update_method_data(trap_mdo, trap_bci, reason, true,
1651 #ifdef GRAAL 1661 #ifdef GRAAL
1652 nm->is_compiled_by_graal() && nm->is_osr_method(), 1662 nm->is_compiled_by_graal() && nm->is_osr_method(),
1653 #endif 1663 #endif
1664 nm->method(),
1654 //outputs: 1665 //outputs:
1655 this_trap_count, 1666 this_trap_count,
1656 maybe_prior_trap, 1667 maybe_prior_trap,
1657 maybe_prior_recompile); 1668 maybe_prior_recompile);
1658 // Because the interpreter also counts null, div0, range, and class 1669 // Because the interpreter also counts null, div0, range, and class
1694 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.) 1705 // (Note that PerMethodRecompilationCutoff is enforced elsewhere.)
1695 make_not_entrant = true; 1706 make_not_entrant = true;
1696 } 1707 }
1697 1708
1698 // Go back to the compiler if there are too many traps in this method. 1709 // Go back to the compiler if there are too many traps in this method.
1699 if (this_trap_count >= (uint)PerMethodTrapLimit) { 1710 if (this_trap_count >= per_method_trap_limit(reason)) {
1700 // If there are too many traps in this method, force a recompile. 1711 // If there are too many traps in this method, force a recompile.
1701 // This will allow the compiler to see the limit overflow, and 1712 // This will allow the compiler to see the limit overflow, and
1702 // take corrective action, if possible. 1713 // take corrective action, if possible.
1703 // (This condition is an unlikely backstop only, because the 1714 // (This condition is an unlikely backstop only, because the
1704 // PerBytecodeTrapLimit is more likely to take effect first, 1715 // PerBytecodeTrapLimit is more likely to take effect first,
1728 int tstate0 = pdata->trap_state(); 1739 int tstate0 = pdata->trap_state();
1729 int tstate1 = trap_state_set_recompiled(tstate0, true); 1740 int tstate1 = trap_state_set_recompiled(tstate0, true);
1730 if (tstate1 != tstate0) 1741 if (tstate1 != tstate0)
1731 pdata->set_trap_state(tstate1); 1742 pdata->set_trap_state(tstate1);
1732 } 1743 }
1744
1745 #if INCLUDE_RTM_OPT
1746 // Restart collecting RTM locking abort statistic if the method
1747 // is recompiled for a reason other than RTM state change.
1748 // Assume that in new recompiled code the statistic could be different,
1749 // for example, due to different inlining.
1750 if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL) &&
1751 UseRTMDeopt && (nm->rtm_state() != ProfileRTM)) {
1752 trap_mdo->atomic_set_rtm_state(ProfileRTM);
1753 }
1754 #endif
1733 } 1755 }
1734 1756
1735 if (inc_recompile_count) { 1757 if (inc_recompile_count) {
1736 trap_mdo->inc_overflow_recompile_count(); 1758 trap_mdo->inc_overflow_recompile_count();
1737 if ((uint)trap_mdo->overflow_recompile_count() > 1759 if ((uint)trap_mdo->overflow_recompile_count() >
1786 Deoptimization::DeoptReason reason, 1808 Deoptimization::DeoptReason reason,
1787 bool update_total_trap_count, 1809 bool update_total_trap_count,
1788 #ifdef GRAAL 1810 #ifdef GRAAL
1789 bool is_osr, 1811 bool is_osr,
1790 #endif 1812 #endif
1813 Method* compiled_method,
1791 //outputs: 1814 //outputs:
1792 uint& ret_this_trap_count, 1815 uint& ret_this_trap_count,
1793 bool& ret_maybe_prior_trap, 1816 bool& ret_maybe_prior_trap,
1794 bool& ret_maybe_prior_recompile) { 1817 bool& ret_maybe_prior_recompile) {
1795 bool maybe_prior_trap = false; 1818 bool maybe_prior_trap = false;
1821 assert(per_bc_reason != Reason_none || update_total_trap_count, "must be"); 1844 assert(per_bc_reason != Reason_none || update_total_trap_count, "must be");
1822 if (per_bc_reason != Reason_none) { 1845 if (per_bc_reason != Reason_none) {
1823 // Find the profile data for this BCI. If there isn't one, 1846 // Find the profile data for this BCI. If there isn't one,
1824 // try to allocate one from the MDO's set of spares. 1847 // try to allocate one from the MDO's set of spares.
1825 // This will let us detect a repeated trap at this point. 1848 // This will let us detect a repeated trap at this point.
1826 pdata = trap_mdo->allocate_bci_to_data(trap_bci); 1849 pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL);
1827 1850
1828 if (pdata != NULL) { 1851 if (pdata != NULL) {
1852 if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) {
1853 if (LogCompilation && xtty != NULL) {
1854 ttyLocker ttyl;
1855 // no more room for speculative traps in this MDO
1856 xtty->elem("speculative_traps_oom");
1857 }
1858 }
1829 // Query the trap state of this profile datum. 1859 // Query the trap state of this profile datum.
1830 int tstate0 = pdata->trap_state(); 1860 int tstate0 = pdata->trap_state();
1831 if (!trap_state_has_reason(tstate0, per_bc_reason)) 1861 if (!trap_state_has_reason(tstate0, per_bc_reason))
1832 maybe_prior_trap = false; 1862 maybe_prior_trap = false;
1833 if (!trap_state_is_recompiled(tstate0)) 1863 if (!trap_state_is_recompiled(tstate0))
1861 ResourceMark rm; 1891 ResourceMark rm;
1862 // Ignored outputs: 1892 // Ignored outputs:
1863 uint ignore_this_trap_count; 1893 uint ignore_this_trap_count;
1864 bool ignore_maybe_prior_trap; 1894 bool ignore_maybe_prior_trap;
1865 bool ignore_maybe_prior_recompile; 1895 bool ignore_maybe_prior_recompile;
1896 assert(!reason_is_speculate(reason), "reason speculate only used by compiler");
1866 // Graal uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts 1897 // Graal uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts
1867 bool update_total_counts = GRAAL_ONLY(false) NOT_GRAAL(true); 1898 bool update_total_counts = GRAAL_ONLY(false) NOT_GRAAL(true);
1868 query_update_method_data(trap_mdo, trap_bci, 1899 query_update_method_data(trap_mdo, trap_bci,
1869 (DeoptReason)reason, 1900 (DeoptReason)reason,
1870 update_total_counts, 1901 update_total_counts,
1871 #ifdef GRAAL 1902 #ifdef GRAAL
1872 false, 1903 false,
1873 #endif 1904 #endif
1905 NULL,
1874 ignore_this_trap_count, 1906 ignore_this_trap_count,
1875 ignore_maybe_prior_trap, 1907 ignore_maybe_prior_trap,
1876 ignore_maybe_prior_recompile); 1908 ignore_maybe_prior_recompile);
1877 } 1909 }
1878 1910
1999 "constraint", 2031 "constraint",
2000 "div0_check", 2032 "div0_check",
2001 "age" GRAAL_ONLY("_or_jsr_mismatch"), 2033 "age" GRAAL_ONLY("_or_jsr_mismatch"),
2002 "predicate", 2034 "predicate",
2003 "loop_limit_check", 2035 "loop_limit_check",
2036 "speculate_class_check",
2037 "rtm_state_change"
2004 #ifdef GRAAL 2038 #ifdef GRAAL
2005 "aliasing", 2039 "aliasing",
2006 "transfer_to_interpreter", 2040 "transfer_to_interpreter",
2007 #endif 2041 #endif
2008 }; 2042 };