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 int stack_offset = LinkageTraits::CStackBackingStoreLength(); | 210 int stack_offset = LinkageTraits::CStackBackingStoreLength(); |
208 for (int i = 0; i < parameter_count; i++) { | 211 for (int i = 0; i < parameter_count; i++) { |
209 if (i < LinkageTraits::CRegisterParametersLength()) { | 212 if (i < LinkageTraits::CRegisterParametersLength()) { |
210 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i))); | 213 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i))); |
211 } else { | 214 } else { |
212 locations.AddParam(stackloc(-1 - stack_offset)); | 215 locations.AddParam(stackloc(-1 - stack_offset)); |
213 stack_offset++; | 216 stack_offset++; |
214 } | 217 } |
215 } | 218 } |
216 | 219 |
217 // The target for C calls is always an address (i.e. machine pointer). | 220 // The target for C calls is always an address (i.e. machine pointer). |
218 MachineType target_type = kMachPtr; | 221 MachineType target_type = kMachPtr; |
219 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 222 LinkageLocation target_loc = LinkageLocation::AnyRegister(); |
220 return new (zone) CallDescriptor( // -- | 223 return new (zone) CallDescriptor( // -- |
221 CallDescriptor::kCallAddress, // kind | 224 CallDescriptor::kCallAddress, // kind |
222 target_type, // target MachineType | 225 target_type, // target MachineType |
223 target_loc, // target location | 226 target_loc, // target location |
224 msig, // machine_sig | 227 msig, // machine_sig |
225 locations.Build(), // location_sig | 228 locations.Build(), // location_sig |
226 0, // js_parameter_count | 229 0, // js_parameter_count |
227 Operator::kNoProperties, // properties | 230 Operator::kNoProperties, // properties |
228 LinkageTraits::CCalleeSaveRegisters(), // callee-saved registers | 231 LinkageTraits::CCalleeSaveRegisters(), // callee-saved registers |
229 CallDescriptor::kNoFlags, // flags | 232 LinkageTraits::CCalleeSaveFPRegisters(), // callee-saved fp regs |
| 233 CallDescriptor::kNoFlags, // flags |
230 "c-call"); | 234 "c-call"); |
231 } | 235 } |
232 | 236 |
233 static LinkageLocation regloc(Register reg) { | 237 static LinkageLocation regloc(Register reg) { |
234 return LinkageLocation(Register::ToAllocationIndex(reg)); | 238 return LinkageLocation(Register::ToAllocationIndex(reg)); |
235 } | 239 } |
236 | 240 |
237 static LinkageLocation stackloc(int i) { | 241 static LinkageLocation stackloc(int i) { |
238 DCHECK_LT(i, 0); | 242 DCHECK_LT(i, 0); |
239 return LinkageLocation(i); | 243 return LinkageLocation(i); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 int parameter_index = 1 + index; // skip index 0, which is the target. | 290 int parameter_index = 1 + index; // skip index 0, which is the target. |
287 return incoming_->GetInputLocation(parameter_index); | 291 return incoming_->GetInputLocation(parameter_index); |
288 } | 292 } |
289 } | 293 } |
290 | 294 |
291 } // namespace compiler | 295 } // namespace compiler |
292 } // namespace internal | 296 } // namespace internal |
293 } // namespace v8 | 297 } // namespace v8 |
294 | 298 |
295 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 299 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
OLD | NEW |