OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 RelocInfo::CODE_TARGET); | 2792 RelocInfo::CODE_TARGET); |
2793 } | 2793 } |
2794 | 2794 |
2795 // Called Construct on an Object that doesn't have a [[Construct]] internal | 2795 // Called Construct on an Object that doesn't have a [[Construct]] internal |
2796 // method. | 2796 // method. |
2797 __ bind(&non_constructor); | 2797 __ bind(&non_constructor); |
2798 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), | 2798 __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(), |
2799 RelocInfo::CODE_TARGET); | 2799 RelocInfo::CODE_TARGET); |
2800 } | 2800 } |
2801 | 2801 |
| 2802 void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) { |
| 2803 // ----------- S t a t e ------------- |
| 2804 // -- r3 : the number of arguments (not including the receiver) |
| 2805 // -- r4 : the constructor to call (can be any Object) |
| 2806 // -- r6 : the new target (either the same as the constructor or |
| 2807 // the JSFunction on which new was invoked initially) |
| 2808 // ----------------------------------- |
| 2809 |
| 2810 Register argc = r3; |
| 2811 Register constructor = r4; |
| 2812 Register new_target = r6; |
| 2813 |
| 2814 Register scratch = r5; |
| 2815 Register scratch2 = r9; |
| 2816 |
| 2817 Register spread = r7; |
| 2818 Register spread_map = r8; |
| 2819 __ LoadP(spread, MemOperand(sp, 0)); |
| 2820 __ LoadP(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset)); |
| 2821 |
| 2822 Label runtime_call, push_args; |
| 2823 // Check that the spread is an array. |
| 2824 __ CompareInstanceType(spread_map, scratch, JS_ARRAY_TYPE); |
| 2825 __ bne(&runtime_call); |
| 2826 |
| 2827 // Check that we have the original ArrayPrototype. |
| 2828 __ LoadP(scratch, FieldMemOperand(spread_map, Map::kPrototypeOffset)); |
| 2829 __ LoadP(scratch2, NativeContextMemOperand()); |
| 2830 __ LoadP(scratch2, |
| 2831 ContextMemOperand(scratch2, Context::INITIAL_ARRAY_PROTOTYPE_INDEX)); |
| 2832 __ cmp(scratch, scratch2); |
| 2833 __ bne(&runtime_call); |
| 2834 |
| 2835 // Check that the ArrayPrototype hasn't been modified in a way that would |
| 2836 // affect iteration. |
| 2837 __ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex); |
| 2838 __ LoadP(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); |
| 2839 __ CmpSmiLiteral(scratch, Smi::FromInt(Isolate::kProtectorValid), r0); |
| 2840 __ bne(&runtime_call); |
| 2841 |
| 2842 // Check that the map of the initial array iterator hasn't changed. |
| 2843 __ LoadP(scratch2, NativeContextMemOperand()); |
| 2844 __ LoadP(scratch, |
| 2845 ContextMemOperand(scratch2, |
| 2846 Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX)); |
| 2847 __ LoadP(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); |
| 2848 __ LoadP(scratch2, |
| 2849 ContextMemOperand( |
| 2850 scratch2, Context::INITIAL_ARRAY_ITERATOR_PROTOTYPE_MAP_INDEX)); |
| 2851 __ cmp(scratch, scratch2); |
| 2852 __ bne(&runtime_call); |
| 2853 |
| 2854 // For FastPacked kinds, iteration will have the same effect as simply |
| 2855 // accessing each property in order. |
| 2856 Label no_protector_check; |
| 2857 __ LoadP(scratch, FieldMemOperand(spread_map, Map::kBitField2Offset)); |
| 2858 __ DecodeField<Map::ElementsKindBits>(scratch); |
| 2859 __ cmpi(scratch, Operand(LAST_FAST_ELEMENTS_KIND)); |
| 2860 __ bgt(&runtime_call); |
| 2861 // For non-FastHoley kinds, we can skip the protector check. |
| 2862 __ cmpi(scratch, Operand(FAST_SMI_ELEMENTS)); |
| 2863 __ beq(&no_protector_check); |
| 2864 __ cmpi(scratch, Operand(FAST_ELEMENTS)); |
| 2865 __ beq(&no_protector_check); |
| 2866 __ cmpi(scratch, Operand(FAST_DOUBLE_ELEMENTS)); |
| 2867 __ beq(&no_protector_check); |
| 2868 // Check the ArrayProtector cell. |
| 2869 __ LoadRoot(scratch, Heap::kArrayProtectorRootIndex); |
| 2870 __ LoadP(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset)); |
| 2871 __ CmpSmiLiteral(scratch, Smi::FromInt(Isolate::kProtectorValid), r0); |
| 2872 __ bne(&runtime_call); |
| 2873 |
| 2874 __ bind(&no_protector_check); |
| 2875 // Load the FixedArray backing store. |
| 2876 __ LoadP(spread, FieldMemOperand(spread, JSArray::kElementsOffset)); |
| 2877 __ b(&push_args); |
| 2878 |
| 2879 __ bind(&runtime_call); |
| 2880 { |
| 2881 // Call the builtin for the result of the spread. |
| 2882 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 2883 __ SmiTag(argc); |
| 2884 __ Push(constructor, new_target, argc, spread); |
| 2885 __ CallRuntime(Runtime::kSpreadIterableFixed); |
| 2886 __ mr(spread, r3); |
| 2887 __ Pop(constructor, new_target, argc); |
| 2888 __ SmiUntag(argc); |
| 2889 } |
| 2890 |
| 2891 Register spread_len = r8; |
| 2892 __ bind(&push_args); |
| 2893 { |
| 2894 // Pop the spread argument off the stack. |
| 2895 __ Pop(scratch); |
| 2896 // Calculate the new nargs including the result of the spread. |
| 2897 __ LoadP(spread_len, FieldMemOperand(spread, FixedArray::kLengthOffset)); |
| 2898 __ SmiUntag(spread_len); |
| 2899 // argc += spread_len - 1. Subtract 1 for the spread itself. |
| 2900 __ add(argc, argc, spread_len); |
| 2901 __ subi(argc, argc, Operand(1)); |
| 2902 } |
| 2903 |
| 2904 // Check for stack overflow. |
| 2905 { |
| 2906 // Check the stack for overflow. We are not trying to catch interruptions |
| 2907 // (i.e. debug break and preemption) here, so check the "real stack limit". |
| 2908 Label done; |
| 2909 __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex); |
| 2910 // Make scratch the space we have left. The stack might already be |
| 2911 // overflowed here which will cause scratch to become negative. |
| 2912 __ sub(scratch, sp, scratch); |
| 2913 // Check if the arguments will overflow the stack. |
| 2914 __ ShiftLeftImm(r0, spread_len, Operand(kPointerSizeLog2)); |
| 2915 __ cmp(scratch, r0); |
| 2916 __ bgt(&done); // Signed comparison. |
| 2917 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 2918 __ bind(&done); |
| 2919 } |
| 2920 |
| 2921 // Put the evaluated spread onto the stack as additional arguments. |
| 2922 { |
| 2923 __ li(scratch, Operand::Zero()); |
| 2924 Label done, loop; |
| 2925 __ bind(&loop); |
| 2926 __ cmp(scratch, spread_len); |
| 2927 __ beq(&done); |
| 2928 __ ShiftLeftImm(r0, scratch, Operand(kPointerSizeLog2)); |
| 2929 __ add(scratch2, spread, r0); |
| 2930 __ LoadP(scratch2, FieldMemOperand(scratch2, FixedArray::kHeaderSize)); |
| 2931 __ Push(scratch2); |
| 2932 __ addi(scratch, scratch, Operand(1)); |
| 2933 __ b(&loop); |
| 2934 __ bind(&done); |
| 2935 } |
| 2936 |
| 2937 // Dispatch. |
| 2938 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 2939 } |
| 2940 |
2802 // static | 2941 // static |
2803 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { | 2942 void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { |
2804 // ----------- S t a t e ------------- | 2943 // ----------- S t a t e ------------- |
2805 // -- r4 : requested object size (untagged) | 2944 // -- r4 : requested object size (untagged) |
2806 // -- lr : return address | 2945 // -- lr : return address |
2807 // ----------------------------------- | 2946 // ----------------------------------- |
2808 __ SmiTag(r4); | 2947 __ SmiTag(r4); |
2809 __ Push(r4); | 2948 __ Push(r4); |
2810 __ LoadSmiLiteral(cp, Smi::kZero); | 2949 __ LoadSmiLiteral(cp, Smi::kZero); |
2811 __ TailCallRuntime(Runtime::kAllocateInNewSpace); | 2950 __ TailCallRuntime(Runtime::kAllocateInNewSpace); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 __ CallRuntime(Runtime::kThrowStackOverflow); | 3104 __ CallRuntime(Runtime::kThrowStackOverflow); |
2966 __ bkpt(0); | 3105 __ bkpt(0); |
2967 } | 3106 } |
2968 } | 3107 } |
2969 | 3108 |
2970 #undef __ | 3109 #undef __ |
2971 } // namespace internal | 3110 } // namespace internal |
2972 } // namespace v8 | 3111 } // namespace v8 |
2973 | 3112 |
2974 #endif // V8_TARGET_ARCH_PPC | 3113 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |