Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Side by Side Diff: src/builtins/mips64/builtins-mips64.cc

Issue 2571563004: [Turbofan] Implement super calls with spread bytecode in assembly code. (Closed)
Patch Set: MIPS64 port Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/mips/builtins-mips.cc ('k') | src/builtins/ppc/builtins-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 __ bind(&stack_overflow); 1180 __ bind(&stack_overflow);
1181 { 1181 {
1182 __ TailCallRuntime(Runtime::kThrowStackOverflow); 1182 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1183 // Unreachable code. 1183 // Unreachable code.
1184 __ break_(0xCC); 1184 __ break_(0xCC);
1185 } 1185 }
1186 } 1186 }
1187 1187
1188 // static 1188 // static
1189 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( 1189 void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
1190 MacroAssembler* masm, CallableType construct_type) { 1190 MacroAssembler* masm, PushArgsConstructMode mode) {
1191 // ----------- S t a t e ------------- 1191 // ----------- S t a t e -------------
1192 // -- a0 : argument count (not including receiver) 1192 // -- a0 : argument count (not including receiver)
1193 // -- a3 : new target 1193 // -- a3 : new target
1194 // -- a1 : constructor to call 1194 // -- a1 : constructor to call
1195 // -- a2 : allocation site feedback if available, undefined otherwise. 1195 // -- a2 : allocation site feedback if available, undefined otherwise.
1196 // -- a4 : address of the first argument 1196 // -- a4 : address of the first argument
1197 // ----------------------------------- 1197 // -----------------------------------
1198 Label stack_overflow; 1198 Label stack_overflow;
1199 1199
1200 // Push a slot for the receiver. 1200 // Push a slot for the receiver.
1201 __ push(zero_reg); 1201 __ push(zero_reg);
1202 1202
1203 // This function modifies t0, a4 and a5. 1203 // This function modifies t0, a4 and a5.
1204 Generate_InterpreterPushArgs(masm, a0, a4, a5, t0, &stack_overflow); 1204 Generate_InterpreterPushArgs(masm, a0, a4, a5, t0, &stack_overflow);
1205 1205
1206 __ AssertUndefinedOrAllocationSite(a2, t0); 1206 __ AssertUndefinedOrAllocationSite(a2, t0);
1207 if (construct_type == CallableType::kJSFunction) { 1207 if (mode == PushArgsConstructMode::kJSFunction) {
1208 __ AssertFunction(a1); 1208 __ AssertFunction(a1);
1209 1209
1210 // Tail call to the function-specific construct stub (still in the caller 1210 // Tail call to the function-specific construct stub (still in the caller
1211 // context at this point). 1211 // context at this point).
1212 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 1212 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1213 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); 1213 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset));
1214 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); 1214 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag));
1215 __ Jump(at); 1215 __ Jump(at);
1216 } else if (mode == PushArgsConstructMode::kWithFinalSpread) {
1217 // Call the constructor with a0, a1, and a3 unmodified.
1218 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(),
1219 RelocInfo::CODE_TARGET);
1216 } else { 1220 } else {
1217 DCHECK_EQ(construct_type, CallableType::kAny); 1221 DCHECK_EQ(PushArgsConstructMode::kOther, mode);
1218 // Call the constructor with a0, a1, and a3 unmodified. 1222 // Call the constructor with a0, a1, and a3 unmodified.
1219 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1223 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1220 } 1224 }
1221 1225
1222 __ bind(&stack_overflow); 1226 __ bind(&stack_overflow);
1223 { 1227 {
1224 __ TailCallRuntime(Runtime::kThrowStackOverflow); 1228 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1225 // Unreachable code. 1229 // Unreachable code.
1226 __ break_(0xCC); 1230 __ break_(0xCC);
1227 } 1231 }
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 } 2815 }
2812 2816
2813 // Called Construct on an Object that doesn't have a [[Construct]] internal 2817 // Called Construct on an Object that doesn't have a [[Construct]] internal
2814 // method. 2818 // method.
2815 __ bind(&non_constructor); 2819 __ bind(&non_constructor);
2816 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), 2820 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
2817 RelocInfo::CODE_TARGET); 2821 RelocInfo::CODE_TARGET);
2818 } 2822 }
2819 2823
2820 // static 2824 // static
2825 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
2826 // ----------- S t a t e -------------
2827 // -- a0 : the number of arguments (not including the receiver)
2828 // -- a1 : the constructor to call (can be any Object)
2829 // -- a3 : the new target (either the same as the constructor or
2830 // the JSFunction on which new was invoked initially)
2831 // -----------------------------------
2832
2833 Register argc = a0;
2834 Register constructor = a1;
2835 Register new_target = a3;
2836
2837 Register scratch = t0;
2838 Register scratch2 = t1;
2839
2840 Register spread = a2;
2841 Register spread_map = a4;
2842
2843 Register native_context = a5;
2844
2845 __ ld(spread, MemOperand(sp, 0));
2846 __ ld(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset));
2847 __ ld(native_context, NativeContextMemOperand());
2848
2849 Label runtime_call, push_args;
2850 // Check that the spread is an array.
2851 __ lbu(scratch, FieldMemOperand(spread_map, Map::kInstanceTypeOffset));
2852 __ Branch(&runtime_call, ne, scratch, Operand(JS_ARRAY_TYPE));
2853
2854 // Check that we have the original ArrayPrototype.
2855 __ ld(scratch, FieldMemOperand(spread_map, Map::kPrototypeOffset));
2856 __ ld(scratch2, ContextMemOperand(native_context,
2857 Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
2858 __ Branch(&runtime_call, ne, scratch, Operand(scratch2));
2859
2860 // Check that the ArrayPrototype hasn't been modified in a way that would
2861 // affect iteration.
2862 __ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
2863 __ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
2864 __ Branch(&runtime_call, ne, scratch,
2865 Operand(Smi::FromInt(Isolate::kProtectorValid)));
2866
2867 // Check that the map of the initial array iterator hasn't changed.
2868 __ ld(scratch,
2869 ContextMemOperand(native_context,
2870 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX));
2871 __ ld(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset));
2872 __ ld(scratch2,
2873 ContextMemOperand(native_context,
2874 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_MAP_INDEX));
2875 __ Branch(&runtime_call, ne, scratch, Operand(scratch2));
2876
2877 // For FastPacked kinds, iteration will have the same effect as simply
2878 // accessing each property in order.
2879 Label no_protector_check;
2880 __ lbu(scratch, FieldMemOperand(spread_map, Map::kBitField2Offset));
2881 __ DecodeField<Map::ElementsKindBits>(scratch);
2882 __ Branch(&runtime_call, hi, scratch, Operand(LAST_FAST_ELEMENTS_KIND));
2883 // For non-FastHoley kinds, we can skip the protector check.
2884 __ Branch(&no_protector_check, eq, scratch, Operand(FAST_SMI_ELEMENTS));
2885 __ Branch(&no_protector_check, eq, scratch, Operand(FAST_ELEMENTS));
2886 __ Branch(&no_protector_check, eq, scratch, Operand(FAST_DOUBLE_ELEMENTS));
2887 // Check the ArrayProtector cell.
2888 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex);
2889 __ lw(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
2890 __ Branch(&runtime_call, ne, scratch,
2891 Operand(Smi::FromInt(Isolate::kProtectorValid)));
2892
2893 __ bind(&no_protector_check);
2894 // Load the FixedArray backing store.
2895 __ ld(spread, FieldMemOperand(spread, JSArray::kElementsOffset));
2896 __ Branch(&push_args);
2897
2898 __ bind(&runtime_call);
2899 {
2900 // Call the builtin for the result of the spread.
2901 FrameScope scope(masm, StackFrame::INTERNAL);
2902 __ SmiTag(argc);
2903 __ Push(constructor, new_target, argc, spread);
2904 __ CallRuntime(Runtime::kSpreadIterableFixed);
2905 __ mov(spread, v0);
2906 __ Pop(constructor, new_target, argc);
2907 __ SmiUntag(argc);
2908 }
2909
2910 Register spread_len = a4;
2911 __ bind(&push_args);
2912 {
2913 // Pop the spread argument off the stack.
2914 __ Pop(scratch);
2915 // Calculate the new nargs including the result of the spread.
2916 __ lw(spread_len,
2917 UntagSmiFieldMemOperand(spread, FixedArray::kLengthOffset));
2918 // argc += spread_len - 1. Subtract 1 for the spread itself.
2919 __ Daddu(argc, argc, spread_len);
2920 __ Dsubu(argc, argc, Operand(1));
2921 }
2922
2923 // Check for stack overflow.
2924 {
2925 // Check the stack for overflow. We are not trying to catch interruptions
2926 // (i.e. debug break and preemption) here, so check the "real stack limit".
2927 Label done;
2928 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex);
2929 // Make scratch the space we have left. The stack might already be
2930 // overflowed here which will cause ip to become negative.
2931 __ Dsubu(scratch, sp, scratch);
2932 // Check if the arguments will overflow the stack.
2933 __ dsll(at, spread_len, kPointerSizeLog2);
2934 __ Branch(&done, gt, scratch, Operand(at)); // Signed comparison.
2935 __ TailCallRuntime(Runtime::kThrowStackOverflow);
2936 __ bind(&done);
2937 }
2938
2939 // Put the evaluated spread onto the stack as additional arguments.
2940 {
2941 __ mov(scratch, zero_reg);
2942 Label done, loop;
2943 __ bind(&loop);
2944 __ Branch(&done, eq, scratch, Operand(spread_len));
2945 __ Dlsa(scratch2, spread, scratch, kPointerSizeLog2);
2946 __ ld(scratch2, FieldMemOperand(scratch2, FixedArray::kHeaderSize));
2947 __ Push(scratch2);
2948 __ Daddu(scratch, scratch, Operand(1));
2949 __ Branch(&loop);
2950 __ bind(&done);
2951 }
2952
2953 // Dispatch.
2954 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2955 }
2956
2957 // static
2821 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { 2958 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) {
2822 // ----------- S t a t e ------------- 2959 // ----------- S t a t e -------------
2823 // -- a0 : requested object size (untagged) 2960 // -- a0 : requested object size (untagged)
2824 // -- ra : return address 2961 // -- ra : return address
2825 // ----------------------------------- 2962 // -----------------------------------
2826 __ SmiTag(a0); 2963 __ SmiTag(a0);
2827 __ Push(a0); 2964 __ Push(a0);
2828 __ Move(cp, Smi::kZero); 2965 __ Move(cp, Smi::kZero);
2829 __ TailCallRuntime(Runtime::kAllocateInNewSpace); 2966 __ TailCallRuntime(Runtime::kAllocateInNewSpace);
2830 } 2967 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2984 __ break_(0xCC); 3121 __ break_(0xCC);
2985 } 3122 }
2986 } 3123 }
2987 3124
2988 #undef __ 3125 #undef __
2989 3126
2990 } // namespace internal 3127 } // namespace internal
2991 } // namespace v8 3128 } // namespace v8
2992 3129
2993 #endif // V8_TARGET_ARCH_MIPS64 3130 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/builtins/mips/builtins-mips.cc ('k') | src/builtins/ppc/builtins-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698