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/api-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 // -- rbx : call_data | 2643 // -- rbx : call_data |
2644 // -- rcx : holder | 2644 // -- rcx : holder |
2645 // -- rdx : api_function_address | 2645 // -- rdx : api_function_address |
2646 // -- rsi : context | 2646 // -- rsi : context |
2647 // -- rax : number of arguments if argc is a register | 2647 // -- rax : number of arguments if argc is a register |
2648 // -- rsp[0] : return address | 2648 // -- rsp[0] : return address |
2649 // -- rsp[8] : last argument | 2649 // -- rsp[8] : last argument |
2650 // -- ... | 2650 // -- ... |
2651 // -- rsp[argc * 8] : first argument | 2651 // -- rsp[argc * 8] : first argument |
2652 // -- rsp[(argc + 1) * 8] : receiver | 2652 // -- rsp[(argc + 1) * 8] : receiver |
2653 // -- rsp[(argc + 2) * 8] : accessor_holder | |
2654 // ----------------------------------- | 2653 // ----------------------------------- |
2655 | 2654 |
2656 Register callee = rdi; | 2655 Register callee = rdi; |
2657 Register call_data = rbx; | 2656 Register call_data = rbx; |
2658 Register holder = rcx; | 2657 Register holder = rcx; |
2659 Register api_function_address = rdx; | 2658 Register api_function_address = rdx; |
2660 Register context = rsi; | 2659 Register context = rsi; |
2661 Register return_address = r8; | 2660 Register return_address = r8; |
2662 | 2661 |
2663 typedef FunctionCallbackArguments FCA; | 2662 typedef FunctionCallbackArguments FCA; |
(...skipping 26 matching lines...) Expand all Loading... |
2690 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2689 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2691 // return value default | 2690 // return value default |
2692 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2691 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2693 // isolate | 2692 // isolate |
2694 Register scratch = call_data; | 2693 Register scratch = call_data; |
2695 __ Move(scratch, ExternalReference::isolate_address(masm->isolate())); | 2694 __ Move(scratch, ExternalReference::isolate_address(masm->isolate())); |
2696 __ Push(scratch); | 2695 __ Push(scratch); |
2697 // holder | 2696 // holder |
2698 __ Push(holder); | 2697 __ Push(holder); |
2699 | 2698 |
2700 // enter a new context | |
2701 int argc = this->argc(); | |
2702 if (this->is_lazy()) { | |
2703 // load context from accessor_holder | |
2704 Register accessor_holder = context; | |
2705 __ movp(accessor_holder, | |
2706 MemOperand(rsp, (argc + FCA::kArgsLength + 1) * kPointerSize)); | |
2707 __ movp(scratch, FieldOperand(accessor_holder, HeapObject::kMapOffset)); | |
2708 __ GetMapConstructor(scratch, scratch, context); | |
2709 __ movp(context, FieldOperand(scratch, JSFunction::kContextOffset)); | |
2710 } else { | |
2711 // load context from callee | |
2712 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); | |
2713 } | |
2714 | |
2715 __ movp(scratch, rsp); | 2699 __ movp(scratch, rsp); |
2716 // Push return address back on stack. | 2700 // Push return address back on stack. |
2717 __ PushReturnAddressFrom(return_address); | 2701 __ PushReturnAddressFrom(return_address); |
2718 | 2702 |
| 2703 if (!this->is_lazy()) { |
| 2704 // load context from callee |
| 2705 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); |
| 2706 } |
| 2707 |
2719 // Allocate the v8::Arguments structure in the arguments' space since | 2708 // Allocate the v8::Arguments structure in the arguments' space since |
2720 // it's not controlled by GC. | 2709 // it's not controlled by GC. |
2721 const int kApiStackSpace = 3; | 2710 const int kApiStackSpace = 3; |
2722 | 2711 |
2723 PrepareCallApiFunction(masm, kApiStackSpace); | 2712 PrepareCallApiFunction(masm, kApiStackSpace); |
2724 | 2713 |
2725 // FunctionCallbackInfo::implicit_args_. | 2714 // FunctionCallbackInfo::implicit_args_. |
| 2715 int argc = this->argc(); |
2726 __ movp(StackSpaceOperand(0), scratch); | 2716 __ movp(StackSpaceOperand(0), scratch); |
2727 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); | 2717 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); |
2728 // FunctionCallbackInfo::values_. | 2718 // FunctionCallbackInfo::values_. |
2729 __ movp(StackSpaceOperand(1), scratch); | 2719 __ movp(StackSpaceOperand(1), scratch); |
2730 // FunctionCallbackInfo::length_. | 2720 // FunctionCallbackInfo::length_. |
2731 __ Set(StackSpaceOperand(2), argc); | 2721 __ Set(StackSpaceOperand(2), argc); |
2732 | 2722 |
2733 #if defined(__MINGW64__) || defined(_WIN64) | 2723 #if defined(__MINGW64__) || defined(_WIN64) |
2734 Register arguments_arg = rcx; | 2724 Register arguments_arg = rcx; |
2735 Register callback_arg = rdx; | 2725 Register callback_arg = rdx; |
(...skipping 10 matching lines...) Expand all Loading... |
2746 __ leap(arguments_arg, StackSpaceOperand(0)); | 2736 __ leap(arguments_arg, StackSpaceOperand(0)); |
2747 | 2737 |
2748 ExternalReference thunk_ref = | 2738 ExternalReference thunk_ref = |
2749 ExternalReference::invoke_function_callback(masm->isolate()); | 2739 ExternalReference::invoke_function_callback(masm->isolate()); |
2750 | 2740 |
2751 // Accessor for FunctionCallbackInfo and first js arg. | 2741 // Accessor for FunctionCallbackInfo and first js arg. |
2752 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1, | 2742 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1, |
2753 ARGUMENTS_DONT_CONTAIN_RECEIVER); | 2743 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
2754 Operand context_restore_operand = args_from_rbp.GetArgumentOperand( | 2744 Operand context_restore_operand = args_from_rbp.GetArgumentOperand( |
2755 FCA::kArgsLength - FCA::kContextSaveIndex); | 2745 FCA::kArgsLength - FCA::kContextSaveIndex); |
| 2746 Operand length_operand = StackSpaceOperand(2); |
2756 Operand return_value_operand = args_from_rbp.GetArgumentOperand( | 2747 Operand return_value_operand = args_from_rbp.GetArgumentOperand( |
2757 this->is_store() ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset); | 2748 this->is_store() ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset); |
2758 const int stack_space = argc + FCA::kArgsLength + 2; | 2749 int stack_space = 0; |
2759 Operand* stack_space_operand = nullptr; | 2750 Operand* stack_space_operand = &length_operand; |
| 2751 stack_space = argc + FCA::kArgsLength + 1; |
| 2752 stack_space_operand = nullptr; |
2760 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, | 2753 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, |
2761 stack_space, stack_space_operand, | 2754 stack_space, stack_space_operand, |
2762 return_value_operand, &context_restore_operand); | 2755 return_value_operand, &context_restore_operand); |
2763 } | 2756 } |
2764 | 2757 |
2765 | 2758 |
2766 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 2759 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
2767 #if defined(__MINGW64__) || defined(_WIN64) | 2760 #if defined(__MINGW64__) || defined(_WIN64) |
2768 Register getter_arg = r8; | 2761 Register getter_arg = r8; |
2769 Register accessor_info_arg = rdx; | 2762 Register accessor_info_arg = rdx; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2842 kStackUnwindSpace, nullptr, return_value_operand, | 2835 kStackUnwindSpace, nullptr, return_value_operand, |
2843 NULL); | 2836 NULL); |
2844 } | 2837 } |
2845 | 2838 |
2846 #undef __ | 2839 #undef __ |
2847 | 2840 |
2848 } // namespace internal | 2841 } // namespace internal |
2849 } // namespace v8 | 2842 } // namespace v8 |
2850 | 2843 |
2851 #endif // V8_TARGET_ARCH_X64 | 2844 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |