Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 5489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5500 Operand* stack_space_operand = &is_construct_call_operand; | 5500 Operand* stack_space_operand = &is_construct_call_operand; |
| 5501 stack_space = argc + FCA::kArgsLength + 1; | 5501 stack_space = argc + FCA::kArgsLength + 1; |
| 5502 stack_space_operand = nullptr; | 5502 stack_space_operand = nullptr; |
| 5503 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, | 5503 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, |
| 5504 stack_space, stack_space_operand, | 5504 stack_space, stack_space_operand, |
| 5505 return_value_operand, &context_restore_operand); | 5505 return_value_operand, &context_restore_operand); |
| 5506 } | 5506 } |
| 5507 | 5507 |
| 5508 | 5508 |
| 5509 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5509 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
| 5510 // ----------- S t a t e ------------- | 5510 // ----------- S t a t e ------------- |
|
Jakob Kummerow
2016/04/18 13:22:35
nit: outdated comment
| |
| 5511 // -- rsp[0] : return address | 5511 // -- rsp[0] : return address |
| 5512 // -- rsp[8] : name | 5512 // -- rsp[8] : name |
| 5513 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ | 5513 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ |
| 5514 // -- ... | 5514 // -- ... |
| 5515 // -- r8 : api_function_address | 5515 // -- r8 : api_function_address |
| 5516 // ----------------------------------- | 5516 // ----------------------------------- |
| 5517 | 5517 |
| 5518 #if defined(__MINGW64__) || defined(_WIN64) | 5518 #if defined(__MINGW64__) || defined(_WIN64) |
| 5519 Register getter_arg = r8; | 5519 Register getter_arg = r8; |
| 5520 Register accessor_info_arg = rdx; | 5520 Register accessor_info_arg = rdx; |
| 5521 Register name_arg = rcx; | 5521 Register name_arg = rcx; |
| 5522 #else | 5522 #else |
| 5523 Register getter_arg = rdx; | 5523 Register getter_arg = rdx; |
| 5524 Register accessor_info_arg = rsi; | 5524 Register accessor_info_arg = rsi; |
| 5525 Register name_arg = rdi; | 5525 Register name_arg = rdi; |
| 5526 #endif | 5526 #endif |
| 5527 Register api_function_address = ApiGetterDescriptor::function_address(); | 5527 Register api_function_address = r8; |
| 5528 DCHECK(api_function_address.is(r8)); | 5528 Register receiver = ApiGetterDescriptor::ReceiverRegister(); |
| 5529 Register holder = ApiGetterDescriptor::HolderRegister(); | |
| 5530 Register callback = ApiGetterDescriptor::CallbackRegister(); | |
| 5529 Register scratch = rax; | 5531 Register scratch = rax; |
|
Jakob Kummerow
2016/04/18 13:22:35
I can haz DCHECK(!AreAliased(...))?
| |
| 5530 | 5532 |
| 5533 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property | |
| 5534 // name below the exit frame to make GC aware of them. | |
| 5535 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); | |
| 5536 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); | |
| 5537 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); | |
| 5538 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); | |
| 5539 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); | |
| 5540 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); | |
| 5541 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); | |
| 5542 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); | |
| 5543 | |
| 5544 // Insert additional parameters into the stack frame above return address. | |
| 5545 __ PopReturnAddressTo(scratch); | |
| 5546 __ Push(receiver); | |
| 5547 __ Push(FieldOperand(callback, AccessorInfo::kDataOffset)); | |
| 5548 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | |
| 5549 __ Push(kScratchRegister); // return value | |
| 5550 __ Push(kScratchRegister); // return value default | |
| 5551 __ PushAddress(ExternalReference::isolate_address(isolate())); | |
| 5552 __ Push(holder); | |
| 5553 __ Push(Smi::FromInt(0)); // should_throw_on_error -> false | |
| 5554 __ Push(FieldOperand(callback, AccessorInfo::kNameOffset)); | |
| 5555 __ PushReturnAddressFrom(scratch); | |
| 5556 | |
| 5531 // v8::PropertyCallbackInfo::args_ array and name handle. | 5557 // v8::PropertyCallbackInfo::args_ array and name handle. |
| 5532 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 5558 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
| 5533 | 5559 |
| 5534 // Allocate v8::PropertyCallbackInfo in non-GCed stack space. | 5560 // Allocate v8::PropertyCallbackInfo in non-GCed stack space. |
| 5535 const int kArgStackSpace = 1; | 5561 const int kArgStackSpace = 1; |
| 5536 | 5562 |
| 5537 // Load address of v8::PropertyAccessorInfo::args_ array. | 5563 // Load address of v8::PropertyAccessorInfo::args_ array. |
| 5538 __ leap(scratch, Operand(rsp, 2 * kPointerSize)); | 5564 __ leap(scratch, Operand(rsp, 2 * kPointerSize)); |
| 5539 | 5565 |
| 5540 PrepareCallApiFunction(masm, kArgStackSpace); | 5566 PrepareCallApiFunction(masm, kArgStackSpace); |
| 5541 // Create v8::PropertyCallbackInfo object on the stack and initialize | 5567 // Create v8::PropertyCallbackInfo object on the stack and initialize |
| 5542 // it's args_ field. | 5568 // it's args_ field. |
| 5543 Operand info_object = StackSpaceOperand(0); | 5569 Operand info_object = StackSpaceOperand(0); |
| 5544 __ movp(info_object, scratch); | 5570 __ movp(info_object, scratch); |
| 5545 | 5571 |
| 5546 __ leap(name_arg, Operand(scratch, -kPointerSize)); | 5572 __ leap(name_arg, Operand(scratch, -kPointerSize)); |
| 5547 // The context register (rsi) has been saved in PrepareCallApiFunction and | 5573 // The context register (rsi) has been saved in PrepareCallApiFunction and |
| 5548 // could be used to pass arguments. | 5574 // could be used to pass arguments. |
| 5549 __ leap(accessor_info_arg, info_object); | 5575 __ leap(accessor_info_arg, info_object); |
| 5550 | 5576 |
| 5551 ExternalReference thunk_ref = | 5577 ExternalReference thunk_ref = |
| 5552 ExternalReference::invoke_accessor_getter_callback(isolate()); | 5578 ExternalReference::invoke_accessor_getter_callback(isolate()); |
| 5553 | 5579 |
| 5554 // It's okay if api_function_address == getter_arg | 5580 // It's okay if api_function_address == getter_arg |
| 5555 // but not accessor_info_arg or name_arg | 5581 // but not accessor_info_arg or name_arg |
| 5556 DCHECK(!api_function_address.is(accessor_info_arg) && | 5582 DCHECK(!api_function_address.is(accessor_info_arg)); |
| 5557 !api_function_address.is(name_arg)); | 5583 DCHECK(!api_function_address.is(name_arg)); |
| 5584 __ movp(scratch, FieldOperand(callback, AccessorInfo::kGetterOffset)); | |
| 5585 __ movp(api_function_address, | |
| 5586 FieldOperand(scratch, Foreign::kForeignAddressOffset)); | |
| 5558 | 5587 |
| 5559 // +3 is to skip prolog, return address and name handle. | 5588 // +3 is to skip prolog, return address and name handle. |
| 5560 Operand return_value_operand( | 5589 Operand return_value_operand( |
| 5561 rbp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5590 rbp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
| 5562 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, | 5591 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, |
| 5563 kStackUnwindSpace, nullptr, return_value_operand, | 5592 kStackUnwindSpace, nullptr, return_value_operand, |
| 5564 NULL); | 5593 NULL); |
| 5565 } | 5594 } |
| 5566 | 5595 |
| 5567 namespace { | 5596 namespace { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5727 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, | 5756 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, |
| 5728 &u8); | 5757 &u8); |
| 5729 } | 5758 } |
| 5730 | 5759 |
| 5731 #undef __ | 5760 #undef __ |
| 5732 | 5761 |
| 5733 } // namespace internal | 5762 } // namespace internal |
| 5734 } // namespace v8 | 5763 } // namespace v8 |
| 5735 | 5764 |
| 5736 #endif // V8_TARGET_ARCH_X64 | 5765 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |