889 |
889 |
890 //----------SOURCE BLOCK------------------------------------------------------- |
890 //----------SOURCE BLOCK------------------------------------------------------- |
891 // This is a block of C++ code which provides values, functions, and |
891 // This is a block of C++ code which provides values, functions, and |
892 // definitions necessary in the rest of the architecture description. |
892 // definitions necessary in the rest of the architecture description. |
893 source_hpp %{ |
893 source_hpp %{ |
|
894 // Header information of the source block. |
|
895 // Method declarations/definitions which are used outside |
|
896 // the ad-scope can conveniently be defined here. |
|
897 // |
|
898 // To keep related declarations/definitions/uses close together, |
|
899 // we switch between source %{ }% and source_hpp %{ }% freely as needed. |
|
900 |
894 // Returns true if Node n is followed by a MemBar node that |
901 // Returns true if Node n is followed by a MemBar node that |
895 // will do an acquire. If so, this node must not do the acquire |
902 // will do an acquire. If so, this node must not do the acquire |
896 // operation. |
903 // operation. |
897 bool followed_by_acquire(const Node *n); |
904 bool followed_by_acquire(const Node *n); |
898 %} |
905 %} |
1112 cbuf.set_insts_end(cbuf.insts_end() + BytesPerInstWord); |
1119 cbuf.set_insts_end(cbuf.insts_end() + BytesPerInstWord); |
1113 } |
1120 } |
1114 |
1121 |
1115 //============================================================================= |
1122 //============================================================================= |
1116 |
1123 |
|
1124 %} // interrupt source |
|
1125 |
|
1126 source_hpp %{ // Header information of the source block. |
|
1127 |
|
1128 //-------------------------------------------------------------- |
|
1129 //---< Used for optimization in Compile::Shorten_branches >--- |
|
1130 //-------------------------------------------------------------- |
|
1131 |
|
1132 const uint trampoline_stub_size = 6 * BytesPerInstWord; |
|
1133 |
|
1134 class CallStubImpl { |
|
1135 |
|
1136 public: |
|
1137 |
|
1138 static void emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset); |
|
1139 |
|
1140 // Size of call trampoline stub. |
|
1141 // This doesn't need to be accurate to the byte, but it |
|
1142 // must be larger than or equal to the real size of the stub. |
|
1143 static uint size_call_trampoline() { |
|
1144 return trampoline_stub_size; |
|
1145 } |
|
1146 |
|
1147 // number of relocations needed by a call trampoline stub |
|
1148 static uint reloc_call_trampoline() { |
|
1149 return 5; |
|
1150 } |
|
1151 |
|
1152 }; |
|
1153 |
|
1154 %} // end source_hpp |
|
1155 |
|
1156 source %{ |
|
1157 |
1117 // Emit a trampoline stub for a call to a target which is too far away. |
1158 // Emit a trampoline stub for a call to a target which is too far away. |
1118 // |
1159 // |
1119 // code sequences: |
1160 // code sequences: |
1120 // |
1161 // |
1121 // call-site: |
1162 // call-site: |
1123 // |
1164 // |
1124 // Related trampoline stub for this call-site in the stub section: |
1165 // Related trampoline stub for this call-site in the stub section: |
1125 // load the call target from the constant pool |
1166 // load the call target from the constant pool |
1126 // branch via CTR (LR/link still points to the call-site above) |
1167 // branch via CTR (LR/link still points to the call-site above) |
1127 |
1168 |
1128 const uint trampoline_stub_size = 6 * BytesPerInstWord; |
1169 void CallStubImpl::emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset) { |
1129 |
|
1130 void emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset) { |
|
1131 // Start the stub. |
1170 // Start the stub. |
1132 address stub = __ start_a_stub(Compile::MAX_stubs_size/2); |
1171 address stub = __ start_a_stub(Compile::MAX_stubs_size/2); |
1133 if (stub == NULL) { |
1172 if (stub == NULL) { |
1134 Compile::current()->env()->record_out_of_memory_failure(); |
1173 Compile::current()->env()->record_out_of_memory_failure(); |
1135 return; |
1174 return; |
1166 assert((uint)(__ offset() - stub_start_offset) <= trampoline_stub_size, "should be good size"); |
1205 assert((uint)(__ offset() - stub_start_offset) <= trampoline_stub_size, "should be good size"); |
1167 assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline"); |
1206 assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline"); |
1168 |
1207 |
1169 // End the stub. |
1208 // End the stub. |
1170 __ end_a_stub(); |
1209 __ end_a_stub(); |
1171 } |
|
1172 |
|
1173 // Size of trampoline stub, this doesn't need to be accurate but it must |
|
1174 // be larger or equal to the real size of the stub. |
|
1175 // Used for optimization in Compile::Shorten_branches. |
|
1176 uint size_call_trampoline() { |
|
1177 return trampoline_stub_size; |
|
1178 } |
|
1179 |
|
1180 // Number of relocation entries needed by trampoline stub. |
|
1181 // Used for optimization in Compile::Shorten_branches. |
|
1182 uint reloc_call_trampoline() { |
|
1183 return 5; |
|
1184 } |
1210 } |
1185 |
1211 |
1186 //============================================================================= |
1212 //============================================================================= |
1187 |
1213 |
1188 // Emit an inline branch-and-link call and a related trampoline stub. |
1214 // Emit an inline branch-and-link call and a related trampoline stub. |
1219 // Put the entry point as a constant into the constant pool. |
1245 // Put the entry point as a constant into the constant pool. |
1220 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); |
1246 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); |
1221 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); |
1247 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); |
1222 |
1248 |
1223 // Emit the trampoline stub which will be related to the branch-and-link below. |
1249 // Emit the trampoline stub which will be related to the branch-and-link below. |
1224 emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); |
1250 CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); |
1225 __ relocate(rtype); |
1251 __ relocate(rtype); |
1226 } |
1252 } |
1227 |
1253 |
1228 // Note: At this point we do not have the address of the trampoline |
1254 // Note: At this point we do not have the address of the trampoline |
1229 // stub, and the entry point might be too far away for bl, so __ pc() |
1255 // stub, and the entry point might be too far away for bl, so __ pc() |
2021 return MachNode::size(ra_); |
2047 return MachNode::size(ra_); |
2022 } |
2048 } |
2023 |
2049 |
2024 //============================================================================= |
2050 //============================================================================= |
2025 |
2051 |
2026 uint size_exception_handler() { |
2052 %} // interrupt source |
2027 // The exception_handler is a b64_patchable. |
2053 |
2028 return MacroAssembler::b64_patchable_size; |
2054 source_hpp %{ // Header information of the source block. |
2029 } |
2055 |
2030 |
2056 class HandlerImpl { |
2031 uint size_deopt_handler() { |
2057 |
2032 // The deopt_handler is a bl64_patchable. |
2058 public: |
2033 return MacroAssembler::bl64_patchable_size; |
2059 |
2034 } |
2060 static int emit_exception_handler(CodeBuffer &cbuf); |
2035 |
2061 static int emit_deopt_handler(CodeBuffer& cbuf); |
2036 int emit_exception_handler(CodeBuffer &cbuf) { |
2062 |
|
2063 static uint size_exception_handler() { |
|
2064 // The exception_handler is a b64_patchable. |
|
2065 return MacroAssembler::b64_patchable_size; |
|
2066 } |
|
2067 |
|
2068 static uint size_deopt_handler() { |
|
2069 // The deopt_handler is a bl64_patchable. |
|
2070 return MacroAssembler::bl64_patchable_size; |
|
2071 } |
|
2072 |
|
2073 }; |
|
2074 |
|
2075 %} // end source_hpp |
|
2076 |
|
2077 source %{ |
|
2078 |
|
2079 int HandlerImpl::emit_exception_handler(CodeBuffer &cbuf) { |
2037 MacroAssembler _masm(&cbuf); |
2080 MacroAssembler _masm(&cbuf); |
2038 |
2081 |
2039 address base = __ start_a_stub(size_exception_handler()); |
2082 address base = __ start_a_stub(size_exception_handler()); |
2040 if (base == NULL) return 0; // CodeBuffer::expand failed |
2083 if (base == NULL) return 0; // CodeBuffer::expand failed |
2041 |
2084 |
2048 return offset; |
2091 return offset; |
2049 } |
2092 } |
2050 |
2093 |
2051 // The deopt_handler is like the exception handler, but it calls to |
2094 // The deopt_handler is like the exception handler, but it calls to |
2052 // the deoptimization blob instead of jumping to the exception blob. |
2095 // the deoptimization blob instead of jumping to the exception blob. |
2053 int emit_deopt_handler(CodeBuffer& cbuf) { |
2096 int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf) { |
2054 MacroAssembler _masm(&cbuf); |
2097 MacroAssembler _masm(&cbuf); |
2055 |
2098 |
2056 address base = __ start_a_stub(size_deopt_handler()); |
2099 address base = __ start_a_stub(size_deopt_handler()); |
2057 if (base == NULL) return 0; // CodeBuffer::expand failed |
2100 if (base == NULL) return 0; // CodeBuffer::expand failed |
2058 |
2101 |
3436 // Put the entry point as a constant into the constant pool. |
3479 // Put the entry point as a constant into the constant pool. |
3437 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); |
3480 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); |
3438 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); |
3481 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); |
3439 |
3482 |
3440 // Emit the trampoline stub which will be related to the branch-and-link below. |
3483 // Emit the trampoline stub which will be related to the branch-and-link below. |
3441 emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); |
3484 CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); |
3442 __ relocate(_optimized_virtual ? |
3485 __ relocate(_optimized_virtual ? |
3443 relocInfo::opt_virtual_call_type : relocInfo::static_call_type); |
3486 relocInfo::opt_virtual_call_type : relocInfo::static_call_type); |
3444 } |
3487 } |
3445 |
3488 |
3446 // The real call. |
3489 // The real call. |
3479 // Put the entry point as a constant into the constant pool. |
3522 // Put the entry point as a constant into the constant pool. |
3480 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); |
3523 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); |
3481 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); |
3524 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); |
3482 |
3525 |
3483 // Emit the trampoline stub which will be related to the branch-and-link below. |
3526 // Emit the trampoline stub which will be related to the branch-and-link below. |
3484 emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); |
3527 CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); |
3485 assert(_optimized_virtual, "methodHandle call should be a virtual call"); |
3528 assert(_optimized_virtual, "methodHandle call should be a virtual call"); |
3486 __ relocate(relocInfo::opt_virtual_call_type); |
3529 __ relocate(relocInfo::opt_virtual_call_type); |
3487 } |
3530 } |
3488 |
3531 |
3489 // The real call. |
3532 // The real call. |
3529 if (!ra_->C->in_scratch_emit_size()) { |
3572 if (!ra_->C->in_scratch_emit_size()) { |
3530 // Create a call trampoline stub for the given method. |
3573 // Create a call trampoline stub for the given method. |
3531 const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method; |
3574 const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method; |
3532 const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none); |
3575 const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none); |
3533 const int entry_point_const_toc_offset = __ offset_to_method_toc(entry_point_const); |
3576 const int entry_point_const_toc_offset = __ offset_to_method_toc(entry_point_const); |
3534 emit_trampoline_stub(_masm, entry_point_const_toc_offset, __ offset()); |
3577 CallStubImpl::emit_trampoline_stub(_masm, entry_point_const_toc_offset, __ offset()); |
3535 |
3578 |
3536 if (ra_->C->env()->failing()) |
3579 if (ra_->C->env()->failing()) |
3537 return; |
3580 return; |
3538 |
3581 |
3539 // Build relocation at call site with ic position as data. |
3582 // Build relocation at call site with ic position as data. |