OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 descriptor->stack_parameter_count_ = &a0; | 144 descriptor->stack_parameter_count_ = &a0; |
145 } | 145 } |
146 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; | 146 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; |
147 descriptor->register_params_ = registers; | 147 descriptor->register_params_ = registers; |
148 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; | 148 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; |
149 descriptor->deoptimization_handler_ = | 149 descriptor->deoptimization_handler_ = |
150 FUNCTION_ADDR(ArrayConstructor_StubFailure); | 150 FUNCTION_ADDR(ArrayConstructor_StubFailure); |
151 } | 151 } |
152 | 152 |
153 | 153 |
| 154 static void InitializeInternalArrayConstructorDescriptor( |
| 155 Isolate* isolate, |
| 156 CodeStubInterfaceDescriptor* descriptor, |
| 157 int constant_stack_parameter_count) { |
| 158 // register state |
| 159 // a0 -- number of arguments |
| 160 // a1 -- constructor function |
| 161 static Register registers[] = { a1 }; |
| 162 descriptor->register_param_count_ = 1; |
| 163 |
| 164 if (constant_stack_parameter_count != 0) { |
| 165 // Stack param count needs (constructor pointer, and single argument). |
| 166 descriptor->stack_parameter_count_ = &a0; |
| 167 } |
| 168 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; |
| 169 descriptor->register_params_ = registers; |
| 170 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; |
| 171 descriptor->deoptimization_handler_ = |
| 172 FUNCTION_ADDR(InternalArrayConstructor_StubFailure); |
| 173 } |
| 174 |
| 175 |
154 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 176 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
155 Isolate* isolate, | 177 Isolate* isolate, |
156 CodeStubInterfaceDescriptor* descriptor) { | 178 CodeStubInterfaceDescriptor* descriptor) { |
157 InitializeArrayConstructorDescriptor(isolate, descriptor, 0); | 179 InitializeArrayConstructorDescriptor(isolate, descriptor, 0); |
158 } | 180 } |
159 | 181 |
160 | 182 |
161 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 183 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
162 Isolate* isolate, | 184 Isolate* isolate, |
163 CodeStubInterfaceDescriptor* descriptor) { | 185 CodeStubInterfaceDescriptor* descriptor) { |
(...skipping 14 matching lines...) Expand all Loading... |
178 static Register registers[] = { a0 }; | 200 static Register registers[] = { a0 }; |
179 descriptor->register_param_count_ = 1; | 201 descriptor->register_param_count_ = 1; |
180 descriptor->register_params_ = registers; | 202 descriptor->register_params_ = registers; |
181 descriptor->deoptimization_handler_ = | 203 descriptor->deoptimization_handler_ = |
182 FUNCTION_ADDR(ToBooleanIC_Miss); | 204 FUNCTION_ADDR(ToBooleanIC_Miss); |
183 descriptor->SetMissHandler( | 205 descriptor->SetMissHandler( |
184 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate)); | 206 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate)); |
185 } | 207 } |
186 | 208 |
187 | 209 |
| 210 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 211 Isolate* isolate, |
| 212 CodeStubInterfaceDescriptor* descriptor) { |
| 213 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, 0); |
| 214 } |
| 215 |
| 216 |
| 217 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 218 Isolate* isolate, |
| 219 CodeStubInterfaceDescriptor* descriptor) { |
| 220 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, 1); |
| 221 } |
| 222 |
| 223 |
| 224 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
| 225 Isolate* isolate, |
| 226 CodeStubInterfaceDescriptor* descriptor) { |
| 227 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, -1); |
| 228 } |
| 229 |
| 230 |
188 #define __ ACCESS_MASM(masm) | 231 #define __ ACCESS_MASM(masm) |
189 | 232 |
190 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 233 static void EmitIdenticalObjectComparison(MacroAssembler* masm, |
191 Label* slow, | 234 Label* slow, |
192 Condition cc); | 235 Condition cc); |
193 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 236 static void EmitSmiNonsmiComparison(MacroAssembler* masm, |
194 Register lhs, | 237 Register lhs, |
195 Register rhs, | 238 Register rhs, |
196 Label* rhs_not_nan, | 239 Label* rhs_not_nan, |
197 Label* slow, | 240 Label* slow, |
(...skipping 7476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7674 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 7717 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
7675 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 7718 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
7676 isolate); | 7719 isolate); |
7677 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 7720 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
7678 isolate); | 7721 isolate); |
7679 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | 7722 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( |
7680 isolate); | 7723 isolate); |
7681 } | 7724 } |
7682 | 7725 |
7683 | 7726 |
| 7727 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( |
| 7728 Isolate* isolate) { |
| 7729 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; |
| 7730 for (int i = 0; i < 2; i++) { |
| 7731 // For internal arrays we only need a few things. |
| 7732 InternalArrayNoArgumentConstructorStub stubh1(kinds[i]); |
| 7733 stubh1.GetCode(isolate)->set_is_pregenerated(true); |
| 7734 InternalArraySingleArgumentConstructorStub stubh2(kinds[i]); |
| 7735 stubh2.GetCode(isolate)->set_is_pregenerated(true); |
| 7736 InternalArrayNArgumentsConstructorStub stubh3(kinds[i]); |
| 7737 stubh3.GetCode(isolate)->set_is_pregenerated(true); |
| 7738 } |
| 7739 } |
| 7740 |
| 7741 |
7684 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 7742 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
7685 // ----------- S t a t e ------------- | 7743 // ----------- S t a t e ------------- |
7686 // -- a0 : argc (only if argument_count_ == ANY) | 7744 // -- a0 : argc (only if argument_count_ == ANY) |
7687 // -- a1 : constructor | 7745 // -- a1 : constructor |
7688 // -- a2 : type info cell | 7746 // -- a2 : type info cell |
7689 // -- sp[0] : return address | 7747 // -- sp[0] : return address |
7690 // -- sp[4] : last argument | 7748 // -- sp[4] : last argument |
7691 // ----------------------------------- | 7749 // ----------------------------------- |
7692 Handle<Object> undefined_sentinel( | 7750 Handle<Object> undefined_sentinel( |
7693 masm->isolate()->heap()->undefined_value(), | 7751 masm->isolate()->heap()->undefined_value(), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7759 // Jump to the generic construct code in case the specialized code cannot | 7817 // Jump to the generic construct code in case the specialized code cannot |
7760 // handle the construction. | 7818 // handle the construction. |
7761 __ bind(&generic_constructor); | 7819 __ bind(&generic_constructor); |
7762 Handle<Code> generic_construct_stub = | 7820 Handle<Code> generic_construct_stub = |
7763 masm->isolate()->builtins()->JSConstructStubGeneric(); | 7821 masm->isolate()->builtins()->JSConstructStubGeneric(); |
7764 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 7822 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
7765 } | 7823 } |
7766 } | 7824 } |
7767 | 7825 |
7768 | 7826 |
| 7827 void InternalArrayConstructorStub::GenerateCase( |
| 7828 MacroAssembler* masm, ElementsKind kind) { |
| 7829 Label not_zero_case, not_one_case; |
| 7830 Label normal_sequence; |
| 7831 |
| 7832 __ Branch(¬_zero_case, ne, a0, Operand(zero_reg)); |
| 7833 InternalArrayNoArgumentConstructorStub stub0(kind); |
| 7834 __ TailCallStub(&stub0); |
| 7835 |
| 7836 __ bind(¬_zero_case); |
| 7837 __ Branch(¬_one_case, gt, a0, Operand(1)); |
| 7838 |
| 7839 if (IsFastPackedElementsKind(kind)) { |
| 7840 // We might need to create a holey array |
| 7841 // look at the first argument. |
| 7842 __ lw(at, MemOperand(sp, 0)); |
| 7843 __ Branch(&normal_sequence, eq, at, Operand(zero_reg)); |
| 7844 |
| 7845 InternalArraySingleArgumentConstructorStub |
| 7846 stub1_holey(GetHoleyElementsKind(kind)); |
| 7847 __ TailCallStub(&stub1_holey); |
| 7848 } |
| 7849 |
| 7850 __ bind(&normal_sequence); |
| 7851 InternalArraySingleArgumentConstructorStub stub1(kind); |
| 7852 __ TailCallStub(&stub1); |
| 7853 |
| 7854 __ bind(¬_one_case); |
| 7855 InternalArrayNArgumentsConstructorStub stubN(kind); |
| 7856 __ TailCallStub(&stubN); |
| 7857 } |
| 7858 |
| 7859 |
| 7860 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
| 7861 // ----------- S t a t e ------------- |
| 7862 // -- a0 : argc |
| 7863 // -- a1 : constructor |
| 7864 // -- sp[0] : return address |
| 7865 // -- sp[4] : last argument |
| 7866 // ----------------------------------- |
| 7867 |
| 7868 if (FLAG_debug_code) { |
| 7869 // The array construct code is only set for the global and natives |
| 7870 // builtin Array functions which always have maps. |
| 7871 |
| 7872 // Initial map for the builtin Array function should be a map. |
| 7873 __ lw(a3, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
| 7874 // Will both indicate a NULL and a Smi. |
| 7875 __ And(at, a3, Operand(kSmiTagMask)); |
| 7876 __ Assert(ne, "Unexpected initial map for Array function", |
| 7877 at, Operand(zero_reg)); |
| 7878 __ GetObjectType(a3, a3, t0); |
| 7879 __ Assert(eq, "Unexpected initial map for Array function", |
| 7880 t0, Operand(MAP_TYPE)); |
| 7881 } |
| 7882 |
| 7883 if (FLAG_optimize_constructed_arrays) { |
| 7884 // Figure out the right elements kind. |
| 7885 __ lw(a3, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
| 7886 |
| 7887 // Load the map's "bit field 2" into a3. We only need the first byte, |
| 7888 // but the following bit field extraction takes care of that anyway. |
| 7889 __ lbu(a3, FieldMemOperand(a3, Map::kBitField2Offset)); |
| 7890 // Retrieve elements_kind from bit field 2. |
| 7891 __ Ext(a3, a3, Map::kElementsKindShift, Map::kElementsKindBitCount); |
| 7892 |
| 7893 if (FLAG_debug_code) { |
| 7894 Label done; |
| 7895 __ Branch(&done, eq, a3, Operand(FAST_ELEMENTS)); |
| 7896 __ Assert( |
| 7897 eq, "Invalid ElementsKind for InternalArray or InternalPackedArray", |
| 7898 a3, Operand(FAST_HOLEY_ELEMENTS)); |
| 7899 __ bind(&done); |
| 7900 } |
| 7901 |
| 7902 Label fast_elements_case; |
| 7903 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); |
| 7904 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
| 7905 |
| 7906 __ bind(&fast_elements_case); |
| 7907 GenerateCase(masm, FAST_ELEMENTS); |
| 7908 } else { |
| 7909 Label generic_constructor; |
| 7910 // Run the native code for the Array function called as constructor. |
| 7911 ArrayNativeCode(masm, &generic_constructor); |
| 7912 |
| 7913 // Jump to the generic construct code in case the specialized code cannot |
| 7914 // handle the construction. |
| 7915 __ bind(&generic_constructor); |
| 7916 Handle<Code> generic_construct_stub = |
| 7917 masm->isolate()->builtins()->JSConstructStubGeneric(); |
| 7918 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 7919 } |
| 7920 } |
| 7921 |
| 7922 |
7769 #undef __ | 7923 #undef __ |
7770 | 7924 |
7771 } } // namespace v8::internal | 7925 } } // namespace v8::internal |
7772 | 7926 |
7773 #endif // V8_TARGET_ARCH_MIPS | 7927 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |