| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 CallDescriptor::kNeedsFrameState, // flags | 334 CallDescriptor::kNeedsFrameState, // flags |
| 335 "lazy-bailout"); | 335 "lazy-bailout"); |
| 336 } | 336 } |
| 337 | 337 |
| 338 | 338 |
| 339 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, | 339 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, |
| 340 int js_parameter_count, | 340 int js_parameter_count, |
| 341 CallDescriptor::Flags flags) { | 341 CallDescriptor::Flags flags) { |
| 342 const size_t return_count = 1; | 342 const size_t return_count = 1; |
| 343 const size_t context_count = 1; | 343 const size_t context_count = 1; |
| 344 const size_t new_target_count = 1; |
| 344 const size_t num_args_count = 1; | 345 const size_t num_args_count = 1; |
| 345 const size_t parameter_count = | 346 const size_t parameter_count = |
| 346 js_parameter_count + num_args_count + context_count; | 347 js_parameter_count + new_target_count + num_args_count + context_count; |
| 347 | 348 |
| 348 LocationSignature::Builder locations(zone, return_count, parameter_count); | 349 LocationSignature::Builder locations(zone, return_count, parameter_count); |
| 349 MachineSignature::Builder types(zone, return_count, parameter_count); | 350 MachineSignature::Builder types(zone, return_count, parameter_count); |
| 350 | 351 |
| 351 // All JS calls have exactly one return value. | 352 // All JS calls have exactly one return value. |
| 352 locations.AddReturn(regloc(kReturnRegister0)); | 353 locations.AddReturn(regloc(kReturnRegister0)); |
| 353 types.AddReturn(kMachAnyTagged); | 354 types.AddReturn(kMachAnyTagged); |
| 354 | 355 |
| 355 // All parameters to JS calls go on the stack. | 356 // All parameters to JS calls go on the stack. |
| 356 for (int i = 0; i < js_parameter_count; i++) { | 357 for (int i = 0; i < js_parameter_count; i++) { |
| 357 int spill_slot_index = i - js_parameter_count; | 358 int spill_slot_index = i - js_parameter_count; |
| 358 locations.AddParam(LinkageLocation::ForCallerFrameSlot(spill_slot_index)); | 359 locations.AddParam(LinkageLocation::ForCallerFrameSlot(spill_slot_index)); |
| 359 types.AddParam(kMachAnyTagged); | 360 types.AddParam(kMachAnyTagged); |
| 360 } | 361 } |
| 361 | 362 |
| 363 // Add JavaScript call new target value. |
| 364 locations.AddParam(regloc(kJavaScriptCallNewTargetRegister)); |
| 365 types.AddParam(kMachAnyTagged); |
| 366 |
| 362 // Add JavaScript call argument count. | 367 // Add JavaScript call argument count. |
| 363 locations.AddParam(regloc(kJavaScriptCallArgCountRegister)); | 368 locations.AddParam(regloc(kJavaScriptCallArgCountRegister)); |
| 364 types.AddParam(kMachInt32); | 369 types.AddParam(kMachInt32); |
| 365 | 370 |
| 366 // Add context. | 371 // Add context. |
| 367 locations.AddParam(regloc(kContextRegister)); | 372 locations.AddParam(regloc(kContextRegister)); |
| 368 types.AddParam(kMachAnyTagged); | 373 types.AddParam(kMachAnyTagged); |
| 369 | 374 |
| 370 // The target for JS function calls is the JSFunction object. | 375 // The target for JS function calls is the JSFunction object. |
| 371 MachineType target_type = kMachAnyTagged; | 376 MachineType target_type = kMachAnyTagged; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 508 |
| 504 | 509 |
| 505 LinkageLocation Linkage::GetOsrValueLocation(int index) const { | 510 LinkageLocation Linkage::GetOsrValueLocation(int index) const { |
| 506 CHECK(incoming_->IsJSFunctionCall()); | 511 CHECK(incoming_->IsJSFunctionCall()); |
| 507 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 512 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
| 508 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 513 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
| 509 | 514 |
| 510 if (index == kOsrContextSpillSlotIndex) { | 515 if (index == kOsrContextSpillSlotIndex) { |
| 511 // Context. Use the parameter location of the context spill slot. | 516 // Context. Use the parameter location of the context spill slot. |
| 512 // Parameter (arity + 2) is special for the context of the function frame. | 517 // Parameter (arity + 2) is special for the context of the function frame. |
| 513 int context_index = | 518 // >> context_index = target + receiver + params + new_target + #args |
| 514 1 + 1 + 1 + parameter_count; // target + receiver + params + #args | 519 int context_index = 1 + 1 + parameter_count + 1 + 1; |
| 515 return incoming_->GetInputLocation(context_index); | 520 return incoming_->GetInputLocation(context_index); |
| 516 } else if (index >= first_stack_slot) { | 521 } else if (index >= first_stack_slot) { |
| 517 // Local variable stored in this (callee) stack. | 522 // Local variable stored in this (callee) stack. |
| 518 int spill_index = | 523 int spill_index = |
| 519 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; | 524 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; |
| 520 return LinkageLocation::ForCalleeFrameSlot(spill_index); | 525 return LinkageLocation::ForCalleeFrameSlot(spill_index); |
| 521 } else { | 526 } else { |
| 522 // Parameter. Use the assigned location from the incoming call descriptor. | 527 // Parameter. Use the assigned location from the incoming call descriptor. |
| 523 int parameter_index = 1 + index; // skip index 0, which is the target. | 528 int parameter_index = 1 + index; // skip index 0, which is the target. |
| 524 return incoming_->GetInputLocation(parameter_index); | 529 return incoming_->GetInputLocation(parameter_index); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 542 } else { | 547 } else { |
| 543 DCHECK(loc == regloc(kContextRegister)); | 548 DCHECK(loc == regloc(kContextRegister)); |
| 544 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); | 549 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); |
| 545 } | 550 } |
| 546 } | 551 } |
| 547 | 552 |
| 548 | 553 |
| 549 } // namespace compiler | 554 } // namespace compiler |
| 550 } // namespace internal | 555 } // namespace internal |
| 551 } // namespace v8 | 556 } // namespace v8 |
| OLD | NEW |