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 #include "src/compiler/linkage.h" | |
Jarin
2016/08/19 09:01:10
I think you should insert an empty line after this
jgruber
2016/08/19 11:17:07
Done. This was actually an automatic change by git
| |
5 #include "src/ast/scopes.h" | 6 #include "src/ast/scopes.h" |
7 #include "src/builtins/builtins-utils.h" | |
6 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
7 #include "src/compiler.h" | 9 #include "src/compiler.h" |
8 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/frame.h" | 11 #include "src/compiler/frame.h" |
10 #include "src/compiler/linkage.h" | |
11 #include "src/compiler/node.h" | 12 #include "src/compiler/node.h" |
12 #include "src/compiler/osr.h" | 13 #include "src/compiler/osr.h" |
13 #include "src/compiler/pipeline.h" | 14 #include "src/compiler/pipeline.h" |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 namespace compiler { | 18 namespace compiler { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 for (size_t i = 0; i < ReturnCount(); ++i) { | 216 for (size_t i = 0; i < ReturnCount(); ++i) { |
216 if (!GetReturnLocation(i).IsRegister()) return false; | 217 if (!GetReturnLocation(i).IsRegister()) return false; |
217 } | 218 } |
218 return true; | 219 return true; |
219 } | 220 } |
220 | 221 |
221 | 222 |
222 CallDescriptor* Linkage::GetRuntimeCallDescriptor( | 223 CallDescriptor* Linkage::GetRuntimeCallDescriptor( |
223 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, | 224 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, |
224 Operator::Properties properties, CallDescriptor::Flags flags) { | 225 Operator::Properties properties, CallDescriptor::Flags flags) { |
226 const Runtime::Function* function = Runtime::FunctionForId(function_id); | |
227 const int return_count = function->result_size; | |
228 const char* debug_name = function->name; | |
229 | |
230 if (!Linkage::NeedsFrameStateInput(function_id)) { | |
231 flags = static_cast<CallDescriptor::Flags>( | |
232 flags & ~CallDescriptor::kNeedsFrameState); | |
233 } | |
234 | |
235 return GetCEntryStubCallDescriptor(zone, return_count, js_parameter_count, | |
236 debug_name, properties, flags); | |
237 } | |
238 | |
239 CallDescriptor* Linkage::GetCEntryStubCallDescriptor( | |
240 Zone* zone, int return_count, int js_parameter_count, | |
241 const char* debug_name, Operator::Properties properties, | |
242 CallDescriptor::Flags flags) { | |
225 const size_t function_count = 1; | 243 const size_t function_count = 1; |
226 const size_t num_args_count = 1; | 244 const size_t num_args_count = 1; |
227 const size_t context_count = 1; | 245 const size_t context_count = 1; |
228 const size_t parameter_count = function_count + | 246 const size_t parameter_count = function_count + |
229 static_cast<size_t>(js_parameter_count) + | 247 static_cast<size_t>(js_parameter_count) + |
230 num_args_count + context_count; | 248 num_args_count + context_count; |
231 | 249 |
232 const Runtime::Function* function = Runtime::FunctionForId(function_id); | 250 LocationSignature::Builder locations(zone, static_cast<size_t>(return_count), |
233 const size_t return_count = static_cast<size_t>(function->result_size); | 251 static_cast<size_t>(parameter_count)); |
234 | |
235 LocationSignature::Builder locations(zone, return_count, parameter_count); | |
236 | 252 |
237 // Add returns. | 253 // Add returns. |
238 if (locations.return_count_ > 0) { | 254 if (locations.return_count_ > 0) { |
239 locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged())); | 255 locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged())); |
240 } | 256 } |
241 if (locations.return_count_ > 1) { | 257 if (locations.return_count_ > 1) { |
242 locations.AddReturn(regloc(kReturnRegister1, MachineType::AnyTagged())); | 258 locations.AddReturn(regloc(kReturnRegister1, MachineType::AnyTagged())); |
243 } | 259 } |
244 if (locations.return_count_ > 2) { | 260 if (locations.return_count_ > 2) { |
245 locations.AddReturn(regloc(kReturnRegister2, MachineType::AnyTagged())); | 261 locations.AddReturn(regloc(kReturnRegister2, MachineType::AnyTagged())); |
246 } | 262 } |
247 | 263 |
248 // All parameters to the runtime call go on the stack. | 264 // All parameters to the runtime call go on the stack. |
249 for (int i = 0; i < js_parameter_count; i++) { | 265 for (int i = 0; i < js_parameter_count; i++) { |
250 locations.AddParam(LinkageLocation::ForCallerFrameSlot( | 266 locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
251 i - js_parameter_count, MachineType::AnyTagged())); | 267 i - js_parameter_count, MachineType::AnyTagged())); |
252 } | 268 } |
253 // Add runtime function itself. | 269 // Add runtime function itself. |
254 locations.AddParam( | 270 locations.AddParam( |
255 regloc(kRuntimeCallFunctionRegister, MachineType::Pointer())); | 271 regloc(kRuntimeCallFunctionRegister, MachineType::Pointer())); |
256 | 272 |
257 // Add runtime call argument count. | 273 // Add runtime call argument count. |
258 locations.AddParam( | 274 locations.AddParam( |
259 regloc(kRuntimeCallArgCountRegister, MachineType::Int32())); | 275 regloc(kRuntimeCallArgCountRegister, MachineType::Int32())); |
260 | 276 |
261 // Add context. | 277 // Add context. |
262 locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); | 278 locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); |
263 | 279 |
264 if (!Linkage::NeedsFrameStateInput(function_id)) { | |
265 flags = static_cast<CallDescriptor::Flags>( | |
266 flags & ~CallDescriptor::kNeedsFrameState); | |
267 } | |
268 | |
269 // The target for runtime calls is a code object. | 280 // The target for runtime calls is a code object. |
270 MachineType target_type = MachineType::AnyTagged(); | 281 MachineType target_type = MachineType::AnyTagged(); |
271 LinkageLocation target_loc = | 282 LinkageLocation target_loc = |
272 LinkageLocation::ForAnyRegister(MachineType::AnyTagged()); | 283 LinkageLocation::ForAnyRegister(MachineType::AnyTagged()); |
273 return new (zone) CallDescriptor( // -- | 284 return new (zone) CallDescriptor( // -- |
274 CallDescriptor::kCallCodeObject, // kind | 285 CallDescriptor::kCallCodeObject, // kind |
275 target_type, // target MachineType | 286 target_type, // target MachineType |
276 target_loc, // target location | 287 target_loc, // target location |
277 locations.Build(), // location_sig | 288 locations.Build(), // location_sig |
278 js_parameter_count, // stack_parameter_count | 289 js_parameter_count, // stack_parameter_count |
279 properties, // properties | 290 properties, // properties |
280 kNoCalleeSaved, // callee-saved | 291 kNoCalleeSaved, // callee-saved |
281 kNoCalleeSaved, // callee-saved fp | 292 kNoCalleeSaved, // callee-saved fp |
282 flags, // flags | 293 flags, // flags |
283 function->name); // debug name | 294 debug_name); // debug name |
284 } | 295 } |
285 | 296 |
286 | |
287 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, | 297 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, |
288 int js_parameter_count, | 298 int js_parameter_count, |
289 CallDescriptor::Flags flags) { | 299 CallDescriptor::Flags flags) { |
290 const size_t return_count = 1; | 300 const size_t return_count = 1; |
291 const size_t context_count = 1; | 301 const size_t context_count = 1; |
292 const size_t new_target_count = 1; | 302 const size_t new_target_count = 1; |
293 const size_t num_args_count = 1; | 303 const size_t num_args_count = 1; |
294 const size_t parameter_count = | 304 const size_t parameter_count = |
295 js_parameter_count + new_target_count + num_args_count + context_count; | 305 js_parameter_count + new_target_count + num_args_count + context_count; |
296 | 306 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); | 522 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); |
513 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, | 523 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, |
514 MachineType::AnyTagged()); | 524 MachineType::AnyTagged()); |
515 } | 525 } |
516 } | 526 } |
517 | 527 |
518 | 528 |
519 } // namespace compiler | 529 } // namespace compiler |
520 } // namespace internal | 530 } // namespace internal |
521 } // namespace v8 | 531 } // namespace v8 |
OLD | NEW |