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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 | 1193 |
1194 __ bind(&stack_overflow); | 1194 __ bind(&stack_overflow); |
1195 { | 1195 { |
1196 __ TailCallRuntime(Runtime::kThrowStackOverflow); | 1196 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
1197 __ Unreachable(); | 1197 __ Unreachable(); |
1198 } | 1198 } |
1199 } | 1199 } |
1200 | 1200 |
1201 // static | 1201 // static |
1202 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1202 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
1203 MacroAssembler* masm, CallableType construct_type) { | 1203 MacroAssembler* masm, PushArgsConstructMode mode) { |
1204 // ----------- S t a t e ------------- | 1204 // ----------- S t a t e ------------- |
1205 // -- x0 : argument count (not including receiver) | 1205 // -- x0 : argument count (not including receiver) |
1206 // -- x3 : new target | 1206 // -- x3 : new target |
1207 // -- x1 : constructor to call | 1207 // -- x1 : constructor to call |
1208 // -- x2 : allocation site feedback if available, undefined otherwise | 1208 // -- x2 : allocation site feedback if available, undefined otherwise |
1209 // -- x4 : address of the first argument | 1209 // -- x4 : address of the first argument |
1210 // ----------------------------------- | 1210 // ----------------------------------- |
1211 Label stack_overflow; | 1211 Label stack_overflow; |
1212 | 1212 |
1213 // Push a slot for the receiver. | 1213 // Push a slot for the receiver. |
1214 __ Push(xzr); | 1214 __ Push(xzr); |
1215 | 1215 |
1216 // Push the arguments. x5, x4, x6, x7 will be modified. | 1216 // Push the arguments. x5, x4, x6, x7 will be modified. |
1217 Generate_InterpreterPushArgs(masm, x0, x4, x5, x6, x7, &stack_overflow); | 1217 Generate_InterpreterPushArgs(masm, x0, x4, x5, x6, x7, &stack_overflow); |
1218 | 1218 |
1219 __ AssertUndefinedOrAllocationSite(x2, x6); | 1219 __ AssertUndefinedOrAllocationSite(x2, x6); |
1220 if (construct_type == CallableType::kJSFunction) { | 1220 if (mode == PushArgsConstructMode::kJSFunction) { |
1221 __ AssertFunction(x1); | 1221 __ AssertFunction(x1); |
1222 | 1222 |
1223 // Tail call to the function-specific construct stub (still in the caller | 1223 // Tail call to the function-specific construct stub (still in the caller |
1224 // context at this point). | 1224 // context at this point). |
1225 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 1225 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
1226 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); | 1226 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); |
1227 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); | 1227 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); |
1228 __ Br(x4); | 1228 __ Br(x4); |
| 1229 } else if (mode == PushArgsConstructMode::kWithFinalSpread) { |
| 1230 // Call the constructor with x0, x1, and x3 unmodified. |
| 1231 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), |
| 1232 RelocInfo::CODE_TARGET); |
1229 } else { | 1233 } else { |
1230 DCHECK_EQ(construct_type, CallableType::kAny); | 1234 DCHECK_EQ(PushArgsConstructMode::kOther, mode); |
1231 // Call the constructor with x0, x1, and x3 unmodified. | 1235 // Call the constructor with x0, x1, and x3 unmodified. |
1232 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1236 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1233 } | 1237 } |
1234 | 1238 |
1235 __ bind(&stack_overflow); | 1239 __ bind(&stack_overflow); |
1236 { | 1240 { |
1237 __ TailCallRuntime(Runtime::kThrowStackOverflow); | 1241 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
1238 __ Unreachable(); | 1242 __ Unreachable(); |
1239 } | 1243 } |
1240 } | 1244 } |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2799 } | 2803 } |
2800 | 2804 |
2801 // Called Construct on an Object that doesn't have a [[Construct]] internal | 2805 // Called Construct on an Object that doesn't have a [[Construct]] internal |
2802 // method. | 2806 // method. |
2803 __ bind(&non_constructor); | 2807 __ bind(&non_constructor); |
2804 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), | 2808 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), |
2805 RelocInfo::CODE_TARGET); | 2809 RelocInfo::CODE_TARGET); |
2806 } | 2810 } |
2807 | 2811 |
2808 // static | 2812 // static |
| 2813 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) { |
| 2814 // ----------- S t a t e ------------- |
| 2815 // -- x0 : the number of arguments (not including the receiver) |
| 2816 // -- x1 : the constructor to call (can be any Object) |
| 2817 // -- x3 : the new target (either the same as the constructor or |
| 2818 // the JSFunction on which new was invoked initially) |
| 2819 // ----------------------------------- |
| 2820 |
| 2821 Register argc = x0; |
| 2822 Register constructor = x1; |
| 2823 Register new_target = x3; |
| 2824 |
| 2825 Register scratch = x2; |
| 2826 Register scratch2 = x6; |
| 2827 |
| 2828 Register spread = x4; |
| 2829 Register spread_map = x5; |
| 2830 __ Peek(spread, 0); |
| 2831 __ Ldr(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset)); |
| 2832 |
| 2833 Label runtime_call, push_args; |
| 2834 // Check that the spread is an array. |
| 2835 __ CompareInstanceType(spread_map, scratch, JS_ARRAY_TYPE); |
| 2836 __ B(ne, &runtime_call); |
| 2837 |
| 2838 // Check that we have the original ArrayPrototype. |
| 2839 __ Ldr(scratch, FieldMemOperand(spread_map, Map::kPrototypeOffset)); |
| 2840 __ Ldr(scratch2, NativeContextMemOperand()); |
| 2841 __ Ldr(scratch2, |
| 2842 ContextMemOperand(scratch2, Context::INITIAL_ARRAY_PROTOTYPE_INDEX)); |
| 2843 __ Cmp(scratch, scratch2); |
| 2844 __ B(ne, &runtime_call); |
| 2845 |
| 2846 // Check that the ArrayPrototype hasn't been modified in a way that would |
| 2847 // affect iteration. |
| 2848 __ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex); |
| 2849 __ Ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); |
| 2850 __ Cmp(scratch, Smi::FromInt(Isolate::kProtectorValid)); |
| 2851 __ B(ne, &runtime_call); |
| 2852 |
| 2853 // Check that the map of the initial array iterator hasn't changed. |
| 2854 __ Ldr(scratch2, NativeContextMemOperand()); |
| 2855 __ Ldr(scratch, |
| 2856 ContextMemOperand(scratch2, |
| 2857 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX)); |
| 2858 __ Ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); |
| 2859 __ Ldr(scratch2, |
| 2860 ContextMemOperand( |
| 2861 scratch2, Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_MAP_INDEX)); |
| 2862 __ Cmp(scratch, scratch2); |
| 2863 __ B(ne, &runtime_call); |
| 2864 |
| 2865 // For FastPacked kinds, iteration will have the same effect as simply |
| 2866 // accessing each property in order. |
| 2867 Label no_protector_check; |
| 2868 __ Ldr(scratch, FieldMemOperand(spread_map, Map::kBitField2Offset)); |
| 2869 __ DecodeField<Map::ElementsKindBits>(scratch); |
| 2870 __ Cmp(scratch, LAST_FAST_ELEMENTS_KIND); |
| 2871 __ B(hi, &runtime_call); |
| 2872 // For non-FastHoley kinds, we can skip the protector check. |
| 2873 __ Cmp(scratch, FAST_SMI_ELEMENTS); |
| 2874 __ B(eq, &no_protector_check); |
| 2875 __ Cmp(scratch, FAST_ELEMENTS); |
| 2876 __ B(eq, &no_protector_check); |
| 2877 __ Cmp(scratch, FAST_DOUBLE_ELEMENTS); |
| 2878 __ B(eq, &no_protector_check); |
| 2879 // Check the ArrayProtector cell. |
| 2880 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex); |
| 2881 __ Ldr(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset)); |
| 2882 __ Cmp(scratch, Smi::FromInt(Isolate::kProtectorValid)); |
| 2883 __ B(ne, &runtime_call); |
| 2884 |
| 2885 __ Bind(&no_protector_check); |
| 2886 // Load the FixedArray backing store. |
| 2887 __ Ldr(spread, FieldMemOperand(spread, JSArray::kElementsOffset)); |
| 2888 __ B(&push_args); |
| 2889 |
| 2890 __ Bind(&runtime_call); |
| 2891 { |
| 2892 // Call the builtin for the result of the spread. |
| 2893 FrameScope scope(masm, StackFrame::INTERNAL); |
| 2894 __ SmiTag(argc); |
| 2895 __ Push(constructor, new_target, argc, spread); |
| 2896 __ CallRuntime(Runtime::kSpreadIterableFixed); |
| 2897 __ Mov(spread, x0); |
| 2898 __ Pop(argc, new_target, constructor); |
| 2899 __ SmiUntag(argc); |
| 2900 } |
| 2901 |
| 2902 Register spread_len = x5; |
| 2903 __ Bind(&push_args); |
| 2904 { |
| 2905 // Pop the spread argument off the stack. |
| 2906 __ Pop(scratch); |
| 2907 // Calculate the new nargs including the result of the spread. |
| 2908 __ Ldrsw(spread_len, |
| 2909 UntagSmiFieldMemOperand(spread, FixedArray::kLengthOffset)); |
| 2910 // argc += spread_len - 1. Subtract 1 for the spread itself. |
| 2911 __ Add(argc, argc, spread_len); |
| 2912 __ Sub(argc, argc, 1); |
| 2913 } |
| 2914 |
| 2915 // Check for stack overflow. |
| 2916 { |
| 2917 // Check the stack for overflow. We are not trying to catch interruptions |
| 2918 // (i.e. debug break and preemption) here, so check the "real stack limit". |
| 2919 Label done; |
| 2920 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex); |
| 2921 // Make scratch the space we have left. The stack might already be |
| 2922 // overflowed here which will cause scratch to become negative. |
| 2923 __ Sub(scratch, masm->StackPointer(), scratch); |
| 2924 // Check if the arguments will overflow the stack. |
| 2925 __ Cmp(scratch, Operand(spread_len, LSL, kPointerSizeLog2)); |
| 2926 __ B(gt, &done); // Signed comparison. |
| 2927 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 2928 __ Bind(&done); |
| 2929 } |
| 2930 |
| 2931 // Put the evaluated spread onto the stack as additional arguments. |
| 2932 { |
| 2933 __ Mov(scratch, 0); |
| 2934 Label done, loop; |
| 2935 __ Bind(&loop); |
| 2936 __ Cmp(scratch, spread_len); |
| 2937 __ B(eq, &done); |
| 2938 __ Add(scratch2, spread, Operand(scratch, LSL, kPointerSizeLog2)); |
| 2939 __ Ldr(scratch2, FieldMemOperand(scratch2, FixedArray::kHeaderSize)); |
| 2940 __ Push(scratch2); |
| 2941 __ Add(scratch, scratch, Operand(1)); |
| 2942 __ B(&loop); |
| 2943 __ Bind(&done); |
| 2944 } |
| 2945 |
| 2946 // Dispatch. |
| 2947 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 2948 } |
| 2949 |
| 2950 // static |
2809 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { | 2951 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { |
2810 ASM_LOCATION("Builtins::Generate_AllocateInNewSpace"); | 2952 ASM_LOCATION("Builtins::Generate_AllocateInNewSpace"); |
2811 // ----------- S t a t e ------------- | 2953 // ----------- S t a t e ------------- |
2812 // -- x1 : requested object size (untagged) | 2954 // -- x1 : requested object size (untagged) |
2813 // -- lr : return address | 2955 // -- lr : return address |
2814 // ----------------------------------- | 2956 // ----------------------------------- |
2815 __ SmiTag(x1); | 2957 __ SmiTag(x1); |
2816 __ Push(x1); | 2958 __ Push(x1); |
2817 __ Move(cp, Smi::kZero); | 2959 __ Move(cp, Smi::kZero); |
2818 __ TailCallRuntime(Runtime::kAllocateInNewSpace); | 2960 __ TailCallRuntime(Runtime::kAllocateInNewSpace); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2989 __ Unreachable(); | 3131 __ Unreachable(); |
2990 } | 3132 } |
2991 } | 3133 } |
2992 | 3134 |
2993 #undef __ | 3135 #undef __ |
2994 | 3136 |
2995 } // namespace internal | 3137 } // namespace internal |
2996 } // namespace v8 | 3138 } // namespace v8 |
2997 | 3139 |
2998 #endif // V8_TARGET_ARCH_ARM | 3140 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |