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