< prev index next >

src/share/vm/opto/output.cpp

Print this page
rev 8802 : G1 performance improvements: card batching, joining, sorting, prefetching and write barrier fence elision and simplification based on a global syncrhonization using handshakes piggybacking on thread-local safepoints.
rev 8803 : Implementation improvements to pass JPRT


  25 #include "precompiled.hpp"
  26 #include "asm/assembler.inline.hpp"
  27 #include "code/compiledIC.hpp"
  28 #include "code/debugInfo.hpp"
  29 #include "code/debugInfoRec.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "compiler/oopMap.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "opto/ad.hpp"
  34 #include "opto/callnode.hpp"
  35 #include "opto/cfgnode.hpp"
  36 #include "opto/locknode.hpp"
  37 #include "opto/machnode.hpp"
  38 #include "opto/optoreg.hpp"
  39 #include "opto/output.hpp"
  40 #include "opto/regalloc.hpp"
  41 #include "opto/runtime.hpp"
  42 #include "opto/subnode.hpp"
  43 #include "opto/type.hpp"
  44 #include "runtime/handles.inline.hpp"

  45 #include "utilities/xmlstream.hpp"
  46 
  47 #ifndef PRODUCT
  48 #define DEBUG_ARG(x) , x
  49 #else
  50 #define DEBUG_ARG(x)
  51 #endif
  52 
  53 // Convert Nodes to instruction bits and pass off to the VM
  54 void Compile::Output() {
  55   // RootNode goes
  56   assert( _cfg->get_root_block()->number_of_nodes() == 0, "" );
  57 
  58   // The number of new nodes (mostly MachNop) is proportional to
  59   // the number of java calls and inner loops which are aligned.
  60   if ( C->check_node_count((NodeLimitFudgeFactor + C->java_calls()*3 +
  61                             C->inner_loops()*(OptoLoopAlignment-1)),
  62                            "out of nodes before code generation" ) ) {
  63     return;
  64   }


1126 
1127     // Calculate the offsets of the constants and the size of the
1128     // constant table (including the padding to the next section).
1129     constant_table().calculate_offsets_and_size();
1130     const_req = constant_table().size() + add_size;
1131   }
1132 
1133   // Initialize the space for the BufferBlob used to find and verify
1134   // instruction size in MachNode::emit_size()
1135   init_scratch_buffer_blob(const_req);
1136   if (failing())  return NULL; // Out of memory
1137 
1138   // Pre-compute the length of blocks and replace
1139   // long branches with short if machine supports it.
1140   shorten_branches(blk_starts, code_req, locs_req, stub_req);
1141 
1142   // nmethod and CodeBuffer count stubs & constants as part of method's code.
1143   // class HandlerImpl is platform-specific and defined in the *.ad files.
1144   int exception_handler_req = HandlerImpl::size_exception_handler() + MAX_stubs_size; // add marginal slop for handler
1145   int deopt_handler_req     = HandlerImpl::size_deopt_handler()     + MAX_stubs_size; // add marginal slop for handler
1146   stub_req += MAX_stubs_size;   // ensure per-stub margin
1147   code_req += MAX_inst_size;    // ensure per-instruction margin
1148 
1149   if (StressCodeBuffers)
1150     code_req = const_req = stub_req = exception_handler_req = deopt_handler_req = 0x10;  // force expansion
1151 
1152   int total_req =
1153     const_req +
1154     code_req +
1155     pad_req +
1156     stub_req +
1157     exception_handler_req +
1158     deopt_handler_req;               // deopt handler
1159 
1160   if (has_method_handle_invokes())
1161     total_req += deopt_handler_req;  // deopt MH handler
1162 
1163   CodeBuffer* cb = code_buffer();
1164   cb->initialize(total_req, locs_req);
1165 
1166   // Have we run out of code space?


1617     if (jmp_target[i] != 0) {
1618       int br_size = jmp_size[i];
1619       int offset = blk_starts[jmp_target[i]]-(blk_starts[i] + jmp_offset[i]);
1620       if (!_matcher->is_short_branch_offset(jmp_rule[i], br_size, offset)) {
1621         tty->print_cr("target (%d) - jmp_offset(%d) = offset (%d), jump_size(%d), jmp_block B%d, target_block B%d", blk_starts[jmp_target[i]], blk_starts[i] + jmp_offset[i], offset, br_size, i, jmp_target[i]);
1622         assert(false, "Displacement too large for short jmp");
1623       }
1624     }
1625   }
1626 #endif
1627 
1628 #ifndef PRODUCT
1629   // Information on the size of the method, without the extraneous code
1630   Scheduling::increment_method_size(cb->insts_size());
1631 #endif
1632 
1633   // ------------------
1634   // Fill in exception table entries.
1635   FillExceptionTables(inct_cnt, call_returns, inct_starts, blk_labels);
1636 



1637   // Only java methods have exception handlers and deopt handlers
1638   // class HandlerImpl is platform-specific and defined in the *.ad files.
1639   if (_method) {
1640     // Emit the exception handler code.
1641     _code_offsets.set_value(CodeOffsets::Exceptions, HandlerImpl::emit_exception_handler(*cb));
1642     if (failing()) {
1643       return; // CodeBuffer::expand failed
1644     }
1645     // Emit the deopt handler code.
1646     _code_offsets.set_value(CodeOffsets::Deopt, HandlerImpl::emit_deopt_handler(*cb));
1647 
1648     // Emit the MethodHandle deopt handler code (if required).
1649     if (has_method_handle_invokes() && !failing()) {
1650       // We can use the same code as for the normal deopt handler, we
1651       // just need a different entry point address.
1652       _code_offsets.set_value(CodeOffsets::DeoptMH, HandlerImpl::emit_deopt_handler(*cb));
1653     }
1654   }
1655 
1656   // One last check for failed CodeBuffer::expand:




  25 #include "precompiled.hpp"
  26 #include "asm/assembler.inline.hpp"
  27 #include "code/compiledIC.hpp"
  28 #include "code/debugInfo.hpp"
  29 #include "code/debugInfoRec.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "compiler/oopMap.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "opto/ad.hpp"
  34 #include "opto/callnode.hpp"
  35 #include "opto/cfgnode.hpp"
  36 #include "opto/locknode.hpp"
  37 #include "opto/machnode.hpp"
  38 #include "opto/optoreg.hpp"
  39 #include "opto/output.hpp"
  40 #include "opto/regalloc.hpp"
  41 #include "opto/runtime.hpp"
  42 #include "opto/subnode.hpp"
  43 #include "opto/type.hpp"
  44 #include "runtime/handles.inline.hpp"
  45 #include "runtime/sharedRuntime.hpp"
  46 #include "utilities/xmlstream.hpp"
  47 
  48 #ifndef PRODUCT
  49 #define DEBUG_ARG(x) , x
  50 #else
  51 #define DEBUG_ARG(x)
  52 #endif
  53 
  54 // Convert Nodes to instruction bits and pass off to the VM
  55 void Compile::Output() {
  56   // RootNode goes
  57   assert( _cfg->get_root_block()->number_of_nodes() == 0, "" );
  58 
  59   // The number of new nodes (mostly MachNop) is proportional to
  60   // the number of java calls and inner loops which are aligned.
  61   if ( C->check_node_count((NodeLimitFudgeFactor + C->java_calls()*3 +
  62                             C->inner_loops()*(OptoLoopAlignment-1)),
  63                            "out of nodes before code generation" ) ) {
  64     return;
  65   }


1127 
1128     // Calculate the offsets of the constants and the size of the
1129     // constant table (including the padding to the next section).
1130     constant_table().calculate_offsets_and_size();
1131     const_req = constant_table().size() + add_size;
1132   }
1133 
1134   // Initialize the space for the BufferBlob used to find and verify
1135   // instruction size in MachNode::emit_size()
1136   init_scratch_buffer_blob(const_req);
1137   if (failing())  return NULL; // Out of memory
1138 
1139   // Pre-compute the length of blocks and replace
1140   // long branches with short if machine supports it.
1141   shorten_branches(blk_starts, code_req, locs_req, stub_req);
1142 
1143   // nmethod and CodeBuffer count stubs & constants as part of method's code.
1144   // class HandlerImpl is platform-specific and defined in the *.ad files.
1145   int exception_handler_req = HandlerImpl::size_exception_handler() + MAX_stubs_size; // add marginal slop for handler
1146   int deopt_handler_req     = HandlerImpl::size_deopt_handler()     + MAX_stubs_size; // add marginal slop for handler
1147   code_req += tls_table()->stub_size();   // ensure per-stub margin
1148   code_req += MAX_inst_size;    // ensure per-instruction margin
1149 
1150   if (StressCodeBuffers)
1151     code_req = const_req = stub_req = exception_handler_req = deopt_handler_req = 0x10;  // force expansion
1152 
1153   int total_req =
1154     const_req +
1155     code_req +
1156     pad_req +
1157     stub_req +
1158     exception_handler_req +
1159     deopt_handler_req;               // deopt handler
1160 
1161   if (has_method_handle_invokes())
1162     total_req += deopt_handler_req;  // deopt MH handler
1163 
1164   CodeBuffer* cb = code_buffer();
1165   cb->initialize(total_req, locs_req);
1166 
1167   // Have we run out of code space?


1618     if (jmp_target[i] != 0) {
1619       int br_size = jmp_size[i];
1620       int offset = blk_starts[jmp_target[i]]-(blk_starts[i] + jmp_offset[i]);
1621       if (!_matcher->is_short_branch_offset(jmp_rule[i], br_size, offset)) {
1622         tty->print_cr("target (%d) - jmp_offset(%d) = offset (%d), jump_size(%d), jmp_block B%d, target_block B%d", blk_starts[jmp_target[i]], blk_starts[i] + jmp_offset[i], offset, br_size, i, jmp_target[i]);
1623         assert(false, "Displacement too large for short jmp");
1624       }
1625     }
1626   }
1627 #endif
1628 
1629 #ifndef PRODUCT
1630   // Information on the size of the method, without the extraneous code
1631   Scheduling::increment_method_size(cb->insts_size());
1632 #endif
1633 
1634   // ------------------
1635   // Fill in exception table entries.
1636   FillExceptionTables(inct_cnt, call_returns, inct_starts, blk_labels);
1637 
1638   // Fill in stubs for calling the runtime from safepoint polls.
1639   tls_table()->emit(*cb, SharedRuntime::is_wide_vector(max_vector_size()));
1640 
1641   // Only java methods have exception handlers and deopt handlers
1642   // class HandlerImpl is platform-specific and defined in the *.ad files.
1643   if (_method) {
1644     // Emit the exception handler code.
1645     _code_offsets.set_value(CodeOffsets::Exceptions, HandlerImpl::emit_exception_handler(*cb));
1646     if (failing()) {
1647       return; // CodeBuffer::expand failed
1648     }
1649     // Emit the deopt handler code.
1650     _code_offsets.set_value(CodeOffsets::Deopt, HandlerImpl::emit_deopt_handler(*cb));
1651 
1652     // Emit the MethodHandle deopt handler code (if required).
1653     if (has_method_handle_invokes() && !failing()) {
1654       // We can use the same code as for the normal deopt handler, we
1655       // just need a different entry point address.
1656       _code_offsets.set_value(CodeOffsets::DeoptMH, HandlerImpl::emit_deopt_handler(*cb));
1657     }
1658   }
1659 
1660   // One last check for failed CodeBuffer::expand:


< prev index next >