OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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 2865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 void CallApiCallbackStub::Generate(MacroAssembler* masm) { | 2876 void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
2877 // ----------- S t a t e ------------- | 2877 // ----------- S t a t e ------------- |
2878 // -- a0 : callee | 2878 // -- a0 : callee |
2879 // -- a4 : call_data | 2879 // -- a4 : call_data |
2880 // -- a2 : holder | 2880 // -- a2 : holder |
2881 // -- a1 : api_function_address | 2881 // -- a1 : api_function_address |
2882 // -- cp : context | 2882 // -- cp : context |
2883 // -- | 2883 // -- |
2884 // -- sp[0] : last argument | 2884 // -- sp[0] : last argument |
2885 // -- ... | 2885 // -- ... |
2886 // -- sp[(argc - 1)* 8] : first argument | 2886 // -- sp[(argc - 1) * 8] : first argument |
2887 // -- sp[argc * 8] : receiver | 2887 // -- sp[argc * 8] : receiver |
| 2888 // -- sp[(argc + 1) * 8] : accessor_holder |
2888 // ----------------------------------- | 2889 // ----------------------------------- |
2889 | 2890 |
2890 Register callee = a0; | 2891 Register callee = a0; |
2891 Register call_data = a4; | 2892 Register call_data = a4; |
2892 Register holder = a2; | 2893 Register holder = a2; |
2893 Register api_function_address = a1; | 2894 Register api_function_address = a1; |
2894 Register context = cp; | 2895 Register context = cp; |
2895 | 2896 |
2896 typedef FunctionCallbackArguments FCA; | 2897 typedef FunctionCallbackArguments FCA; |
2897 | 2898 |
2898 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 2899 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
2899 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 2900 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
2900 STATIC_ASSERT(FCA::kDataIndex == 4); | 2901 STATIC_ASSERT(FCA::kDataIndex == 4); |
2901 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 2902 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
2902 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 2903 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
2903 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 2904 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
2904 STATIC_ASSERT(FCA::kHolderIndex == 0); | 2905 STATIC_ASSERT(FCA::kHolderIndex == 0); |
2905 STATIC_ASSERT(FCA::kNewTargetIndex == 7); | 2906 STATIC_ASSERT(FCA::kNewTargetIndex == 7); |
2906 STATIC_ASSERT(FCA::kArgsLength == 8); | 2907 STATIC_ASSERT(FCA::kArgsLength == 8); |
2907 | 2908 |
2908 // new target | 2909 // new target |
2909 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2910 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2910 | 2911 |
2911 // Save context, callee and call data. | 2912 // Save context, callee and call data. |
2912 __ Push(context, callee, call_data); | 2913 __ Push(context, callee, call_data); |
2913 if (!is_lazy()) { | |
2914 // Load context from callee. | |
2915 __ Ld(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | |
2916 } | |
2917 | 2914 |
2918 Register scratch = call_data; | 2915 Register scratch = call_data; |
2919 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 2916 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
2920 // Push return value and default return value. | 2917 // Push return value and default return value. |
2921 __ Push(scratch, scratch); | 2918 __ Push(scratch, scratch); |
2922 __ li(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); | 2919 __ li(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); |
2923 // Push isolate and holder. | 2920 // Push isolate and holder. |
2924 __ Push(scratch, holder); | 2921 __ Push(scratch, holder); |
2925 | 2922 |
| 2923 // Enter a new context |
| 2924 if (is_lazy()) { |
| 2925 // Load context from accessor_holder |
| 2926 Register accessor_holder = context; |
| 2927 __ Ld(accessor_holder, |
| 2928 MemOperand(sp, (FCA::kArgsLength + 1 + argc()) * kPointerSize)); |
| 2929 __ Ld(scratch, FieldMemOperand(accessor_holder, HeapObject::kMapOffset)); |
| 2930 __ GetMapConstructor(scratch, scratch, context, callee); |
| 2931 __ Ld(context, FieldMemOperand(scratch, JSFunction::kContextOffset)); |
| 2932 } else { |
| 2933 // Load context from callee. |
| 2934 __ Ld(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
| 2935 } |
| 2936 |
2926 // Prepare arguments. | 2937 // Prepare arguments. |
2927 __ mov(scratch, sp); | 2938 __ mov(scratch, sp); |
2928 | 2939 |
2929 // Allocate the v8::Arguments structure in the arguments' space since | 2940 // Allocate the v8::Arguments structure in the arguments' space since |
2930 // it's not controlled by GC. | 2941 // it's not controlled by GC. |
2931 const int kApiStackSpace = 3; | 2942 const int kApiStackSpace = 3; |
2932 | 2943 |
2933 FrameScope frame_scope(masm, StackFrame::MANUAL); | 2944 FrameScope frame_scope(masm, StackFrame::MANUAL); |
2934 __ EnterExitFrame(false, kApiStackSpace); | 2945 __ EnterExitFrame(false, kApiStackSpace); |
2935 | 2946 |
(...skipping 20 matching lines...) Expand all Loading... |
2956 MemOperand context_restore_operand( | 2967 MemOperand context_restore_operand( |
2957 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 2968 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
2958 // Stores return the first js argument. | 2969 // Stores return the first js argument. |
2959 int return_value_offset = 0; | 2970 int return_value_offset = 0; |
2960 if (is_store()) { | 2971 if (is_store()) { |
2961 return_value_offset = 2 + FCA::kArgsLength; | 2972 return_value_offset = 2 + FCA::kArgsLength; |
2962 } else { | 2973 } else { |
2963 return_value_offset = 2 + FCA::kReturnValueOffset; | 2974 return_value_offset = 2 + FCA::kReturnValueOffset; |
2964 } | 2975 } |
2965 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 2976 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
2966 int stack_space = 0; | 2977 const int stack_space = argc() + FCA::kArgsLength + 2; |
2967 int32_t stack_space_offset = 3 * kPointerSize; | |
2968 stack_space = argc() + FCA::kArgsLength + 1; | |
2969 // TODO(adamk): Why are we clobbering this immediately? | 2978 // TODO(adamk): Why are we clobbering this immediately? |
2970 stack_space_offset = kInvalidStackOffset; | 2979 const int32_t stack_space_offset = kInvalidStackOffset; |
2971 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, | 2980 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
2972 stack_space_offset, return_value_operand, | 2981 stack_space_offset, return_value_operand, |
2973 &context_restore_operand); | 2982 &context_restore_operand); |
2974 } | 2983 } |
2975 | 2984 |
2976 | 2985 |
2977 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 2986 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
2978 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property | 2987 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property |
2979 // name below the exit frame to make GC aware of them. | 2988 // name below the exit frame to make GC aware of them. |
2980 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); | 2989 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3045 kStackUnwindSpace, kInvalidStackOffset, | 3054 kStackUnwindSpace, kInvalidStackOffset, |
3046 return_value_operand, NULL); | 3055 return_value_operand, NULL); |
3047 } | 3056 } |
3048 | 3057 |
3049 #undef __ | 3058 #undef __ |
3050 | 3059 |
3051 } // namespace internal | 3060 } // namespace internal |
3052 } // namespace v8 | 3061 } // namespace v8 |
3053 | 3062 |
3054 #endif // V8_TARGET_ARCH_MIPS64 | 3063 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |