1503
1504 vframe* vf = vframe::new_vframe(&fr, ®_map, thread);
1505 compiledVFrame* cvf = compiledVFrame::cast(vf);
1506
1507 CompiledMethod* nm = cvf->code();
1508
1509 ScopeDesc* trap_scope = cvf->scope();
1510
1511 if (TraceDeoptimization) {
1512 ttyLocker ttyl;
1513 tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT ", method=%s" JVMCI_ONLY(", debug_id=%d"), trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string()
1514 #if INCLUDE_JVMCI
1515 , debug_id
1516 #endif
1517 );
1518 }
1519
1520 methodHandle trap_method = trap_scope->method();
1521 int trap_bci = trap_scope->bci();
1522 #if INCLUDE_JVMCI
1523 long speculation = thread->pending_failed_speculation();
1524 if (nm->is_compiled_by_jvmci()) {
1525 if (speculation != 0) {
1526 oop speculation_log = nm->as_nmethod()->speculation_log();
1527 if (speculation_log != NULL) {
1528 if (TraceDeoptimization || TraceUncollectedSpeculations) {
1529 if (HotSpotSpeculationLog::lastFailed(speculation_log) != 0) {
1530 tty->print_cr("A speculation that was not collected by the compiler is being overwritten");
1531 }
1532 }
1533 if (TraceDeoptimization) {
1534 tty->print_cr("Saving speculation to speculation log");
1535 }
1536 HotSpotSpeculationLog::set_lastFailed(speculation_log, speculation);
1537 } else {
1538 if (TraceDeoptimization) {
1539 tty->print_cr("Speculation present but no speculation log");
1540 }
1541 }
1542 thread->set_pending_failed_speculation(0);
1543 } else {
1544 if (TraceDeoptimization) {
1545 tty->print_cr("No speculation");
1546 }
1547 }
1548 } else {
1549 assert(speculation == 0, "There should not be a speculation for method compiled by non-JVMCI compilers");
1550 }
1551
1552 if (trap_bci == SynchronizationEntryBCI) {
1553 trap_bci = 0;
1554 thread->set_pending_monitorenter(true);
1555 }
1556
1557 if (reason == Deoptimization::Reason_transfer_to_interpreter) {
1558 thread->set_pending_transfer_to_interpreter(true);
1559 }
1560 #endif
1561
1562 Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci);
1563 // Record this event in the histogram.
1564 gather_statistics(reason, action, trap_bc);
1565
1566 // Ensure that we can record deopt. history:
1567 // Need MDO to record RTM code generation state.
1568 bool create_if_missing = ProfileTraps || UseCodeAging RTM_OPT_ONLY( || UseRTMLocking );
1569
1578 profiled_method = trap_method;
1579 #endif
1580
1581 MethodData* trap_mdo =
1582 get_method_data(thread, profiled_method, create_if_missing);
1583
1584 // Log a message
1585 Events::log_deopt_message(thread, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT " method=%s @ %d %s",
1586 trap_reason_name(reason), trap_action_name(action), p2i(fr.pc()),
1587 trap_method->name_and_sig_as_C_string(), trap_bci, nm->compiler_name());
1588
1589 // Print a bunch of diagnostics, if requested.
1590 if (TraceDeoptimization || LogCompilation) {
1591 ResourceMark rm;
1592 ttyLocker ttyl;
1593 char buf[100];
1594 if (xtty != NULL) {
1595 xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT "' %s",
1596 os::current_thread_id(),
1597 format_trap_request(buf, sizeof(buf), trap_request));
1598 nm->log_identity(xtty);
1599 }
1600 Symbol* class_name = NULL;
1601 bool unresolved = false;
1602 if (unloaded_class_index >= 0) {
1603 constantPoolHandle constants (THREAD, trap_method->constants());
1604 if (constants->tag_at(unloaded_class_index).is_unresolved_klass()) {
1605 class_name = constants->klass_name_at(unloaded_class_index);
1606 unresolved = true;
1607 if (xtty != NULL)
1608 xtty->print(" unresolved='1'");
1609 } else if (constants->tag_at(unloaded_class_index).is_symbol()) {
1610 class_name = constants->symbol_at(unloaded_class_index);
1611 }
1612 if (xtty != NULL)
1613 xtty->name(class_name);
1614 }
1615 if (xtty != NULL && trap_mdo != NULL && (int)reason < (int)MethodData::_trap_hist_limit) {
1616 // Dump the relevant MDO state.
1617 // This is the deopt count for the current reason, any previous
1623 int dos = (pdata == NULL)? 0: pdata->trap_state();
1624 if (dos != 0) {
1625 xtty->print(" state='%s'", format_trap_state(buf, sizeof(buf), dos));
1626 if (trap_state_is_recompiled(dos)) {
1627 int recnt2 = trap_mdo->overflow_recompile_count();
1628 if (recnt2 != 0)
1629 xtty->print(" recompiles2='%d'", recnt2);
1630 }
1631 }
1632 }
1633 if (xtty != NULL) {
1634 xtty->stamp();
1635 xtty->end_head();
1636 }
1637 if (TraceDeoptimization) { // make noise on the tty
1638 tty->print("Uncommon trap occurred in");
1639 nm->method()->print_short_name(tty);
1640 tty->print(" compiler=%s compile_id=%d", nm->compiler_name(), nm->compile_id());
1641 #if INCLUDE_JVMCI
1642 if (nm->is_nmethod()) {
1643 char* installed_code_name = nm->as_nmethod()->jvmci_installed_code_name(buf, sizeof(buf));
1644 if (installed_code_name != NULL) {
1645 tty->print(" (JVMCI: installed code name=%s) ", installed_code_name);
1646 }
1647 }
1648 #endif
1649 tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"),
1650 p2i(fr.pc()),
1651 os::current_thread_id(),
1652 trap_reason_name(reason),
1653 trap_action_name(action),
1654 unloaded_class_index
1655 #if INCLUDE_JVMCI
1656 , debug_id
1657 #endif
1658 );
1659 if (class_name != NULL) {
1660 tty->print(unresolved ? " unresolved class: " : " symbol: ");
1661 class_name->print_symbol_on(tty);
1662 }
1663 tty->cr();
|
1503
1504 vframe* vf = vframe::new_vframe(&fr, ®_map, thread);
1505 compiledVFrame* cvf = compiledVFrame::cast(vf);
1506
1507 CompiledMethod* nm = cvf->code();
1508
1509 ScopeDesc* trap_scope = cvf->scope();
1510
1511 if (TraceDeoptimization) {
1512 ttyLocker ttyl;
1513 tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT ", method=%s" JVMCI_ONLY(", debug_id=%d"), trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string()
1514 #if INCLUDE_JVMCI
1515 , debug_id
1516 #endif
1517 );
1518 }
1519
1520 methodHandle trap_method = trap_scope->method();
1521 int trap_bci = trap_scope->bci();
1522 #if INCLUDE_JVMCI
1523 jlong speculation = thread->pending_failed_speculation();
1524 if (nm->is_compiled_by_jvmci() && nm->is_nmethod()) { // Exclude AOTed methods
1525 nm->as_nmethod()->update_speculation(thread);
1526 } else {
1527 assert(speculation == 0, "There should not be a speculation for methods compiled by non-JVMCI compilers");
1528 }
1529
1530 if (trap_bci == SynchronizationEntryBCI) {
1531 trap_bci = 0;
1532 thread->set_pending_monitorenter(true);
1533 }
1534
1535 if (reason == Deoptimization::Reason_transfer_to_interpreter) {
1536 thread->set_pending_transfer_to_interpreter(true);
1537 }
1538 #endif
1539
1540 Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci);
1541 // Record this event in the histogram.
1542 gather_statistics(reason, action, trap_bc);
1543
1544 // Ensure that we can record deopt. history:
1545 // Need MDO to record RTM code generation state.
1546 bool create_if_missing = ProfileTraps || UseCodeAging RTM_OPT_ONLY( || UseRTMLocking );
1547
1556 profiled_method = trap_method;
1557 #endif
1558
1559 MethodData* trap_mdo =
1560 get_method_data(thread, profiled_method, create_if_missing);
1561
1562 // Log a message
1563 Events::log_deopt_message(thread, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT " method=%s @ %d %s",
1564 trap_reason_name(reason), trap_action_name(action), p2i(fr.pc()),
1565 trap_method->name_and_sig_as_C_string(), trap_bci, nm->compiler_name());
1566
1567 // Print a bunch of diagnostics, if requested.
1568 if (TraceDeoptimization || LogCompilation) {
1569 ResourceMark rm;
1570 ttyLocker ttyl;
1571 char buf[100];
1572 if (xtty != NULL) {
1573 xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT "' %s",
1574 os::current_thread_id(),
1575 format_trap_request(buf, sizeof(buf), trap_request));
1576 #if INCLUDE_JVMCI
1577 if (speculation != 0) {
1578 xtty->print(" speculation='" JLONG_FORMAT "'", speculation);
1579 }
1580 #endif
1581 nm->log_identity(xtty);
1582 }
1583 Symbol* class_name = NULL;
1584 bool unresolved = false;
1585 if (unloaded_class_index >= 0) {
1586 constantPoolHandle constants (THREAD, trap_method->constants());
1587 if (constants->tag_at(unloaded_class_index).is_unresolved_klass()) {
1588 class_name = constants->klass_name_at(unloaded_class_index);
1589 unresolved = true;
1590 if (xtty != NULL)
1591 xtty->print(" unresolved='1'");
1592 } else if (constants->tag_at(unloaded_class_index).is_symbol()) {
1593 class_name = constants->symbol_at(unloaded_class_index);
1594 }
1595 if (xtty != NULL)
1596 xtty->name(class_name);
1597 }
1598 if (xtty != NULL && trap_mdo != NULL && (int)reason < (int)MethodData::_trap_hist_limit) {
1599 // Dump the relevant MDO state.
1600 // This is the deopt count for the current reason, any previous
1606 int dos = (pdata == NULL)? 0: pdata->trap_state();
1607 if (dos != 0) {
1608 xtty->print(" state='%s'", format_trap_state(buf, sizeof(buf), dos));
1609 if (trap_state_is_recompiled(dos)) {
1610 int recnt2 = trap_mdo->overflow_recompile_count();
1611 if (recnt2 != 0)
1612 xtty->print(" recompiles2='%d'", recnt2);
1613 }
1614 }
1615 }
1616 if (xtty != NULL) {
1617 xtty->stamp();
1618 xtty->end_head();
1619 }
1620 if (TraceDeoptimization) { // make noise on the tty
1621 tty->print("Uncommon trap occurred in");
1622 nm->method()->print_short_name(tty);
1623 tty->print(" compiler=%s compile_id=%d", nm->compiler_name(), nm->compile_id());
1624 #if INCLUDE_JVMCI
1625 if (nm->is_nmethod()) {
1626 const char* installed_code_name = nm->as_nmethod()->jvmci_name();
1627 if (installed_code_name != NULL) {
1628 tty->print(" (JVMCI: installed code name=%s) ", installed_code_name);
1629 }
1630 }
1631 #endif
1632 tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"),
1633 p2i(fr.pc()),
1634 os::current_thread_id(),
1635 trap_reason_name(reason),
1636 trap_action_name(action),
1637 unloaded_class_index
1638 #if INCLUDE_JVMCI
1639 , debug_id
1640 #endif
1641 );
1642 if (class_name != NULL) {
1643 tty->print(unresolved ? " unresolved class: " : " symbol: ");
1644 class_name->print_symbol_on(tty);
1645 }
1646 tty->cr();
|