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 ------------- |
| 5511 // -- rsp[0] : return address |
| 5512 // -- rsp[8] : name |
| 5513 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ |
| 5514 // -- ... |
| 5515 // -- r8 : api_function_address |
| 5516 // ----------------------------------- |
| 5517 |
5510 #if defined(__MINGW64__) || defined(_WIN64) | 5518 #if defined(__MINGW64__) || defined(_WIN64) |
5511 Register getter_arg = r8; | 5519 Register getter_arg = r8; |
5512 Register accessor_info_arg = rdx; | 5520 Register accessor_info_arg = rdx; |
5513 Register name_arg = rcx; | 5521 Register name_arg = rcx; |
5514 #else | 5522 #else |
5515 Register getter_arg = rdx; | 5523 Register getter_arg = rdx; |
5516 Register accessor_info_arg = rsi; | 5524 Register accessor_info_arg = rsi; |
5517 Register name_arg = rdi; | 5525 Register name_arg = rdi; |
5518 #endif | 5526 #endif |
5519 Register api_function_address = r8; | 5527 Register api_function_address = ApiGetterDescriptor::function_address(); |
5520 Register receiver = ApiGetterDescriptor::ReceiverRegister(); | 5528 DCHECK(api_function_address.is(r8)); |
5521 Register holder = ApiGetterDescriptor::HolderRegister(); | |
5522 Register callback = ApiGetterDescriptor::CallbackRegister(); | |
5523 Register scratch = rax; | 5529 Register scratch = rax; |
5524 DCHECK(!AreAliased(receiver, holder, callback, scratch)); | |
5525 | |
5526 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property | |
5527 // name below the exit frame to make GC aware of them. | |
5528 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); | |
5529 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); | |
5530 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); | |
5531 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); | |
5532 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); | |
5533 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); | |
5534 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); | |
5535 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); | |
5536 | |
5537 // Insert additional parameters into the stack frame above return address. | |
5538 __ PopReturnAddressTo(scratch); | |
5539 __ Push(receiver); | |
5540 __ Push(FieldOperand(callback, AccessorInfo::kDataOffset)); | |
5541 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | |
5542 __ Push(kScratchRegister); // return value | |
5543 __ Push(kScratchRegister); // return value default | |
5544 __ PushAddress(ExternalReference::isolate_address(isolate())); | |
5545 __ Push(holder); | |
5546 __ Push(Smi::FromInt(0)); // should_throw_on_error -> false | |
5547 __ Push(FieldOperand(callback, AccessorInfo::kNameOffset)); | |
5548 __ PushReturnAddressFrom(scratch); | |
5549 | 5530 |
5550 // v8::PropertyCallbackInfo::args_ array and name handle. | 5531 // v8::PropertyCallbackInfo::args_ array and name handle. |
5551 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 5532 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
5552 | 5533 |
5553 // Allocate v8::PropertyCallbackInfo in non-GCed stack space. | 5534 // Allocate v8::PropertyCallbackInfo in non-GCed stack space. |
5554 const int kArgStackSpace = 1; | 5535 const int kArgStackSpace = 1; |
5555 | 5536 |
5556 // Load address of v8::PropertyAccessorInfo::args_ array. | 5537 // Load address of v8::PropertyAccessorInfo::args_ array. |
5557 __ leap(scratch, Operand(rsp, 2 * kPointerSize)); | 5538 __ leap(scratch, Operand(rsp, 2 * kPointerSize)); |
5558 | 5539 |
5559 PrepareCallApiFunction(masm, kArgStackSpace); | 5540 PrepareCallApiFunction(masm, kArgStackSpace); |
5560 // Create v8::PropertyCallbackInfo object on the stack and initialize | 5541 // Create v8::PropertyCallbackInfo object on the stack and initialize |
5561 // it's args_ field. | 5542 // it's args_ field. |
5562 Operand info_object = StackSpaceOperand(0); | 5543 Operand info_object = StackSpaceOperand(0); |
5563 __ movp(info_object, scratch); | 5544 __ movp(info_object, scratch); |
5564 | 5545 |
5565 __ leap(name_arg, Operand(scratch, -kPointerSize)); | 5546 __ leap(name_arg, Operand(scratch, -kPointerSize)); |
5566 // The context register (rsi) has been saved in PrepareCallApiFunction and | 5547 // The context register (rsi) has been saved in PrepareCallApiFunction and |
5567 // could be used to pass arguments. | 5548 // could be used to pass arguments. |
5568 __ leap(accessor_info_arg, info_object); | 5549 __ leap(accessor_info_arg, info_object); |
5569 | 5550 |
5570 ExternalReference thunk_ref = | 5551 ExternalReference thunk_ref = |
5571 ExternalReference::invoke_accessor_getter_callback(isolate()); | 5552 ExternalReference::invoke_accessor_getter_callback(isolate()); |
5572 | 5553 |
5573 // It's okay if api_function_address == getter_arg | 5554 // It's okay if api_function_address == getter_arg |
5574 // but not accessor_info_arg or name_arg | 5555 // but not accessor_info_arg or name_arg |
5575 DCHECK(!api_function_address.is(accessor_info_arg)); | 5556 DCHECK(!api_function_address.is(accessor_info_arg) && |
5576 DCHECK(!api_function_address.is(name_arg)); | 5557 !api_function_address.is(name_arg)); |
5577 __ movp(scratch, FieldOperand(callback, AccessorInfo::kJsGetterOffset)); | |
5578 __ movp(api_function_address, | |
5579 FieldOperand(scratch, Foreign::kForeignAddressOffset)); | |
5580 | 5558 |
5581 // +3 is to skip prolog, return address and name handle. | 5559 // +3 is to skip prolog, return address and name handle. |
5582 Operand return_value_operand( | 5560 Operand return_value_operand( |
5583 rbp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5561 rbp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
5584 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, | 5562 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, |
5585 kStackUnwindSpace, nullptr, return_value_operand, | 5563 kStackUnwindSpace, nullptr, return_value_operand, |
5586 NULL); | 5564 NULL); |
5587 } | 5565 } |
5588 | 5566 |
5589 namespace { | 5567 namespace { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5749 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, | 5727 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, |
5750 &u8); | 5728 &u8); |
5751 } | 5729 } |
5752 | 5730 |
5753 #undef __ | 5731 #undef __ |
5754 | 5732 |
5755 } // namespace internal | 5733 } // namespace internal |
5756 } // namespace v8 | 5734 } // namespace v8 |
5757 | 5735 |
5758 #endif // V8_TARGET_ARCH_X64 | 5736 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |