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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/frame.h" | 8 #include "src/compiler/frame.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 CallDescriptor::kNeedsFrameState, // flags | 376 CallDescriptor::kNeedsFrameState, // flags |
377 "lazy-bailout"); | 377 "lazy-bailout"); |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, | 381 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, |
382 int js_parameter_count, | 382 int js_parameter_count, |
383 CallDescriptor::Flags flags) { | 383 CallDescriptor::Flags flags) { |
384 const size_t return_count = 1; | 384 const size_t return_count = 1; |
385 const size_t context_count = 1; | 385 const size_t context_count = 1; |
386 const size_t parameter_count = js_parameter_count + context_count; | 386 const size_t num_args_count = 1; |
| 387 const size_t parameter_count = |
| 388 js_parameter_count + num_args_count + context_count; |
387 | 389 |
388 LocationSignature::Builder locations(zone, return_count, parameter_count); | 390 LocationSignature::Builder locations(zone, return_count, parameter_count); |
389 MachineSignature::Builder types(zone, return_count, parameter_count); | 391 MachineSignature::Builder types(zone, return_count, parameter_count); |
390 | 392 |
391 // All JS calls have exactly one return value. | 393 // All JS calls have exactly one return value. |
392 locations.AddReturn(regloc(kReturnRegister0)); | 394 locations.AddReturn(regloc(kReturnRegister0)); |
393 types.AddReturn(kMachAnyTagged); | 395 types.AddReturn(kMachAnyTagged); |
394 | 396 |
395 // All parameters to JS calls go on the stack. | 397 // All parameters to JS calls go on the stack. |
396 for (int i = 0; i < js_parameter_count; i++) { | 398 for (int i = 0; i < js_parameter_count; i++) { |
397 int spill_slot_index = i - js_parameter_count; | 399 int spill_slot_index = i - js_parameter_count; |
398 locations.AddParam(LinkageLocation::ForCallerFrameSlot(spill_slot_index)); | 400 locations.AddParam(LinkageLocation::ForCallerFrameSlot(spill_slot_index)); |
399 types.AddParam(kMachAnyTagged); | 401 types.AddParam(kMachAnyTagged); |
400 } | 402 } |
| 403 |
| 404 // Add JavaScript call argument count. |
| 405 locations.AddParam(regloc(kJavaScriptCallArgCountRegister)); |
| 406 types.AddParam(kMachInt32); |
| 407 |
401 // Add context. | 408 // Add context. |
402 locations.AddParam(regloc(kContextRegister)); | 409 locations.AddParam(regloc(kContextRegister)); |
403 types.AddParam(kMachAnyTagged); | 410 types.AddParam(kMachAnyTagged); |
404 | 411 |
405 // The target for JS function calls is the JSFunction object. | 412 // The target for JS function calls is the JSFunction object. |
406 MachineType target_type = kMachAnyTagged; | 413 MachineType target_type = kMachAnyTagged; |
407 // TODO(titzer): When entering into an OSR function from unoptimized code, | 414 // TODO(titzer): When entering into an OSR function from unoptimized code, |
408 // the JSFunction is not in a register, but it is on the stack in an | 415 // the JSFunction is not in a register, but it is on the stack in an |
409 // unaddressable spill slot. We hack this in the OSR prologue. Fix. | 416 // unaddressable spill slot. We hack this in the OSR prologue. Fix. |
410 LinkageLocation target_loc = regloc(kJSFunctionRegister); | 417 LinkageLocation target_loc = regloc(kJSFunctionRegister); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 544 } |
538 | 545 |
539 | 546 |
540 LinkageLocation Linkage::GetOsrValueLocation(int index) const { | 547 LinkageLocation Linkage::GetOsrValueLocation(int index) const { |
541 CHECK(incoming_->IsJSFunctionCall()); | 548 CHECK(incoming_->IsJSFunctionCall()); |
542 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 549 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
543 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 550 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
544 | 551 |
545 if (index == kOsrContextSpillSlotIndex) { | 552 if (index == kOsrContextSpillSlotIndex) { |
546 // Context. Use the parameter location of the context spill slot. | 553 // Context. Use the parameter location of the context spill slot. |
547 // Parameter (arity + 1) is special for the context of the function frame. | 554 // Parameter (arity + 2) is special for the context of the function frame. |
548 int context_index = 1 + 1 + parameter_count; // target + receiver + params | 555 int context_index = |
| 556 1 + 1 + 1 + parameter_count; // target + receiver + params + #args |
549 return incoming_->GetInputLocation(context_index); | 557 return incoming_->GetInputLocation(context_index); |
550 } else if (index >= first_stack_slot) { | 558 } else if (index >= first_stack_slot) { |
551 // Local variable stored in this (callee) stack. | 559 // Local variable stored in this (callee) stack. |
552 int spill_index = | 560 int spill_index = |
553 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; | 561 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; |
554 return LinkageLocation::ForCalleeFrameSlot(spill_index); | 562 return LinkageLocation::ForCalleeFrameSlot(spill_index); |
555 } else { | 563 } else { |
556 // Parameter. Use the assigned location from the incoming call descriptor. | 564 // Parameter. Use the assigned location from the incoming call descriptor. |
557 int parameter_index = 1 + index; // skip index 0, which is the target. | 565 int parameter_index = 1 + index; // skip index 0, which is the target. |
558 return incoming_->GetInputLocation(parameter_index); | 566 return incoming_->GetInputLocation(parameter_index); |
559 } | 567 } |
560 } | 568 } |
561 } // namespace compiler | 569 } // namespace compiler |
562 } // namespace internal | 570 } // namespace internal |
563 } // namespace v8 | 571 } // namespace v8 |
OLD | NEW |