1485 }
1486
1487 // Verify that there is sufficient space remaining
1488 cb->insts()->maybe_expand_to_ensure_remaining(MAX_inst_size);
1489 if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
1490 C->record_failure("CodeCache is full");
1491 return;
1492 }
1493
1494 // Save the offset for the listing
1495 #ifndef PRODUCT
1496 if (node_offsets && n->_idx < node_offset_limit)
1497 node_offsets[n->_idx] = cb->insts_size();
1498 #endif
1499
1500 // "Normal" instruction case
1501 DEBUG_ONLY( uint instr_offset = cb->insts_size(); )
1502 n->emit(*cb, _regalloc);
1503 current_offset = cb->insts_size();
1504
1505 #ifdef ASSERT
1506 if (n->size(_regalloc) < (current_offset-instr_offset)) {
1507 n->dump();
1508 assert(false, "wrong size of mach node");
1509 }
1510 #endif
1511 non_safepoints.observe_instruction(n, current_offset);
1512
1513 // mcall is last "call" that can be a safepoint
1514 // record it so we can see if a poll will directly follow it
1515 // in which case we'll need a pad to make the PcDesc sites unique
1516 // see 5010568. This can be slightly inaccurate but conservative
1517 // in the case that return address is not actually at current_offset.
1518 // This is a small price to pay.
1519
1520 if (is_mcall) {
1521 last_call_offset = current_offset;
1522 }
1523
1524 if (n->is_Mach() && n->as_Mach()->avoid_back_to_back(MachNode::AVOID_AFTER)) {
1613 assert(false, "Displacement too large for short jmp");
1614 }
1615 }
1616 }
1617 #endif
1618
1619 #ifndef PRODUCT
1620 // Information on the size of the method, without the extraneous code
1621 Scheduling::increment_method_size(cb->insts_size());
1622 #endif
1623
1624 // ------------------
1625 // Fill in exception table entries.
1626 FillExceptionTables(inct_cnt, call_returns, inct_starts, blk_labels);
1627
1628 // Only java methods have exception handlers and deopt handlers
1629 // class HandlerImpl is platform-specific and defined in the *.ad files.
1630 if (_method) {
1631 // Emit the exception handler code.
1632 _code_offsets.set_value(CodeOffsets::Exceptions, HandlerImpl::emit_exception_handler(*cb));
1633 // Emit the deopt handler code.
1634 _code_offsets.set_value(CodeOffsets::Deopt, HandlerImpl::emit_deopt_handler(*cb));
1635
1636 // Emit the MethodHandle deopt handler code (if required).
1637 if (has_method_handle_invokes()) {
1638 // We can use the same code as for the normal deopt handler, we
1639 // just need a different entry point address.
1640 _code_offsets.set_value(CodeOffsets::DeoptMH, HandlerImpl::emit_deopt_handler(*cb));
1641 }
1642 }
1643
1644 // One last check for failed CodeBuffer::expand:
1645 if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
1646 C->record_failure("CodeCache is full");
1647 return;
1648 }
1649
1650 #ifndef PRODUCT
1651 // Dump the assembly code, including basic-block numbers
1652 if (print_assembly()) {
1653 ttyLocker ttyl; // keep the following output all in one block
1654 if (!VMThread::should_terminate()) { // test this under the tty lock
1655 // This output goes directly to the tty, not the compiler log.
1656 // To enable tools to match it up with the compilation activity,
1657 // be sure to tag this tty output with the compile ID.
|
1485 }
1486
1487 // Verify that there is sufficient space remaining
1488 cb->insts()->maybe_expand_to_ensure_remaining(MAX_inst_size);
1489 if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
1490 C->record_failure("CodeCache is full");
1491 return;
1492 }
1493
1494 // Save the offset for the listing
1495 #ifndef PRODUCT
1496 if (node_offsets && n->_idx < node_offset_limit)
1497 node_offsets[n->_idx] = cb->insts_size();
1498 #endif
1499
1500 // "Normal" instruction case
1501 DEBUG_ONLY( uint instr_offset = cb->insts_size(); )
1502 n->emit(*cb, _regalloc);
1503 current_offset = cb->insts_size();
1504
1505 // Above we only verified that there is enough space in the instruction section.
1506 // However, the instruction may emit stubs that cause code buffer expansion.
1507 // Bail out here if expansion failed due to a lack of code cache space.
1508 if (failing()) {
1509 return;
1510 }
1511
1512 #ifdef ASSERT
1513 if (n->size(_regalloc) < (current_offset-instr_offset)) {
1514 n->dump();
1515 assert(false, "wrong size of mach node");
1516 }
1517 #endif
1518 non_safepoints.observe_instruction(n, current_offset);
1519
1520 // mcall is last "call" that can be a safepoint
1521 // record it so we can see if a poll will directly follow it
1522 // in which case we'll need a pad to make the PcDesc sites unique
1523 // see 5010568. This can be slightly inaccurate but conservative
1524 // in the case that return address is not actually at current_offset.
1525 // This is a small price to pay.
1526
1527 if (is_mcall) {
1528 last_call_offset = current_offset;
1529 }
1530
1531 if (n->is_Mach() && n->as_Mach()->avoid_back_to_back(MachNode::AVOID_AFTER)) {
1620 assert(false, "Displacement too large for short jmp");
1621 }
1622 }
1623 }
1624 #endif
1625
1626 #ifndef PRODUCT
1627 // Information on the size of the method, without the extraneous code
1628 Scheduling::increment_method_size(cb->insts_size());
1629 #endif
1630
1631 // ------------------
1632 // Fill in exception table entries.
1633 FillExceptionTables(inct_cnt, call_returns, inct_starts, blk_labels);
1634
1635 // Only java methods have exception handlers and deopt handlers
1636 // class HandlerImpl is platform-specific and defined in the *.ad files.
1637 if (_method) {
1638 // Emit the exception handler code.
1639 _code_offsets.set_value(CodeOffsets::Exceptions, HandlerImpl::emit_exception_handler(*cb));
1640 if (failing()) {
1641 return; // CodeBuffer::expand failed
1642 }
1643 // Emit the deopt handler code.
1644 _code_offsets.set_value(CodeOffsets::Deopt, HandlerImpl::emit_deopt_handler(*cb));
1645
1646 // Emit the MethodHandle deopt handler code (if required).
1647 if (has_method_handle_invokes() && !failing()) {
1648 // We can use the same code as for the normal deopt handler, we
1649 // just need a different entry point address.
1650 _code_offsets.set_value(CodeOffsets::DeoptMH, HandlerImpl::emit_deopt_handler(*cb));
1651 }
1652 }
1653
1654 // One last check for failed CodeBuffer::expand:
1655 if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
1656 C->record_failure("CodeCache is full");
1657 return;
1658 }
1659
1660 #ifndef PRODUCT
1661 // Dump the assembly code, including basic-block numbers
1662 if (print_assembly()) {
1663 ttyLocker ttyl; // keep the following output all in one block
1664 if (!VMThread::should_terminate()) { // test this under the tty lock
1665 // This output goes directly to the tty, not the compiler log.
1666 // To enable tools to match it up with the compilation activity,
1667 // be sure to tag this tty output with the compile ID.
|