1268 revoke_biases_of_monitors(thread, fr, ®_map);
1269
1270 DeoptReason reason = trap_request_reason(trap_request);
1271 DeoptAction action = trap_request_action(trap_request);
1272 jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
1273
1274 vframe* vf = vframe::new_vframe(&fr, ®_map, thread);
1275 compiledVFrame* cvf = compiledVFrame::cast(vf);
1276
1277 nmethod* nm = cvf->code();
1278
1279 ScopeDesc* trap_scope = cvf->scope();
1280 methodHandle trap_method = trap_scope->method();
1281 int trap_bci = trap_scope->bci();
1282 Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci);
1283
1284 // Record this event in the histogram.
1285 gather_statistics(reason, action, trap_bc);
1286
1287 // Ensure that we can record deopt. history:
1288 bool create_if_missing = ProfileTraps;
1289
1290 MethodData* trap_mdo =
1291 get_method_data(thread, trap_method, create_if_missing);
1292
1293 // Log a message
1294 Events::log_deopt_message(thread, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT " method=%s @ %d",
1295 trap_reason_name(reason), trap_action_name(action), fr.pc(),
1296 trap_method->name_and_sig_as_C_string(), trap_bci);
1297
1298 // Print a bunch of diagnostics, if requested.
1299 if (TraceDeoptimization || LogCompilation) {
1300 ResourceMark rm;
1301 ttyLocker ttyl;
1302 char buf[100];
1303 if (xtty != NULL) {
1304 xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT"' %s",
1305 os::current_thread_id(),
1306 format_trap_request(buf, sizeof(buf), trap_request));
1307 nm->log_identity(xtty);
1308 }
1549 reprofile = true;
1550 }
1551
1552 }
1553
1554 // Take requested actions on the method:
1555
1556 // Recompile
1557 if (make_not_entrant) {
1558 if (!nm->make_not_entrant()) {
1559 return; // the call did not change nmethod's state
1560 }
1561
1562 if (pdata != NULL) {
1563 // Record the recompilation event, if any.
1564 int tstate0 = pdata->trap_state();
1565 int tstate1 = trap_state_set_recompiled(tstate0, true);
1566 if (tstate1 != tstate0)
1567 pdata->set_trap_state(tstate1);
1568 }
1569 }
1570
1571 if (inc_recompile_count) {
1572 trap_mdo->inc_overflow_recompile_count();
1573 if ((uint)trap_mdo->overflow_recompile_count() >
1574 (uint)PerBytecodeRecompilationCutoff) {
1575 // Give up on the method containing the bad BCI.
1576 if (trap_method() == nm->method()) {
1577 make_not_compilable = true;
1578 } else {
1579 trap_method->set_not_compilable(CompLevel_full_optimization, true, "overflow_recompile_count > PerBytecodeRecompilationCutoff");
1580 // But give grace to the enclosing nm->method().
1581 }
1582 }
1583 }
1584
1585 // Reprofile
1586 if (reprofile) {
1587 CompilationPolicy::policy()->reprofile(trap_scope, nm->is_osr_method());
1588 }
1806 = Deoptimization::Action_reinterpret;
1807 const char* Deoptimization::_trap_reason_name[Reason_LIMIT] = {
1808 // Note: Keep this in sync. with enum DeoptReason.
1809 "none",
1810 "null_check",
1811 "null_assert",
1812 "range_check",
1813 "class_check",
1814 "array_check",
1815 "intrinsic",
1816 "bimorphic",
1817 "unloaded",
1818 "uninitialized",
1819 "unreached",
1820 "unhandled",
1821 "constraint",
1822 "div0_check",
1823 "age",
1824 "predicate",
1825 "loop_limit_check",
1826 "speculate_class_check"
1827 };
1828 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
1829 // Note: Keep this in sync. with enum DeoptAction.
1830 "none",
1831 "maybe_recompile",
1832 "reinterpret",
1833 "make_not_entrant",
1834 "make_not_compilable"
1835 };
1836
1837 const char* Deoptimization::trap_reason_name(int reason) {
1838 if (reason == Reason_many) return "many";
1839 if ((uint)reason < Reason_LIMIT)
1840 return _trap_reason_name[reason];
1841 static char buf[20];
1842 sprintf(buf, "reason%d", reason);
1843 return buf;
1844 }
1845 const char* Deoptimization::trap_action_name(int action) {
1846 if ((uint)action < Action_LIMIT)
|
1268 revoke_biases_of_monitors(thread, fr, ®_map);
1269
1270 DeoptReason reason = trap_request_reason(trap_request);
1271 DeoptAction action = trap_request_action(trap_request);
1272 jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
1273
1274 vframe* vf = vframe::new_vframe(&fr, ®_map, thread);
1275 compiledVFrame* cvf = compiledVFrame::cast(vf);
1276
1277 nmethod* nm = cvf->code();
1278
1279 ScopeDesc* trap_scope = cvf->scope();
1280 methodHandle trap_method = trap_scope->method();
1281 int trap_bci = trap_scope->bci();
1282 Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci);
1283
1284 // Record this event in the histogram.
1285 gather_statistics(reason, action, trap_bc);
1286
1287 // Ensure that we can record deopt. history:
1288 // Need MDO to record RTM code generation state.
1289 bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking );
1290
1291 MethodData* trap_mdo =
1292 get_method_data(thread, trap_method, create_if_missing);
1293
1294 // Log a message
1295 Events::log_deopt_message(thread, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT " method=%s @ %d",
1296 trap_reason_name(reason), trap_action_name(action), fr.pc(),
1297 trap_method->name_and_sig_as_C_string(), trap_bci);
1298
1299 // Print a bunch of diagnostics, if requested.
1300 if (TraceDeoptimization || LogCompilation) {
1301 ResourceMark rm;
1302 ttyLocker ttyl;
1303 char buf[100];
1304 if (xtty != NULL) {
1305 xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT"' %s",
1306 os::current_thread_id(),
1307 format_trap_request(buf, sizeof(buf), trap_request));
1308 nm->log_identity(xtty);
1309 }
1550 reprofile = true;
1551 }
1552
1553 }
1554
1555 // Take requested actions on the method:
1556
1557 // Recompile
1558 if (make_not_entrant) {
1559 if (!nm->make_not_entrant()) {
1560 return; // the call did not change nmethod's state
1561 }
1562
1563 if (pdata != NULL) {
1564 // Record the recompilation event, if any.
1565 int tstate0 = pdata->trap_state();
1566 int tstate1 = trap_state_set_recompiled(tstate0, true);
1567 if (tstate1 != tstate0)
1568 pdata->set_trap_state(tstate1);
1569 }
1570
1571 #if INCLUDE_RTM_OPT
1572 // Restart collecting RTM locking abort statistic if the method
1573 // is recompiled for a reason other than RTM state change.
1574 // Assume that in new recompiled code the statistic could be different,
1575 // for example, due to different inlining.
1576 if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL) &&
1577 UseRTMDeopt && (nm->rtm_state() != ProfileRTM)) {
1578 trap_mdo->atomic_set_rtm_state(ProfileRTM);
1579 }
1580 #endif
1581 }
1582
1583 if (inc_recompile_count) {
1584 trap_mdo->inc_overflow_recompile_count();
1585 if ((uint)trap_mdo->overflow_recompile_count() >
1586 (uint)PerBytecodeRecompilationCutoff) {
1587 // Give up on the method containing the bad BCI.
1588 if (trap_method() == nm->method()) {
1589 make_not_compilable = true;
1590 } else {
1591 trap_method->set_not_compilable(CompLevel_full_optimization, true, "overflow_recompile_count > PerBytecodeRecompilationCutoff");
1592 // But give grace to the enclosing nm->method().
1593 }
1594 }
1595 }
1596
1597 // Reprofile
1598 if (reprofile) {
1599 CompilationPolicy::policy()->reprofile(trap_scope, nm->is_osr_method());
1600 }
1818 = Deoptimization::Action_reinterpret;
1819 const char* Deoptimization::_trap_reason_name[Reason_LIMIT] = {
1820 // Note: Keep this in sync. with enum DeoptReason.
1821 "none",
1822 "null_check",
1823 "null_assert",
1824 "range_check",
1825 "class_check",
1826 "array_check",
1827 "intrinsic",
1828 "bimorphic",
1829 "unloaded",
1830 "uninitialized",
1831 "unreached",
1832 "unhandled",
1833 "constraint",
1834 "div0_check",
1835 "age",
1836 "predicate",
1837 "loop_limit_check",
1838 "speculate_class_check",
1839 "rtm_state_change"
1840 };
1841 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
1842 // Note: Keep this in sync. with enum DeoptAction.
1843 "none",
1844 "maybe_recompile",
1845 "reinterpret",
1846 "make_not_entrant",
1847 "make_not_compilable"
1848 };
1849
1850 const char* Deoptimization::trap_reason_name(int reason) {
1851 if (reason == Reason_many) return "many";
1852 if ((uint)reason < Reason_LIMIT)
1853 return _trap_reason_name[reason];
1854 static char buf[20];
1855 sprintf(buf, "reason%d", reason);
1856 return buf;
1857 }
1858 const char* Deoptimization::trap_action_name(int action) {
1859 if ((uint)action < Action_LIMIT)
|