| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ | 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ |
| 6 #define V8_COMPILER_LINKAGE_IMPL_H_ | 6 #define V8_COMPILER_LINKAGE_IMPL_H_ |
| 7 | 7 |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler/osr.h" | 9 #include "src/compiler/osr.h" |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 LinkageLocation target_loc = regloc(LinkageTraits::JSCallFunctionReg()); | 63 LinkageLocation target_loc = regloc(LinkageTraits::JSCallFunctionReg()); |
| 64 return new (zone) CallDescriptor( // -- | 64 return new (zone) CallDescriptor( // -- |
| 65 CallDescriptor::kCallJSFunction, // kind | 65 CallDescriptor::kCallJSFunction, // kind |
| 66 target_type, // target MachineType | 66 target_type, // target MachineType |
| 67 target_loc, // target location | 67 target_loc, // target location |
| 68 types.Build(), // machine_sig | 68 types.Build(), // machine_sig |
| 69 locations.Build(), // location_sig | 69 locations.Build(), // location_sig |
| 70 js_parameter_count, // js_parameter_count | 70 js_parameter_count, // js_parameter_count |
| 71 Operator::kNoProperties, // properties | 71 Operator::kNoProperties, // properties |
| 72 kNoCalleeSaved, // callee-saved | 72 kNoCalleeSaved, // callee-saved |
| 73 kNoCalleeSaved, // callee-saved fp |
| 73 flags, // flags | 74 flags, // flags |
| 74 "js-call"); | 75 "js-call"); |
| 75 } | 76 } |
| 76 | 77 |
| 77 | 78 |
| 78 // TODO(turbofan): cache call descriptors for runtime calls. | 79 // TODO(turbofan): cache call descriptors for runtime calls. |
| 79 static CallDescriptor* GetRuntimeCallDescriptor( | 80 static CallDescriptor* GetRuntimeCallDescriptor( |
| 80 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, | 81 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, |
| 81 Operator::Properties properties) { | 82 Operator::Properties properties) { |
| 82 const size_t function_count = 1; | 83 const size_t function_count = 1; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 125 LinkageLocation target_loc = LinkageLocation::AnyRegister(); |
| 125 return new (zone) CallDescriptor( // -- | 126 return new (zone) CallDescriptor( // -- |
| 126 CallDescriptor::kCallCodeObject, // kind | 127 CallDescriptor::kCallCodeObject, // kind |
| 127 target_type, // target MachineType | 128 target_type, // target MachineType |
| 128 target_loc, // target location | 129 target_loc, // target location |
| 129 types.Build(), // machine_sig | 130 types.Build(), // machine_sig |
| 130 locations.Build(), // location_sig | 131 locations.Build(), // location_sig |
| 131 js_parameter_count, // js_parameter_count | 132 js_parameter_count, // js_parameter_count |
| 132 properties, // properties | 133 properties, // properties |
| 133 kNoCalleeSaved, // callee-saved | 134 kNoCalleeSaved, // callee-saved |
| 135 kNoCalleeSaved, // callee-saved fp |
| 134 flags, // flags | 136 flags, // flags |
| 135 function->name); // debug name | 137 function->name); // debug name |
| 136 } | 138 } |
| 137 | 139 |
| 138 | 140 |
| 139 // TODO(all): Add support for return representations/locations to | 141 // TODO(all): Add support for return representations/locations to |
| 140 // CallInterfaceDescriptor. | 142 // CallInterfaceDescriptor. |
| 141 // TODO(turbofan): cache call descriptors for code stub calls. | 143 // TODO(turbofan): cache call descriptors for code stub calls. |
| 142 static CallDescriptor* GetStubCallDescriptor( | 144 static CallDescriptor* GetStubCallDescriptor( |
| 143 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, | 145 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 186 LinkageLocation target_loc = LinkageLocation::AnyRegister(); |
| 185 return new (zone) CallDescriptor( // -- | 187 return new (zone) CallDescriptor( // -- |
| 186 CallDescriptor::kCallCodeObject, // kind | 188 CallDescriptor::kCallCodeObject, // kind |
| 187 target_type, // target MachineType | 189 target_type, // target MachineType |
| 188 target_loc, // target location | 190 target_loc, // target location |
| 189 types.Build(), // machine_sig | 191 types.Build(), // machine_sig |
| 190 locations.Build(), // location_sig | 192 locations.Build(), // location_sig |
| 191 js_parameter_count, // js_parameter_count | 193 js_parameter_count, // js_parameter_count |
| 192 properties, // properties | 194 properties, // properties |
| 193 kNoCalleeSaved, // callee-saved registers | 195 kNoCalleeSaved, // callee-saved registers |
| 196 kNoCalleeSaved, // callee-saved fp |
| 194 flags, // flags | 197 flags, // flags |
| 195 descriptor.DebugName(isolate)); | 198 descriptor.DebugName(isolate)); |
| 196 } | 199 } |
| 197 | 200 |
| 198 static CallDescriptor* GetSimplifiedCDescriptor( | 201 static CallDescriptor* GetSimplifiedCDescriptor( |
| 199 Zone* zone, const MachineSignature* msig) { | 202 Zone* zone, const MachineSignature* msig) { |
| 200 LocationSignature::Builder locations(zone, msig->return_count(), | 203 LocationSignature::Builder locations(zone, msig->return_count(), |
| 201 msig->parameter_count()); | 204 msig->parameter_count()); |
| 202 // Add return location(s). | 205 // Add return location(s). |
| 203 AddReturnLocations(&locations); | 206 AddReturnLocations(&locations); |
| 204 | 207 |
| 205 // Add register and/or stack parameter(s). | 208 // Add register and/or stack parameter(s). |
| 206 const int parameter_count = static_cast<int>(msig->parameter_count()); | 209 const int parameter_count = static_cast<int>(msig->parameter_count()); |
| 207 for (int i = 0; i < parameter_count; i++) { | 210 for (int i = 0; i < parameter_count; i++) { |
| 208 if (i < LinkageTraits::CRegisterParametersLength()) { | 211 if (i < LinkageTraits::CRegisterParametersLength()) { |
| 209 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i))); | 212 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i))); |
| 210 } else { | 213 } else { |
| 211 locations.AddParam(stackloc(-1 - i)); | 214 locations.AddParam(stackloc(-1 - i)); |
| 212 } | 215 } |
| 213 } | 216 } |
| 214 | 217 |
| 215 // The target for C calls is always an address (i.e. machine pointer). | 218 // The target for C calls is always an address (i.e. machine pointer). |
| 216 MachineType target_type = kMachPtr; | 219 MachineType target_type = kMachPtr; |
| 217 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 220 LinkageLocation target_loc = LinkageLocation::AnyRegister(); |
| 218 return new (zone) CallDescriptor( // -- | 221 return new (zone) CallDescriptor( // -- |
| 219 CallDescriptor::kCallAddress, // kind | 222 CallDescriptor::kCallAddress, // kind |
| 220 target_type, // target MachineType | 223 target_type, // target MachineType |
| 221 target_loc, // target location | 224 target_loc, // target location |
| 222 msig, // machine_sig | 225 msig, // machine_sig |
| 223 locations.Build(), // location_sig | 226 locations.Build(), // location_sig |
| 224 0, // js_parameter_count | 227 0, // js_parameter_count |
| 225 Operator::kNoProperties, // properties | 228 Operator::kNoProperties, // properties |
| 226 LinkageTraits::CCalleeSaveRegisters(), // callee-saved registers | 229 LinkageTraits::CCalleeSaveRegisters(), // callee-saved registers |
| 227 CallDescriptor::kNoFlags, // flags | 230 LinkageTraits::CCalleeSaveFPRegisters(), // callee-saved fp regs |
| 231 CallDescriptor::kNoFlags, // flags |
| 228 "c-call"); | 232 "c-call"); |
| 229 } | 233 } |
| 230 | 234 |
| 231 static LinkageLocation regloc(Register reg) { | 235 static LinkageLocation regloc(Register reg) { |
| 232 return LinkageLocation(Register::ToAllocationIndex(reg)); | 236 return LinkageLocation(Register::ToAllocationIndex(reg)); |
| 233 } | 237 } |
| 234 | 238 |
| 235 static LinkageLocation stackloc(int i) { | 239 static LinkageLocation stackloc(int i) { |
| 236 DCHECK_LT(i, 0); | 240 DCHECK_LT(i, 0); |
| 237 return LinkageLocation(i); | 241 return LinkageLocation(i); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 int parameter_index = 1 + index; // skip index 0, which is the target. | 288 int parameter_index = 1 + index; // skip index 0, which is the target. |
| 285 return incoming_->GetInputLocation(parameter_index); | 289 return incoming_->GetInputLocation(parameter_index); |
| 286 } | 290 } |
| 287 } | 291 } |
| 288 | 292 |
| 289 } // namespace compiler | 293 } // namespace compiler |
| 290 } // namespace internal | 294 } // namespace internal |
| 291 } // namespace v8 | 295 } // namespace v8 |
| 292 | 296 |
| 293 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 297 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
| OLD | NEW |