Chromium Code Reviews| 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 // Add JavaScript call argument count. | |
|
Michael Starzinger
2015/11/04 13:43:14
nit: empty newline before this block?
Benedikt Meurer
2015/11/04 13:51:09
Done.
| |
| 404 locations.AddParam(regloc(kJavaScriptCallArgCountRegister)); | |
| 405 types.AddParam(kMachInt32); | |
| 406 | |
| 401 // Add context. | 407 // Add context. |
| 402 locations.AddParam(regloc(kContextRegister)); | 408 locations.AddParam(regloc(kContextRegister)); |
| 403 types.AddParam(kMachAnyTagged); | 409 types.AddParam(kMachAnyTagged); |
| 404 | 410 |
| 405 // The target for JS function calls is the JSFunction object. | 411 // The target for JS function calls is the JSFunction object. |
| 406 MachineType target_type = kMachAnyTagged; | 412 MachineType target_type = kMachAnyTagged; |
| 407 // TODO(titzer): When entering into an OSR function from unoptimized code, | 413 // 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 | 414 // 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. | 415 // unaddressable spill slot. We hack this in the OSR prologue. Fix. |
| 410 LinkageLocation target_loc = regloc(kJSFunctionRegister); | 416 LinkageLocation target_loc = regloc(kJSFunctionRegister); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 } | 543 } |
| 538 | 544 |
| 539 | 545 |
| 540 LinkageLocation Linkage::GetOsrValueLocation(int index) const { | 546 LinkageLocation Linkage::GetOsrValueLocation(int index) const { |
| 541 CHECK(incoming_->IsJSFunctionCall()); | 547 CHECK(incoming_->IsJSFunctionCall()); |
| 542 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 548 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
| 543 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 549 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
| 544 | 550 |
| 545 if (index == kOsrContextSpillSlotIndex) { | 551 if (index == kOsrContextSpillSlotIndex) { |
| 546 // Context. Use the parameter location of the context spill slot. | 552 // Context. Use the parameter location of the context spill slot. |
| 547 // Parameter (arity + 1) is special for the context of the function frame. | 553 // Parameter (arity + 2) is special for the context of the function frame. |
| 548 int context_index = 1 + 1 + parameter_count; // target + receiver + params | 554 int context_index = |
| 555 1 + 1 + 1 + parameter_count; // target + receiver + params + #args | |
| 549 return incoming_->GetInputLocation(context_index); | 556 return incoming_->GetInputLocation(context_index); |
| 550 } else if (index >= first_stack_slot) { | 557 } else if (index >= first_stack_slot) { |
| 551 // Local variable stored in this (callee) stack. | 558 // Local variable stored in this (callee) stack. |
| 552 int spill_index = | 559 int spill_index = |
| 553 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; | 560 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; |
| 554 return LinkageLocation::ForCalleeFrameSlot(spill_index); | 561 return LinkageLocation::ForCalleeFrameSlot(spill_index); |
| 555 } else { | 562 } else { |
| 556 // Parameter. Use the assigned location from the incoming call descriptor. | 563 // Parameter. Use the assigned location from the incoming call descriptor. |
| 557 int parameter_index = 1 + index; // skip index 0, which is the target. | 564 int parameter_index = 1 + index; // skip index 0, which is the target. |
| 558 return incoming_->GetInputLocation(parameter_index); | 565 return incoming_->GetInputLocation(parameter_index); |
| 559 } | 566 } |
| 560 } | 567 } |
| 561 } // namespace compiler | 568 } // namespace compiler |
| 562 } // namespace internal | 569 } // namespace internal |
| 563 } // namespace v8 | 570 } // namespace v8 |
| OLD | NEW |