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

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

Issue 2649143002: [Turbofan] Implement call with spread bytecode in assembly code. (Closed)
Patch Set: Rename PushArgsMode to InterpreterPushArgsMode 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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 __ ldr(scratch, MemOperand(index, -kPointerSize, PostIndex)); 1141 __ ldr(scratch, MemOperand(index, -kPointerSize, PostIndex));
1142 __ push(scratch); 1142 __ push(scratch);
1143 __ bind(&loop_check); 1143 __ bind(&loop_check);
1144 __ cmp(index, limit); 1144 __ cmp(index, limit);
1145 __ b(gt, &loop_header); 1145 __ b(gt, &loop_header);
1146 } 1146 }
1147 1147
1148 // static 1148 // static
1149 void Builtins::Generate_InterpreterPushArgsAndCallImpl( 1149 void Builtins::Generate_InterpreterPushArgsAndCallImpl(
1150 MacroAssembler* masm, TailCallMode tail_call_mode, 1150 MacroAssembler* masm, TailCallMode tail_call_mode,
1151 CallableType function_type) { 1151 InterpreterPushArgsMode mode) {
1152 // ----------- S t a t e ------------- 1152 // ----------- S t a t e -------------
1153 // -- r0 : the number of arguments (not including the receiver) 1153 // -- r0 : the number of arguments (not including the receiver)
1154 // -- r2 : the address of the first argument to be pushed. Subsequent 1154 // -- r2 : the address of the first argument to be pushed. Subsequent
1155 // arguments should be consecutive above this, in the same order as 1155 // arguments should be consecutive above this, in the same order as
1156 // they are to be pushed onto the stack. 1156 // they are to be pushed onto the stack.
1157 // -- r1 : the target to call (can be any Object). 1157 // -- r1 : the target to call (can be any Object).
1158 // ----------------------------------- 1158 // -----------------------------------
1159 Label stack_overflow; 1159 Label stack_overflow;
1160 1160
1161 __ add(r3, r0, Operand(1)); // Add one for receiver. 1161 __ add(r3, r0, Operand(1)); // Add one for receiver.
1162 1162
1163 // Push the arguments. r2, r4, r5 will be modified. 1163 // Push the arguments. r2, r4, r5 will be modified.
1164 Generate_InterpreterPushArgs(masm, r3, r2, r4, r5, &stack_overflow); 1164 Generate_InterpreterPushArgs(masm, r3, r2, r4, r5, &stack_overflow);
1165 1165
1166 // Call the target. 1166 // Call the target.
1167 if (function_type == CallableType::kJSFunction) { 1167 if (mode == InterpreterPushArgsMode::kJSFunction) {
1168 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, 1168 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny,
1169 tail_call_mode), 1169 tail_call_mode),
1170 RelocInfo::CODE_TARGET); 1170 RelocInfo::CODE_TARGET);
1171 } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) {
1172 __ Jump(masm->isolate()->builtins()->CallWithSpread(),
1173 RelocInfo::CODE_TARGET);
1171 } else { 1174 } else {
1172 DCHECK_EQ(function_type, CallableType::kAny);
1173 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, 1175 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
1174 tail_call_mode), 1176 tail_call_mode),
1175 RelocInfo::CODE_TARGET); 1177 RelocInfo::CODE_TARGET);
1176 } 1178 }
1177 1179
1178 __ bind(&stack_overflow); 1180 __ bind(&stack_overflow);
1179 { 1181 {
1180 __ TailCallRuntime(Runtime::kThrowStackOverflow); 1182 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1181 // Unreachable code. 1183 // Unreachable code.
1182 __ bkpt(0); 1184 __ bkpt(0);
1183 } 1185 }
1184 } 1186 }
1185 1187
1186 // static 1188 // static
1187 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( 1189 void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
1188 MacroAssembler* masm, PushArgsConstructMode mode) { 1190 MacroAssembler* masm, InterpreterPushArgsMode mode) {
1189 // ----------- S t a t e ------------- 1191 // ----------- S t a t e -------------
1190 // -- r0 : argument count (not including receiver) 1192 // -- r0 : argument count (not including receiver)
1191 // -- r3 : new target 1193 // -- r3 : new target
1192 // -- r1 : constructor to call 1194 // -- r1 : constructor to call
1193 // -- r2 : allocation site feedback if available, undefined otherwise. 1195 // -- r2 : allocation site feedback if available, undefined otherwise.
1194 // -- r4 : address of the first argument 1196 // -- r4 : address of the first argument
1195 // ----------------------------------- 1197 // -----------------------------------
1196 Label stack_overflow; 1198 Label stack_overflow;
1197 1199
1198 // Push a slot for the receiver to be constructed. 1200 // Push a slot for the receiver to be constructed.
1199 __ mov(ip, Operand::Zero()); 1201 __ mov(ip, Operand::Zero());
1200 __ push(ip); 1202 __ push(ip);
1201 1203
1202 // Push the arguments. r5, r4, r6 will be modified. 1204 // Push the arguments. r5, r4, r6 will be modified.
1203 Generate_InterpreterPushArgs(masm, r0, r4, r5, r6, &stack_overflow); 1205 Generate_InterpreterPushArgs(masm, r0, r4, r5, r6, &stack_overflow);
1204 1206
1205 __ AssertUndefinedOrAllocationSite(r2, r5); 1207 __ AssertUndefinedOrAllocationSite(r2, r5);
1206 if (mode == PushArgsConstructMode::kJSFunction) { 1208 if (mode == InterpreterPushArgsMode::kJSFunction) {
1207 __ AssertFunction(r1); 1209 __ AssertFunction(r1);
1208 1210
1209 // Tail call to the function-specific construct stub (still in the caller 1211 // Tail call to the function-specific construct stub (still in the caller
1210 // context at this point). 1212 // context at this point).
1211 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 1213 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
1212 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); 1214 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
1213 // Jump to the construct function. 1215 // Jump to the construct function.
1214 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); 1216 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
1215 } else if (mode == PushArgsConstructMode::kWithFinalSpread) { 1217 } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) {
1216 // Call the constructor with r0, r1, and r3 unmodified. 1218 // Call the constructor with r0, r1, and r3 unmodified.
1217 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(), 1219 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(),
1218 RelocInfo::CODE_TARGET); 1220 RelocInfo::CODE_TARGET);
1219 } else { 1221 } else {
1220 DCHECK_EQ(PushArgsConstructMode::kOther, mode); 1222 DCHECK_EQ(InterpreterPushArgsMode::kOther, mode);
1221 // Call the constructor with r0, r1, and r3 unmodified. 1223 // Call the constructor with r0, r1, and r3 unmodified.
1222 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1224 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1223 } 1225 }
1224 1226
1225 __ bind(&stack_overflow); 1227 __ bind(&stack_overflow);
1226 { 1228 {
1227 __ TailCallRuntime(Runtime::kThrowStackOverflow); 1229 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1228 // Unreachable code. 1230 // Unreachable code.
1229 __ bkpt(0); 1231 __ bkpt(0);
1230 } 1232 }
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 2612
2611 // 3. Call to something that is not callable. 2613 // 3. Call to something that is not callable.
2612 __ bind(&non_callable); 2614 __ bind(&non_callable);
2613 { 2615 {
2614 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 2616 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
2615 __ Push(r1); 2617 __ Push(r1);
2616 __ CallRuntime(Runtime::kThrowCalledNonCallable); 2618 __ CallRuntime(Runtime::kThrowCalledNonCallable);
2617 } 2619 }
2618 } 2620 }
2619 2621
2620 // static 2622 static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
2621 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
2622 // ----------- S t a t e -------------
2623 // -- r0 : the number of arguments (not including the receiver)
2624 // -- r1 : the constructor to call (checked to be a JSFunction)
2625 // -- r3 : the new target (checked to be a constructor)
2626 // -----------------------------------
2627 __ AssertFunction(r1);
2628
2629 // Calling convention for function specific ConstructStubs require
2630 // r2 to contain either an AllocationSite or undefined.
2631 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
2632
2633 // Tail call to the function-specific construct stub (still in the caller
2634 // context at this point).
2635 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
2636 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
2637 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
2638 }
2639
2640 // static
2641 void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) {
2642 // ----------- S t a t e -------------
2643 // -- r0 : the number of arguments (not including the receiver)
2644 // -- r1 : the function to call (checked to be a JSBoundFunction)
2645 // -- r3 : the new target (checked to be a constructor)
2646 // -----------------------------------
2647 __ AssertBoundFunction(r1);
2648
2649 // Push the [[BoundArguments]] onto the stack.
2650 Generate_PushBoundArguments(masm);
2651
2652 // Patch new.target to [[BoundTargetFunction]] if new.target equals target.
2653 __ cmp(r1, r3);
2654 __ ldr(r3, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset),
2655 eq);
2656
2657 // Construct the [[BoundTargetFunction]] via the Construct builtin.
2658 __ ldr(r1, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset));
2659 __ mov(ip, Operand(ExternalReference(Builtins::kConstruct, masm->isolate())));
2660 __ ldr(ip, MemOperand(ip));
2661 __ add(pc, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
2662 }
2663
2664 // static
2665 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
2666 // ----------- S t a t e -------------
2667 // -- r0 : the number of arguments (not including the receiver)
2668 // -- r1 : the constructor to call (checked to be a JSProxy)
2669 // -- r3 : the new target (either the same as the constructor or
2670 // the JSFunction on which new was invoked initially)
2671 // -----------------------------------
2672
2673 // Call into the Runtime for Proxy [[Construct]].
2674 __ Push(r1);
2675 __ Push(r3);
2676 // Include the pushed new_target, constructor and the receiver.
2677 __ add(r0, r0, Operand(3));
2678 // Tail-call to the runtime.
2679 __ JumpToExternalReference(
2680 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate()));
2681 }
2682
2683 // static
2684 void Builtins::Generate_Construct(MacroAssembler* masm) {
2685 // ----------- S t a t e -------------
2686 // -- r0 : the number of arguments (not including the receiver)
2687 // -- r1 : the constructor to call (can be any Object)
2688 // -- r3 : the new target (either the same as the constructor or
2689 // the JSFunction on which new was invoked initially)
2690 // -----------------------------------
2691
2692 // Check if target is a Smi.
2693 Label non_constructor;
2694 __ JumpIfSmi(r1, &non_constructor);
2695
2696 // Dispatch based on instance type.
2697 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE);
2698 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
2699 RelocInfo::CODE_TARGET, eq);
2700
2701 // Check if target has a [[Construct]] internal method.
2702 __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset));
2703 __ tst(r2, Operand(1 << Map::kIsConstructor));
2704 __ b(eq, &non_constructor);
2705
2706 // Only dispatch to bound functions after checking whether they are
2707 // constructors.
2708 __ cmp(r5, Operand(JS_BOUND_FUNCTION_TYPE));
2709 __ Jump(masm->isolate()->builtins()->ConstructBoundFunction(),
2710 RelocInfo::CODE_TARGET, eq);
2711
2712 // Only dispatch to proxies after checking whether they are constructors.
2713 __ cmp(r5, Operand(JS_PROXY_TYPE));
2714 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
2715 eq);
2716
2717 // Called Construct on an exotic Object with a [[Construct]] internal method.
2718 {
2719 // Overwrite the original receiver with the (original) target.
2720 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
2721 // Let the "call_as_constructor_delegate" take care of the rest.
2722 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1);
2723 __ Jump(masm->isolate()->builtins()->CallFunction(),
2724 RelocInfo::CODE_TARGET);
2725 }
2726
2727 // Called Construct on an Object that doesn't have a [[Construct]] internal
2728 // method.
2729 __ bind(&non_constructor);
2730 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
2731 RelocInfo::CODE_TARGET);
2732 }
2733
2734 // static
2735 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
2736 // ----------- S t a t e -------------
2737 // -- r0 : the number of arguments (not including the receiver)
2738 // -- r1 : the constructor to call (can be any Object)
2739 // -- r3 : the new target (either the same as the constructor or
2740 // the JSFunction on which new was invoked initially)
2741 // -----------------------------------
2742
2743 Register argc = r0; 2623 Register argc = r0;
2744 Register constructor = r1; 2624 Register constructor = r1;
2745 Register new_target = r3; 2625 Register new_target = r3;
2746 2626
2747 Register scratch = r2; 2627 Register scratch = r2;
2748 Register scratch2 = r6; 2628 Register scratch2 = r6;
2749 2629
2750 Register spread = r4; 2630 Register spread = r4;
2751 Register spread_map = r5; 2631 Register spread_map = r5;
2632
2633 Register spread_len = r5;
2634
2752 __ ldr(spread, MemOperand(sp, 0)); 2635 __ ldr(spread, MemOperand(sp, 0));
2753 __ ldr(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset)); 2636 __ ldr(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset));
2754 2637
2755 Label runtime_call, push_args; 2638 Label runtime_call, push_args;
2756 // Check that the spread is an array. 2639 // Check that the spread is an array.
2757 __ CompareInstanceType(spread_map, scratch, JS_ARRAY_TYPE); 2640 __ CompareInstanceType(spread_map, scratch, JS_ARRAY_TYPE);
2758 __ b(ne, &runtime_call); 2641 __ b(ne, &runtime_call);
2759 2642
2760 // Check that we have the original ArrayPrototype. 2643 // Check that we have the original ArrayPrototype.
2761 __ ldr(scratch, FieldMemOperand(spread_map, Map::kPrototypeOffset)); 2644 __ ldr(scratch, FieldMemOperand(spread_map, Map::kPrototypeOffset));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 __ b(eq, &no_protector_check); 2679 __ b(eq, &no_protector_check);
2797 __ cmp(scratch, Operand(FAST_ELEMENTS)); 2680 __ cmp(scratch, Operand(FAST_ELEMENTS));
2798 __ b(eq, &no_protector_check); 2681 __ b(eq, &no_protector_check);
2799 // Check the ArrayProtector cell. 2682 // Check the ArrayProtector cell.
2800 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex); 2683 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex);
2801 __ ldr(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset)); 2684 __ ldr(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
2802 __ cmp(scratch, Operand(Smi::FromInt(Isolate::kProtectorValid))); 2685 __ cmp(scratch, Operand(Smi::FromInt(Isolate::kProtectorValid)));
2803 __ b(ne, &runtime_call); 2686 __ b(ne, &runtime_call);
2804 2687
2805 __ bind(&no_protector_check); 2688 __ bind(&no_protector_check);
2806 // Load the FixedArray backing store. 2689 // Load the FixedArray backing store, but use the length from the array.
2690 __ ldr(spread_len, FieldMemOperand(spread, JSArray::kLengthOffset));
2691 __ SmiUntag(spread_len);
2807 __ ldr(spread, FieldMemOperand(spread, JSArray::kElementsOffset)); 2692 __ ldr(spread, FieldMemOperand(spread, JSArray::kElementsOffset));
2808 __ b(&push_args); 2693 __ b(&push_args);
2809 2694
2810 __ bind(&runtime_call); 2695 __ bind(&runtime_call);
2811 { 2696 {
2812 // Call the builtin for the result of the spread. 2697 // Call the builtin for the result of the spread.
2813 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 2698 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
2814 __ SmiTag(argc); 2699 __ SmiTag(argc);
2815 __ Push(constructor); 2700 __ Push(constructor);
2816 __ Push(new_target); 2701 __ Push(new_target);
2817 __ Push(argc); 2702 __ Push(argc);
2818 __ Push(spread); 2703 __ Push(spread);
2819 __ CallRuntime(Runtime::kSpreadIterableFixed); 2704 __ CallRuntime(Runtime::kSpreadIterableFixed);
2820 __ mov(spread, r0); 2705 __ mov(spread, r0);
2821 __ Pop(argc); 2706 __ Pop(argc);
2822 __ Pop(new_target); 2707 __ Pop(new_target);
2823 __ Pop(constructor); 2708 __ Pop(constructor);
2824 __ SmiUntag(argc); 2709 __ SmiUntag(argc);
2825 } 2710 }
2826 2711
2827 Register spread_len = r5;
2828 __ bind(&push_args);
2829 { 2712 {
2830 // Pop the spread argument off the stack.
2831 __ Pop(scratch);
2832 // Calculate the new nargs including the result of the spread. 2713 // Calculate the new nargs including the result of the spread.
2833 __ ldr(spread_len, FieldMemOperand(spread, FixedArray::kLengthOffset)); 2714 __ ldr(spread_len, FieldMemOperand(spread, FixedArray::kLengthOffset));
2834 __ SmiUntag(spread_len); 2715 __ SmiUntag(spread_len);
2716
2717 __ bind(&push_args);
2835 // argc += spread_len - 1. Subtract 1 for the spread itself. 2718 // argc += spread_len - 1. Subtract 1 for the spread itself.
2836 __ add(argc, argc, spread_len); 2719 __ add(argc, argc, spread_len);
2837 __ sub(argc, argc, Operand(1)); 2720 __ sub(argc, argc, Operand(1));
2721
2722 // Pop the spread argument off the stack.
2723 __ Pop(scratch);
2838 } 2724 }
2839 2725
2840 // Check for stack overflow. 2726 // Check for stack overflow.
2841 { 2727 {
2842 // Check the stack for overflow. We are not trying to catch interruptions 2728 // Check the stack for overflow. We are not trying to catch interruptions
2843 // (i.e. debug break and preemption) here, so check the "real stack limit". 2729 // (i.e. debug break and preemption) here, so check the "real stack limit".
2844 Label done; 2730 Label done;
2845 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex); 2731 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex);
2846 // Make scratch the space we have left. The stack might already be 2732 // Make scratch the space we have left. The stack might already be
2847 // overflowed here which will cause scratch to become negative. 2733 // overflowed here which will cause scratch to become negative.
(...skipping 12 matching lines...) Expand all
2860 __ bind(&loop); 2746 __ bind(&loop);
2861 __ cmp(scratch, spread_len); 2747 __ cmp(scratch, spread_len);
2862 __ b(eq, &done); 2748 __ b(eq, &done);
2863 __ add(scratch2, spread, Operand(scratch, LSL, kPointerSizeLog2)); 2749 __ add(scratch2, spread, Operand(scratch, LSL, kPointerSizeLog2));
2864 __ ldr(scratch2, FieldMemOperand(scratch2, FixedArray::kHeaderSize)); 2750 __ ldr(scratch2, FieldMemOperand(scratch2, FixedArray::kHeaderSize));
2865 __ Push(scratch2); 2751 __ Push(scratch2);
2866 __ add(scratch, scratch, Operand(1)); 2752 __ add(scratch, scratch, Operand(1));
2867 __ b(&loop); 2753 __ b(&loop);
2868 __ bind(&done); 2754 __ bind(&done);
2869 } 2755 }
2756 }
2870 2757
2871 // Dispatch. 2758 // static
2759 void Builtins::Generate_CallWithSpread(MacroAssembler* masm) {
2760 // ----------- S t a t e -------------
2761 // -- r0 : the number of arguments (not including the receiver)
2762 // -- r1 : the constructor to call (can be any Object)
2763 // -----------------------------------
2764
2765 // CheckSpreadAndPushToStack will push r3 to save it.
2766 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
2767 CheckSpreadAndPushToStack(masm);
2768 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
2769 TailCallMode::kDisallow),
2770 RelocInfo::CODE_TARGET);
2771 }
2772
2773 // static
2774 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
2775 // ----------- S t a t e -------------
2776 // -- r0 : the number of arguments (not including the receiver)
2777 // -- r1 : the constructor to call (checked to be a JSFunction)
2778 // -- r3 : the new target (checked to be a constructor)
2779 // -----------------------------------
2780 __ AssertFunction(r1);
2781
2782 // Calling convention for function specific ConstructStubs require
2783 // r2 to contain either an AllocationSite or undefined.
2784 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
2785
2786 // Tail call to the function-specific construct stub (still in the caller
2787 // context at this point).
2788 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
2789 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
2790 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
2791 }
2792
2793 // static
2794 void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) {
2795 // ----------- S t a t e -------------
2796 // -- r0 : the number of arguments (not including the receiver)
2797 // -- r1 : the function to call (checked to be a JSBoundFunction)
2798 // -- r3 : the new target (checked to be a constructor)
2799 // -----------------------------------
2800 __ AssertBoundFunction(r1);
2801
2802 // Push the [[BoundArguments]] onto the stack.
2803 Generate_PushBoundArguments(masm);
2804
2805 // Patch new.target to [[BoundTargetFunction]] if new.target equals target.
2806 __ cmp(r1, r3);
2807 __ ldr(r3, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset),
2808 eq);
2809
2810 // Construct the [[BoundTargetFunction]] via the Construct builtin.
2811 __ ldr(r1, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset));
2812 __ mov(ip, Operand(ExternalReference(Builtins::kConstruct, masm->isolate())));
2813 __ ldr(ip, MemOperand(ip));
2814 __ add(pc, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
2815 }
2816
2817 // static
2818 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
2819 // ----------- S t a t e -------------
2820 // -- r0 : the number of arguments (not including the receiver)
2821 // -- r1 : the constructor to call (checked to be a JSProxy)
2822 // -- r3 : the new target (either the same as the constructor or
2823 // the JSFunction on which new was invoked initially)
2824 // -----------------------------------
2825
2826 // Call into the Runtime for Proxy [[Construct]].
2827 __ Push(r1);
2828 __ Push(r3);
2829 // Include the pushed new_target, constructor and the receiver.
2830 __ add(r0, r0, Operand(3));
2831 // Tail-call to the runtime.
2832 __ JumpToExternalReference(
2833 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate()));
2834 }
2835
2836 // static
2837 void Builtins::Generate_Construct(MacroAssembler* masm) {
2838 // ----------- S t a t e -------------
2839 // -- r0 : the number of arguments (not including the receiver)
2840 // -- r1 : the constructor to call (can be any Object)
2841 // -- r3 : the new target (either the same as the constructor or
2842 // the JSFunction on which new was invoked initially)
2843 // -----------------------------------
2844
2845 // Check if target is a Smi.
2846 Label non_constructor;
2847 __ JumpIfSmi(r1, &non_constructor);
2848
2849 // Dispatch based on instance type.
2850 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE);
2851 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
2852 RelocInfo::CODE_TARGET, eq);
2853
2854 // Check if target has a [[Construct]] internal method.
2855 __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset));
2856 __ tst(r2, Operand(1 << Map::kIsConstructor));
2857 __ b(eq, &non_constructor);
2858
2859 // Only dispatch to bound functions after checking whether they are
2860 // constructors.
2861 __ cmp(r5, Operand(JS_BOUND_FUNCTION_TYPE));
2862 __ Jump(masm->isolate()->builtins()->ConstructBoundFunction(),
2863 RelocInfo::CODE_TARGET, eq);
2864
2865 // Only dispatch to proxies after checking whether they are constructors.
2866 __ cmp(r5, Operand(JS_PROXY_TYPE));
2867 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
2868 eq);
2869
2870 // Called Construct on an exotic Object with a [[Construct]] internal method.
2871 {
2872 // Overwrite the original receiver with the (original) target.
2873 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
2874 // Let the "call_as_constructor_delegate" take care of the rest.
2875 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1);
2876 __ Jump(masm->isolate()->builtins()->CallFunction(),
2877 RelocInfo::CODE_TARGET);
2878 }
2879
2880 // Called Construct on an Object that doesn't have a [[Construct]] internal
2881 // method.
2882 __ bind(&non_constructor);
2883 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
2884 RelocInfo::CODE_TARGET);
2885 }
2886
2887 // static
2888 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
2889 // ----------- S t a t e -------------
2890 // -- r0 : the number of arguments (not including the receiver)
2891 // -- r1 : the constructor to call (can be any Object)
2892 // -- r3 : the new target (either the same as the constructor or
2893 // the JSFunction on which new was invoked initially)
2894 // -----------------------------------
2895
2896 CheckSpreadAndPushToStack(masm);
2872 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 2897 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2873 } 2898 }
2874 2899
2875 // static 2900 // static
2876 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { 2901 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) {
2877 // ----------- S t a t e ------------- 2902 // ----------- S t a t e -------------
2878 // -- r1 : requested object size (untagged) 2903 // -- r1 : requested object size (untagged)
2879 // -- lr : return address 2904 // -- lr : return address
2880 // ----------------------------------- 2905 // -----------------------------------
2881 __ SmiTag(r1); 2906 __ SmiTag(r1);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3030 __ bkpt(0); 3055 __ bkpt(0);
3031 } 3056 }
3032 } 3057 }
3033 3058
3034 #undef __ 3059 #undef __
3035 3060
3036 } // namespace internal 3061 } // namespace internal
3037 } // namespace v8 3062 } // namespace v8
3038 3063
3039 #endif // V8_TARGET_ARCH_ARM 3064 #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