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

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

Issue 2571563004: [Turbofan] Implement super calls with spread bytecode in assembly code. (Closed)
Patch Set: Change arm64 loop to be similar to the rest 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_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 // Pop the temporary registers, so that return address is on top of stack. 936 // Pop the temporary registers, so that return address is on top of stack.
937 __ Pop(edx); 937 __ Pop(edx);
938 938
939 __ TailCallRuntime(Runtime::kThrowStackOverflow); 939 __ TailCallRuntime(Runtime::kThrowStackOverflow);
940 940
941 // This should be unreachable. 941 // This should be unreachable.
942 __ int3(); 942 __ int3();
943 } 943 }
944 } 944 }
945 945
946 // static
947 void Builtins::Generate_InterpreterPushArgsAndConstructWithSpread(
948 MacroAssembler* masm) {
949 // ----------- S t a t e -------------
950 // -- eax : the number of arguments (not including the receiver)
951 // -- edx : the new target
952 // -- edi : the constructor
953 // -- ebx : allocation site feedback (if available or undefined)
954 // -- ecx : the address of the first argument to be pushed. Subsequent
955 // arguments should be consecutive above this, in the same order as
956 // they are to be pushed onto the stack.
957 // -----------------------------------
958 Label stack_overflow;
959 // We need two scratch registers. Push edi and edx onto stack.
960 __ Push(edi);
961 __ Push(edx);
962
963 // Push arguments and move return address to the top of stack.
964 // The eax register is readonly. The ecx register will be modified. The edx
965 // and edi registers will be modified but restored to their original values.
966 Generate_InterpreterPushArgsAndReturnAddress(masm, eax, ecx, edx, edi, false,
967 2, &stack_overflow);
968
969 // Restore edi and edx
970 __ Pop(edx);
971 __ Pop(edi);
972
973 __ AssertUndefinedOrAllocationSite(ebx);
974 // Call the constructor with unmodified eax, edi, edx values.
975
976 __ Jump(masm->isolate()->builtins()->ConstructWithSpread(),
977 RelocInfo::CODE_TARGET);
978
979 __ bind(&stack_overflow);
980 {
981 // Pop the temporary registers, so that return address is on top of stack.
982 __ Pop(edx);
983 __ Pop(edi);
984
985 __ TailCallRuntime(Runtime::kThrowStackOverflow);
986
987 // This should be unreachable.
988 __ int3();
989 }
990 }
991
946 static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { 992 static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
947 // Set the return address to the correct point in the interpreter entry 993 // Set the return address to the correct point in the interpreter entry
948 // trampoline. 994 // trampoline.
949 Smi* interpreter_entry_return_pc_offset( 995 Smi* interpreter_entry_return_pc_offset(
950 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); 996 masm->isolate()->heap()->interpreter_entry_return_pc_offset());
951 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero); 997 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero);
952 __ LoadHeapObject(ebx, 998 __ LoadHeapObject(ebx,
953 masm->isolate()->builtins()->InterpreterEntryTrampoline()); 999 masm->isolate()->builtins()->InterpreterEntryTrampoline());
954 __ add(ebx, Immediate(interpreter_entry_return_pc_offset->value() + 1000 __ add(ebx, Immediate(interpreter_entry_return_pc_offset->value() +
955 Code::kHeaderSize - kHeapObjectTag)); 1001 Code::kHeaderSize - kHeapObjectTag));
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 } 2834 }
2789 2835
2790 // Called Construct on an Object that doesn't have a [[Construct]] internal 2836 // Called Construct on an Object that doesn't have a [[Construct]] internal
2791 // method. 2837 // method.
2792 __ bind(&non_constructor); 2838 __ bind(&non_constructor);
2793 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), 2839 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
2794 RelocInfo::CODE_TARGET); 2840 RelocInfo::CODE_TARGET);
2795 } 2841 }
2796 2842
2797 // static 2843 // static
2844 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
2845 // ----------- S t a t e -------------
2846 // -- eax : the number of arguments (not including the receiver)
2847 // -- edx : the new target (either the same as the constructor or
2848 // the JSFunction on which new was invoked initially)
2849 // -- edi : the constructor to call (can be any Object)
2850 // -----------------------------------
2851
2852 // Free up some registers.
2853 __ movd(xmm0, edx);
2854 __ movd(xmm1, edi);
2855
2856 Register argc = eax;
2857
2858 Register scratch = ecx;
2859 Register scratch2 = edi;
2860
2861 Register spread = ebx;
2862 Register spread_map = edx;
2863
2864 __ mov(spread, Operand(esp, kPointerSize));
2865 __ mov(spread_map, FieldOperand(spread, HeapObject::kMapOffset));
2866
2867 Label runtime_call, push_args;
2868 // Check that the spread is an array.
2869 __ CmpInstanceType(spread_map, JS_ARRAY_TYPE);
2870 __ j(not_equal, &runtime_call);
2871
2872 // Check that we have the original ArrayPrototype.
2873 __ mov(scratch, FieldOperand(spread_map, Map::kPrototypeOffset));
2874 __ mov(scratch2, NativeContextOperand());
2875 __ cmp(scratch,
2876 ContextOperand(scratch2, Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
2877 __ j(not_equal, &runtime_call);
2878
2879 // Check that the ArrayPrototype hasn't been modified in a way that would
2880 // affect iteration.
2881 __ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
2882 __ cmp(FieldOperand(scratch, Cell::kValueOffset),
2883 Immediate(Smi::FromInt(Isolate::kProtectorValid)));
2884 __ j(not_equal, &runtime_call);
2885
2886 // Check that the map of the initial array iterator hasn't changed.
2887 __ mov(scratch2, NativeContextOperand());
2888 __ mov(scratch,
2889 ContextOperand(scratch2,
2890 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX));
2891 __ mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset));
2892 __ cmp(scratch,
2893 ContextOperand(scratch2,
2894 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_MAP_INDEX));
2895 __ j(not_equal, &runtime_call);
2896
2897 // For FastPacked kinds, iteration will have the same effect as simply
2898 // accessing each property in order.
2899 Label no_protector_check;
2900 __ mov(scratch, FieldOperand(spread_map, Map::kBitField2Offset));
2901 __ DecodeField<Map::ElementsKindBits>(scratch);
2902 __ cmp(scratch, Immediate(LAST_FAST_ELEMENTS_KIND));
2903 __ j(above, &runtime_call);
2904 // For non-FastHoley kinds, we can skip the protector check.
2905 __ cmp(scratch, Immediate(FAST_SMI_ELEMENTS));
2906 __ j(equal, &no_protector_check);
2907 __ cmp(scratch, Immediate(FAST_ELEMENTS));
2908 __ j(equal, &no_protector_check);
2909 __ cmp(scratch, Immediate(FAST_DOUBLE_ELEMENTS));
2910 __ j(equal, &no_protector_check);
2911 // Check the ArrayProtector cell.
2912 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex);
2913 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset),
2914 Immediate(Smi::FromInt(Isolate::kProtectorValid)));
2915 __ j(not_equal, &runtime_call);
2916
2917 __ bind(&no_protector_check);
2918 // Load the FixedArray backing store.
2919 __ mov(spread, FieldOperand(spread, JSArray::kElementsOffset));
2920 // Free up some registers.
2921 __ jmp(&push_args);
2922
2923 __ bind(&runtime_call);
2924 {
2925 // Call the builtin for the result of the spread.
2926 FrameScope scope(masm, StackFrame::INTERNAL);
2927 // Need to save these on the stack.
2928 __ movd(edi, xmm1);
2929 __ movd(edx, xmm0);
2930 __ Push(edi);
2931 __ Push(edx);
2932 __ SmiTag(argc);
2933 __ Push(argc);
2934 __ Push(spread);
2935 __ CallRuntime(Runtime::kSpreadIterableFixed);
2936 __ mov(spread, eax);
2937 __ Pop(argc);
2938 __ SmiUntag(argc);
2939 __ Pop(edx);
2940 __ Pop(edi);
2941 // Free up some registers.
2942 __ movd(xmm0, edx);
2943 __ movd(xmm1, edi);
2944 }
2945
2946 Register spread_len = edx;
2947 Register return_address = edi;
2948 __ bind(&push_args);
2949 {
2950 // Pop the return address and spread argument.
2951 __ PopReturnAddressTo(return_address);
2952 __ Pop(scratch);
2953
2954 // Calculate the new nargs including the result of the spread.
2955 __ mov(spread_len, FieldOperand(spread, FixedArray::kLengthOffset));
2956 __ SmiUntag(spread_len);
2957 // argc += spread_len - 1. Subtract 1 for the spread itself.
2958 __ lea(argc, Operand(argc, spread_len, times_1, -1));
2959 }
2960
2961 // Check for stack overflow.
2962 {
2963 // Check the stack for overflow. We are not trying to catch interruptions
2964 // (i.e. debug break and preemption) here, so check the "real stack limit".
2965 Label done;
2966 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex);
2967 // Make scratch the space we have left. The stack might already be
2968 // overflowed here which will cause scratch to become negative.
2969 __ neg(scratch);
2970 __ add(scratch, esp);
2971 __ sar(scratch, kPointerSizeLog2);
2972 // Check if the arguments will overflow the stack.
2973 __ cmp(scratch, spread_len);
2974 __ j(greater, &done, Label::kNear); // Signed comparison.
2975 __ TailCallRuntime(Runtime::kThrowStackOverflow);
2976 __ bind(&done);
2977 }
2978
2979 // Put the evaluated spread onto the stack as additional arguments.
2980 {
2981 Register scratch2 = esi;
2982 __ movd(xmm2, esi);
2983
2984 __ mov(scratch, Immediate(0));
2985 Label done, loop;
2986 __ bind(&loop);
2987 __ cmp(scratch, spread_len);
2988 __ j(equal, &done, Label::kNear);
2989 __ mov(scratch2, FieldOperand(spread, scratch, times_pointer_size,
2990 FixedArray::kHeaderSize));
2991 __ Push(scratch2);
2992 __ inc(scratch);
2993 __ jmp(&loop);
2994 __ bind(&done);
2995 __ PushReturnAddressFrom(return_address);
2996 __ movd(esi, xmm2);
2997 __ movd(edi, xmm1);
2998 __ movd(edx, xmm0);
2999 }
3000
3001 // Dispatch.
3002 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
3003 }
3004
3005 // static
2798 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { 3006 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) {
2799 // ----------- S t a t e ------------- 3007 // ----------- S t a t e -------------
2800 // -- edx : requested object size (untagged) 3008 // -- edx : requested object size (untagged)
2801 // -- esp[0] : return address 3009 // -- esp[0] : return address
2802 // ----------------------------------- 3010 // -----------------------------------
2803 __ SmiTag(edx); 3011 __ SmiTag(edx);
2804 __ PopReturnAddressTo(ecx); 3012 __ PopReturnAddressTo(ecx);
2805 __ Push(edx); 3013 __ Push(edx);
2806 __ PushReturnAddressFrom(ecx); 3014 __ PushReturnAddressFrom(ecx);
2807 __ Move(esi, Smi::kZero); 3015 __ Move(esi, Smi::kZero);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 3317
3110 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3318 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3111 Generate_OnStackReplacementHelper(masm, true); 3319 Generate_OnStackReplacementHelper(masm, true);
3112 } 3320 }
3113 3321
3114 #undef __ 3322 #undef __
3115 } // namespace internal 3323 } // namespace internal
3116 } // namespace v8 3324 } // namespace v8
3117 3325
3118 #endif // V8_TARGET_ARCH_IA32 3326 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698