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

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

Issue 2571563004: [Turbofan] Implement super calls with spread bytecode in assembly code. (Closed)
Patch Set: Update builtins for new push args modes 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
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_ARM 5 #if V8_TARGET_ARCH_ARM
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 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 __ bind(&stack_overflow); 1179 __ bind(&stack_overflow);
1180 { 1180 {
1181 __ TailCallRuntime(Runtime::kThrowStackOverflow); 1181 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1182 // Unreachable code. 1182 // Unreachable code.
1183 __ bkpt(0); 1183 __ bkpt(0);
1184 } 1184 }
1185 } 1185 }
1186 1186
1187 // static 1187 // static
1188 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( 1188 void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
1189 MacroAssembler* masm, CallableType construct_type) { 1189 MacroAssembler* masm, PushArgsConstructMode mode) {
1190 // ----------- S t a t e ------------- 1190 // ----------- S t a t e -------------
1191 // -- r0 : argument count (not including receiver) 1191 // -- r0 : argument count (not including receiver)
1192 // -- r3 : new target 1192 // -- r3 : new target
1193 // -- r1 : constructor to call 1193 // -- r1 : constructor to call
1194 // -- r2 : allocation site feedback if available, undefined otherwise. 1194 // -- r2 : allocation site feedback if available, undefined otherwise.
1195 // -- r4 : address of the first argument 1195 // -- r4 : address of the first argument
1196 // ----------------------------------- 1196 // -----------------------------------
1197 Label stack_overflow; 1197 Label stack_overflow;
1198 1198
1199 // Push a slot for the receiver to be constructed. 1199 // Push a slot for the receiver to be constructed.
1200 __ mov(ip, Operand::Zero()); 1200 __ mov(ip, Operand::Zero());
1201 __ push(ip); 1201 __ push(ip);
1202 1202
1203 // Push the arguments. r5, r4, r6 will be modified. 1203 // Push the arguments. r5, r4, r6 will be modified.
1204 Generate_InterpreterPushArgs(masm, r0, r4, r5, r6, &stack_overflow); 1204 Generate_InterpreterPushArgs(masm, r0, r4, r5, r6, &stack_overflow);
1205 1205
1206 __ AssertUndefinedOrAllocationSite(r2, r5); 1206 __ AssertUndefinedOrAllocationSite(r2, r5);
1207 if (construct_type == CallableType::kJSFunction) { 1207 if (mode == PushArgsConstructMode::kJSFunction) {
1208 __ AssertFunction(r1); 1208 __ AssertFunction(r1);
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 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 1212 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
1213 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); 1213 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
1214 // Jump to the construct function. 1214 // Jump to the construct function.
1215 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); 1215 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
1216 1216 } else if (mode == PushArgsConstructMode::kWithFinalSpread) {
1217 // Call the constructor with r0, r1, and r3 unmodified.
1218 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(),
1219 RelocInfo::CODE_TARGET);
1217 } else { 1220 } else {
1218 DCHECK_EQ(construct_type, CallableType::kAny); 1221 DCHECK_EQ(PushArgsConstructMode::kOther, mode);
1219 // Call the constructor with r0, r1, and r3 unmodified. 1222 // Call the constructor with r0, r1, and r3 unmodified.
1220 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1223 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1221 } 1224 }
1222 1225
1223 __ bind(&stack_overflow); 1226 __ bind(&stack_overflow);
1224 { 1227 {
1225 __ TailCallRuntime(Runtime::kThrowStackOverflow); 1228 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1226 // Unreachable code. 1229 // Unreachable code.
1227 __ bkpt(0); 1230 __ bkpt(0);
1228 } 1231 }
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 } 2726 }
2724 2727
2725 // Called Construct on an Object that doesn't have a [[Construct]] internal 2728 // Called Construct on an Object that doesn't have a [[Construct]] internal
2726 // method. 2729 // method.
2727 __ bind(&non_constructor); 2730 __ bind(&non_constructor);
2728 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), 2731 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
2729 RelocInfo::CODE_TARGET); 2732 RelocInfo::CODE_TARGET);
2730 } 2733 }
2731 2734
2732 // static 2735 // static
2736 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
2737 // ----------- S t a t e -------------
2738 // -- r0 : the number of arguments (not including the receiver)
2739 // -- r1 : the constructor to call (can be any Object)
2740 // -- r3 : the new target (either the same as the constructor or
2741 // the JSFunction on which new was invoked initially)
2742 // -----------------------------------
2743
2744 Register argc = r0;
2745 Register constructor = r1;
2746 Register new_target = r3;
2747
2748 Register scratch = r2;
2749 Register scratch2 = r6;
2750
2751 Register spread = r4;
2752 Register spread_map = r5;
2753 __ ldr(spread, MemOperand(sp, 0));
2754 __ ldr(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset));
2755
2756 Label runtime_call, push_args;
2757 // Check that the spread is an array.
2758 __ CompareInstanceType(spread_map, scratch, JS_ARRAY_TYPE);
2759 __ b(ne, &runtime_call);
2760
2761 // Check that we have the original ArrayPrototype.
2762 __ ldr(scratch, FieldMemOperand(spread_map, Map::kPrototypeOffset));
2763 __ ldr(scratch2, NativeContextMemOperand());
2764 __ ldr(scratch2,
2765 ContextMemOperand(scratch2, Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
2766 __ cmp(scratch, scratch2);
2767 __ b(ne, &runtime_call);
2768
2769 // Check that the ArrayPrototype hasn't been modified in a way that would
2770 // affect iteration.
2771 __ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
2772 __ ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
2773 __ cmp(scratch, Operand(Smi::FromInt(Isolate::kProtectorValid)));
2774 __ b(ne, &runtime_call);
2775
2776 // Check that the map of the initial array iterator hasn't changed.
2777 __ ldr(scratch2, NativeContextMemOperand());
2778 __ ldr(scratch,
2779 ContextMemOperand(scratch2,
2780 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX));
2781 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset));
2782 __ ldr(scratch2,
2783 ContextMemOperand(
2784 scratch2, Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_MAP_INDEX));
2785 __ cmp(scratch, scratch2);
2786 __ b(ne, &runtime_call);
2787
2788 // For FastPacked kinds, iteration will have the same effect as simply
2789 // accessing each property in order.
2790 Label no_protector_check;
2791 __ ldr(scratch, FieldMemOperand(spread_map, Map::kBitField2Offset));
2792 __ DecodeField<Map::ElementsKindBits>(scratch);
2793 __ cmp(scratch, Operand(LAST_FAST_ELEMENTS_KIND));
2794 __ b(hi, &runtime_call);
2795 // For non-FastHoley kinds, we can skip the protector check.
2796 __ cmp(scratch, Operand(FAST_SMI_ELEMENTS));
2797 __ b(eq, &no_protector_check);
2798 __ cmp(scratch, Operand(FAST_ELEMENTS));
2799 __ b(eq, &no_protector_check);
2800 __ cmp(scratch, Operand(FAST_DOUBLE_ELEMENTS));
2801 __ b(eq, &no_protector_check);
2802 // Check the ArrayProtector cell.
2803 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex);
2804 __ ldr(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
2805 __ cmp(scratch, Operand(Smi::FromInt(Isolate::kProtectorValid)));
2806 __ b(ne, &runtime_call);
2807
2808 __ bind(&no_protector_check);
2809 // Load the FixedArray backing store.
2810 __ ldr(spread, FieldMemOperand(spread, JSArray::kElementsOffset));
2811 __ b(&push_args);
2812
2813 __ bind(&runtime_call);
2814 {
2815 // Call the builtin for the result of the spread.
2816 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
2817 __ SmiTag(argc);
2818 __ Push(constructor);
2819 __ Push(new_target);
2820 __ Push(argc);
2821 __ Push(spread);
2822 __ CallRuntime(Runtime::kSpreadIterableFixed);
2823 __ mov(spread, r0);
2824 __ Pop(argc);
2825 __ Pop(new_target);
2826 __ Pop(constructor);
2827 __ SmiUntag(argc);
2828 }
2829
2830 Register spread_len = r5;
2831 __ bind(&push_args);
2832 {
2833 // Pop the spread argument off the stack.
2834 __ Pop(scratch);
2835 // Calculate the new nargs including the result of the spread.
2836 __ ldr(spread_len, FieldMemOperand(spread, FixedArray::kLengthOffset));
2837 __ SmiUntag(spread_len);
2838 // argc += spread_len - 1. Subtract 1 for the spread itself.
2839 __ add(argc, argc, spread_len);
2840 __ sub(argc, argc, Operand(1));
2841 }
2842
2843 // Check for stack overflow.
2844 {
2845 // Check the stack for overflow. We are not trying to catch interruptions
2846 // (i.e. debug break and preemption) here, so check the "real stack limit".
2847 Label done;
2848 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex);
2849 // Make scratch the space we have left. The stack might already be
2850 // overflowed here which will cause scratch to become negative.
2851 __ sub(scratch, sp, scratch);
2852 // Check if the arguments will overflow the stack.
2853 __ cmp(scratch, Operand(spread_len, LSL, kPointerSizeLog2));
2854 __ b(gt, &done); // Signed comparison.
2855 __ TailCallRuntime(Runtime::kThrowStackOverflow);
2856 __ bind(&done);
2857 }
2858
2859 // Put the evaluated spread onto the stack as additional arguments.
2860 {
2861 __ mov(scratch, Operand(0));
2862 Label done, loop;
2863 __ bind(&loop);
2864 __ cmp(scratch, spread_len);
2865 __ b(eq, &done);
2866 __ add(scratch2, spread, Operand(scratch, LSL, kPointerSizeLog2));
2867 __ ldr(scratch2, FieldMemOperand(scratch2, FixedArray::kHeaderSize));
2868 __ Push(scratch2);
2869 __ add(scratch, scratch, Operand(1));
2870 __ b(&loop);
2871 __ bind(&done);
2872 }
2873
2874 // Dispatch.
2875 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2876 }
2877
2878 // static
2733 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { 2879 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) {
2734 // ----------- S t a t e ------------- 2880 // ----------- S t a t e -------------
2735 // -- r1 : requested object size (untagged) 2881 // -- r1 : requested object size (untagged)
2736 // -- lr : return address 2882 // -- lr : return address
2737 // ----------------------------------- 2883 // -----------------------------------
2738 __ SmiTag(r1); 2884 __ SmiTag(r1);
2739 __ Push(r1); 2885 __ Push(r1);
2740 __ Move(cp, Smi::kZero); 2886 __ Move(cp, Smi::kZero);
2741 __ TailCallRuntime(Runtime::kAllocateInNewSpace); 2887 __ TailCallRuntime(Runtime::kAllocateInNewSpace);
2742 } 2888 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 __ bkpt(0); 3033 __ bkpt(0);
2888 } 3034 }
2889 } 3035 }
2890 3036
2891 #undef __ 3037 #undef __
2892 3038
2893 } // namespace internal 3039 } // namespace internal
2894 } // namespace v8 3040 } // namespace v8
2895 3041
2896 #endif // V8_TARGET_ARCH_ARM 3042 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/builtins/arm64/builtins-arm64.cc » ('j') | src/interpreter/bytecode-array-builder.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698