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

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

Powered by Google App Engine
This is Rietveld 408576698