src/cpu/ppc/vm/ppc.ad

Print this page
rev 6114 : 8037821: Account for trampoline stubs when estimating code buffer sizes
Summary: Correct calculation of stubs section size when trampoline stubs are used.
Contributed-by: Lutz.Schmidt@sap.com

*** 889,898 **** --- 889,905 ---- //----------SOURCE BLOCK------------------------------------------------------- // This is a block of C++ code which provides values, functions, and // definitions necessary in the rest of the architecture description. source_hpp %{ + // Header information of the source block. + // Method declarations/definitions which are used outside + // the ad-scope can conveniently be defined here. + // + // To keep related declarations/definitions/uses close together, + // we switch between source %{ }% and source_hpp %{ }% freely as needed. + // Returns true if Node n is followed by a MemBar node that // will do an acquire. If so, this node must not do the acquire // operation. bool followed_by_acquire(const Node *n); %}
*** 1112,1121 **** --- 1119,1162 ---- cbuf.set_insts_end(cbuf.insts_end() + BytesPerInstWord); } //============================================================================= + %} // interrupt source + + source_hpp %{ // Header information of the source block. + + //-------------------------------------------------------------- + //---< Used for optimization in Compile::Shorten_branches >--- + //-------------------------------------------------------------- + + const uint trampoline_stub_size = 6 * BytesPerInstWord; + + class CallStubImpl { + + public: + + static void emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset); + + // Size of call trampoline stub. + // This doesn't need to be accurate to the byte, but it + // must be larger than or equal to the real size of the stub. + static uint size_call_trampoline() { + return trampoline_stub_size; + } + + // number of relocations needed by a call trampoline stub + static uint reloc_call_trampoline() { + return 5; + } + + }; + + %} // end source_hpp + + source %{ + // Emit a trampoline stub for a call to a target which is too far away. // // code sequences: // // call-site:
*** 1123,1135 **** // // Related trampoline stub for this call-site in the stub section: // load the call target from the constant pool // branch via CTR (LR/link still points to the call-site above) ! const uint trampoline_stub_size = 6 * BytesPerInstWord; ! ! void emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset) { // Start the stub. address stub = __ start_a_stub(Compile::MAX_stubs_size/2); if (stub == NULL) { Compile::current()->env()->record_out_of_memory_failure(); return; --- 1164,1174 ---- // // Related trampoline stub for this call-site in the stub section: // load the call target from the constant pool // branch via CTR (LR/link still points to the call-site above) ! void CallStubImpl::emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset) { // Start the stub. address stub = __ start_a_stub(Compile::MAX_stubs_size/2); if (stub == NULL) { Compile::current()->env()->record_out_of_memory_failure(); return;
*** 1168,1190 **** // End the stub. __ end_a_stub(); } - // Size of trampoline stub, this doesn't need to be accurate but it must - // be larger or equal to the real size of the stub. - // Used for optimization in Compile::Shorten_branches. - uint size_call_trampoline() { - return trampoline_stub_size; - } - - // Number of relocation entries needed by trampoline stub. - // Used for optimization in Compile::Shorten_branches. - uint reloc_call_trampoline() { - return 5; - } - //============================================================================= // Emit an inline branch-and-link call and a related trampoline stub. // // code sequences: --- 1207,1216 ----
*** 1219,1229 **** // Put the entry point as a constant into the constant pool. const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); // Emit the trampoline stub which will be related to the branch-and-link below. ! emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); __ relocate(rtype); } // Note: At this point we do not have the address of the trampoline // stub, and the entry point might be too far away for bl, so __ pc() --- 1245,1255 ---- // Put the entry point as a constant into the constant pool. const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); // Emit the trampoline stub which will be related to the branch-and-link below. ! CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); __ relocate(rtype); } // Note: At this point we do not have the address of the trampoline // stub, and the entry point might be too far away for bl, so __ pc()
*** 2021,2041 **** return MachNode::size(ra_); } //============================================================================= ! uint size_exception_handler() { // The exception_handler is a b64_patchable. return MacroAssembler::b64_patchable_size; ! } ! uint size_deopt_handler() { // The deopt_handler is a bl64_patchable. return MacroAssembler::bl64_patchable_size; ! } ! int emit_exception_handler(CodeBuffer &cbuf) { MacroAssembler _masm(&cbuf); address base = __ start_a_stub(size_exception_handler()); if (base == NULL) return 0; // CodeBuffer::expand failed --- 2047,2084 ---- return MachNode::size(ra_); } //============================================================================= ! %} // interrupt source ! ! source_hpp %{ // Header information of the source block. ! ! class HandlerImpl { ! ! public: ! ! static int emit_exception_handler(CodeBuffer &cbuf); ! static int emit_deopt_handler(CodeBuffer& cbuf); ! ! static uint size_exception_handler() { // The exception_handler is a b64_patchable. return MacroAssembler::b64_patchable_size; ! } ! static uint size_deopt_handler() { // The deopt_handler is a bl64_patchable. return MacroAssembler::bl64_patchable_size; ! } ! ! }; ! ! %} // end source_hpp ! ! source %{ ! int HandlerImpl::emit_exception_handler(CodeBuffer &cbuf) { MacroAssembler _masm(&cbuf); address base = __ start_a_stub(size_exception_handler()); if (base == NULL) return 0; // CodeBuffer::expand failed
*** 2048,2058 **** return offset; } // The deopt_handler is like the exception handler, but it calls to // the deoptimization blob instead of jumping to the exception blob. ! int emit_deopt_handler(CodeBuffer& cbuf) { MacroAssembler _masm(&cbuf); address base = __ start_a_stub(size_deopt_handler()); if (base == NULL) return 0; // CodeBuffer::expand failed --- 2091,2101 ---- return offset; } // The deopt_handler is like the exception handler, but it calls to // the deoptimization blob instead of jumping to the exception blob. ! int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf) { MacroAssembler _masm(&cbuf); address base = __ start_a_stub(size_deopt_handler()); if (base == NULL) return 0; // CodeBuffer::expand failed
*** 3436,3446 **** // Put the entry point as a constant into the constant pool. const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); // Emit the trampoline stub which will be related to the branch-and-link below. ! emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); __ relocate(_optimized_virtual ? relocInfo::opt_virtual_call_type : relocInfo::static_call_type); } // The real call. --- 3479,3489 ---- // Put the entry point as a constant into the constant pool. const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); // Emit the trampoline stub which will be related to the branch-and-link below. ! CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); __ relocate(_optimized_virtual ? relocInfo::opt_virtual_call_type : relocInfo::static_call_type); } // The real call.
*** 3479,3489 **** // Put the entry point as a constant into the constant pool. const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); // Emit the trampoline stub which will be related to the branch-and-link below. ! emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); assert(_optimized_virtual, "methodHandle call should be a virtual call"); __ relocate(relocInfo::opt_virtual_call_type); } // The real call. --- 3522,3532 ---- // Put the entry point as a constant into the constant pool. const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); // Emit the trampoline stub which will be related to the branch-and-link below. ! CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); assert(_optimized_virtual, "methodHandle call should be a virtual call"); __ relocate(relocInfo::opt_virtual_call_type); } // The real call.
*** 3529,3539 **** if (!ra_->C->in_scratch_emit_size()) { // Create a call trampoline stub for the given method. const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method; const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_const_toc_offset = __ offset_to_method_toc(entry_point_const); ! emit_trampoline_stub(_masm, entry_point_const_toc_offset, __ offset()); if (ra_->C->env()->failing()) return; // Build relocation at call site with ic position as data. --- 3572,3582 ---- if (!ra_->C->in_scratch_emit_size()) { // Create a call trampoline stub for the given method. const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method; const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none); const int entry_point_const_toc_offset = __ offset_to_method_toc(entry_point_const); ! CallStubImpl::emit_trampoline_stub(_masm, entry_point_const_toc_offset, __ offset()); if (ra_->C->env()->failing()) return; // Build relocation at call site with ic position as data.