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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 locations.Build(), // location_sig | 397 locations.Build(), // location_sig |
398 stack_parameter_count, // stack_parameter_count | 398 stack_parameter_count, // stack_parameter_count |
399 properties, // properties | 399 properties, // properties |
400 kNoCalleeSaved, // callee-saved registers | 400 kNoCalleeSaved, // callee-saved registers |
401 kNoCalleeSaved, // callee-saved fp | 401 kNoCalleeSaved, // callee-saved fp |
402 CallDescriptor::kCanUseRoots | // flags | 402 CallDescriptor::kCanUseRoots | // flags |
403 flags, // flags | 403 flags, // flags |
404 descriptor.DebugName(isolate)); | 404 descriptor.DebugName(isolate)); |
405 } | 405 } |
406 | 406 |
| 407 CallDescriptor* Linkage::GetBytecodeDispatchCallDescriptor( |
| 408 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, |
| 409 int stack_parameter_count) { |
| 410 const int register_parameter_count = descriptor.GetRegisterParameterCount(); |
| 411 const int parameter_count = register_parameter_count + stack_parameter_count; |
| 412 const int context_count = 1; |
| 413 const size_t parameter_and_context_count = |
| 414 static_cast<size_t>(parameter_count + context_count); |
| 415 |
| 416 LocationSignature::Builder locations(zone, 0, parameter_and_context_count); |
| 417 MachineSignature::Builder types(zone, 0, parameter_and_context_count); |
| 418 |
| 419 // Add parameters in registers and on the stack. |
| 420 for (int i = 0; i < parameter_count; i++) { |
| 421 if (i < register_parameter_count) { |
| 422 // The first parameters go in registers. |
| 423 Register reg = descriptor.GetRegisterParameter(i); |
| 424 Representation rep = |
| 425 RepresentationFromType(descriptor.GetParameterType(i)); |
| 426 locations.AddParam(regloc(reg)); |
| 427 types.AddParam(reptyp(rep)); |
| 428 } else { |
| 429 // The rest of the parameters go on the stack. |
| 430 int stack_slot = i - register_parameter_count - stack_parameter_count; |
| 431 locations.AddParam(LinkageLocation::ForCallerFrameSlot(stack_slot)); |
| 432 types.AddParam(MachineType::AnyTagged()); |
| 433 } |
| 434 } |
| 435 // Add context. |
| 436 locations.AddParam(regloc(kContextRegister)); |
| 437 types.AddParam(MachineType::AnyTagged()); |
| 438 |
| 439 // The target for interpreter dispatches is a code entry address. |
| 440 MachineType target_type = MachineType::Pointer(); |
| 441 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
| 442 return new (zone) CallDescriptor( // -- |
| 443 CallDescriptor::kCallAddress, // kind |
| 444 target_type, // target MachineType |
| 445 target_loc, // target location |
| 446 types.Build(), // machine_sig |
| 447 locations.Build(), // location_sig |
| 448 stack_parameter_count, // stack_parameter_count |
| 449 Operator::kNoProperties, // properties |
| 450 kNoCalleeSaved, // callee-saved registers |
| 451 kNoCalleeSaved, // callee-saved fp |
| 452 CallDescriptor::kCanUseRoots | // flags |
| 453 CallDescriptor::kSupportsTailCalls, // flags |
| 454 descriptor.DebugName(isolate)); |
| 455 } |
407 | 456 |
408 LinkageLocation Linkage::GetOsrValueLocation(int index) const { | 457 LinkageLocation Linkage::GetOsrValueLocation(int index) const { |
409 CHECK(incoming_->IsJSFunctionCall()); | 458 CHECK(incoming_->IsJSFunctionCall()); |
410 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 459 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
411 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 460 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
412 | 461 |
413 if (index == kOsrContextSpillSlotIndex) { | 462 if (index == kOsrContextSpillSlotIndex) { |
414 // Context. Use the parameter location of the context spill slot. | 463 // Context. Use the parameter location of the context spill slot. |
415 // Parameter (arity + 2) is special for the context of the function frame. | 464 // Parameter (arity + 2) is special for the context of the function frame. |
416 // >> context_index = target + receiver + params + new_target + #args | 465 // >> context_index = target + receiver + params + new_target + #args |
(...skipping 28 matching lines...) Expand all Loading... |
445 } else { | 494 } else { |
446 DCHECK(loc == regloc(kContextRegister)); | 495 DCHECK(loc == regloc(kContextRegister)); |
447 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); | 496 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); |
448 } | 497 } |
449 } | 498 } |
450 | 499 |
451 | 500 |
452 } // namespace compiler | 501 } // namespace compiler |
453 } // namespace internal | 502 } // namespace internal |
454 } // namespace v8 | 503 } // namespace v8 |
OLD | NEW |