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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/frame.h" | 9 #include "src/compiler/frame.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 "interpreter-dispatch"); | 423 "interpreter-dispatch"); |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 // TODO(all): Add support for return representations/locations to | 427 // TODO(all): Add support for return representations/locations to |
428 // CallInterfaceDescriptor. | 428 // CallInterfaceDescriptor. |
429 // TODO(turbofan): cache call descriptors for code stub calls. | 429 // TODO(turbofan): cache call descriptors for code stub calls. |
430 CallDescriptor* Linkage::GetStubCallDescriptor( | 430 CallDescriptor* Linkage::GetStubCallDescriptor( |
431 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, | 431 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, |
432 int stack_parameter_count, CallDescriptor::Flags flags, | 432 int stack_parameter_count, CallDescriptor::Flags flags, |
433 Operator::Properties properties, MachineType return_type) { | 433 Operator::Properties properties, MachineType return_type, |
| 434 size_t return_count) { |
434 const int register_parameter_count = descriptor.GetRegisterParameterCount(); | 435 const int register_parameter_count = descriptor.GetRegisterParameterCount(); |
435 const int js_parameter_count = | 436 const int js_parameter_count = |
436 register_parameter_count + stack_parameter_count; | 437 register_parameter_count + stack_parameter_count; |
437 const int context_count = 1; | 438 const int context_count = 1; |
438 const size_t return_count = 1; | |
439 const size_t parameter_count = | 439 const size_t parameter_count = |
440 static_cast<size_t>(js_parameter_count + context_count); | 440 static_cast<size_t>(js_parameter_count + context_count); |
441 | 441 |
442 LocationSignature::Builder locations(zone, return_count, parameter_count); | 442 LocationSignature::Builder locations(zone, return_count, parameter_count); |
443 MachineSignature::Builder types(zone, return_count, parameter_count); | 443 MachineSignature::Builder types(zone, return_count, parameter_count); |
444 | 444 |
445 // Add return location. | 445 // Add returns. |
446 locations.AddReturn(regloc(kReturnRegister0)); | 446 if (locations.return_count_ > 0) { |
447 types.AddReturn(return_type); | 447 locations.AddReturn(regloc(kReturnRegister0)); |
| 448 } |
| 449 if (locations.return_count_ > 1) { |
| 450 locations.AddReturn(regloc(kReturnRegister1)); |
| 451 } |
| 452 for (size_t i = 0; i < return_count; i++) { |
| 453 types.AddReturn(return_type); |
| 454 } |
448 | 455 |
449 // Add parameters in registers and on the stack. | 456 // Add parameters in registers and on the stack. |
450 for (int i = 0; i < js_parameter_count; i++) { | 457 for (int i = 0; i < js_parameter_count; i++) { |
451 if (i < register_parameter_count) { | 458 if (i < register_parameter_count) { |
452 // The first parameters go in registers. | 459 // The first parameters go in registers. |
453 Register reg = descriptor.GetRegisterParameter(i); | 460 Register reg = descriptor.GetRegisterParameter(i); |
454 Representation rep = | 461 Representation rep = |
455 RepresentationFromType(descriptor.GetParameterType(i)); | 462 RepresentationFromType(descriptor.GetParameterType(i)); |
456 locations.AddParam(regloc(reg)); | 463 locations.AddParam(regloc(reg)); |
457 types.AddParam(reptyp(rep)); | 464 types.AddParam(reptyp(rep)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } else { | 531 } else { |
525 DCHECK(loc == regloc(kContextRegister)); | 532 DCHECK(loc == regloc(kContextRegister)); |
526 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); | 533 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); |
527 } | 534 } |
528 } | 535 } |
529 | 536 |
530 | 537 |
531 } // namespace compiler | 538 } // namespace compiler |
532 } // namespace internal | 539 } // namespace internal |
533 } // namespace v8 | 540 } // namespace v8 |
OLD | NEW |