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