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

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 14576005: Adapt hydrogen-based Array constructor to also support InternalArray and function call (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adapt to bugfix for 244461 Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.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 // 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 descriptor->stack_parameter_count_ = &r0; 143 descriptor->stack_parameter_count_ = &r0;
144 } 144 }
145 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; 145 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count;
146 descriptor->register_params_ = registers; 146 descriptor->register_params_ = registers;
147 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; 147 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
148 descriptor->deoptimization_handler_ = 148 descriptor->deoptimization_handler_ =
149 FUNCTION_ADDR(ArrayConstructor_StubFailure); 149 FUNCTION_ADDR(ArrayConstructor_StubFailure);
150 } 150 }
151 151
152 152
153 static void InitializeInternalArrayConstructorDescriptor(
154 Isolate* isolate,
155 CodeStubInterfaceDescriptor* descriptor,
156 int constant_stack_parameter_count) {
157 // register state
158 // r0 -- number of arguments
159 // r1 -- constructor function
160 static Register registers[] = { r1 };
161 descriptor->register_param_count_ = 1;
162
163 if (constant_stack_parameter_count != 0) {
164 // stack param count needs (constructor pointer, and single argument)
165 descriptor->stack_parameter_count_ = &r0;
166 }
167 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count;
168 descriptor->register_params_ = registers;
169 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
170 descriptor->deoptimization_handler_ =
171 FUNCTION_ADDR(InternalArrayConstructor_StubFailure);
172 }
173
174
153 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( 175 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor(
154 Isolate* isolate, 176 Isolate* isolate,
155 CodeStubInterfaceDescriptor* descriptor) { 177 CodeStubInterfaceDescriptor* descriptor) {
156 InitializeArrayConstructorDescriptor(isolate, descriptor, 0); 178 InitializeArrayConstructorDescriptor(isolate, descriptor, 0);
157 } 179 }
158 180
159 181
160 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( 182 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor(
161 Isolate* isolate, 183 Isolate* isolate,
162 CodeStubInterfaceDescriptor* descriptor) { 184 CodeStubInterfaceDescriptor* descriptor) {
(...skipping 14 matching lines...) Expand all
177 static Register registers[] = { r0 }; 199 static Register registers[] = { r0 };
178 descriptor->register_param_count_ = 1; 200 descriptor->register_param_count_ = 1;
179 descriptor->register_params_ = registers; 201 descriptor->register_params_ = registers;
180 descriptor->deoptimization_handler_ = 202 descriptor->deoptimization_handler_ =
181 FUNCTION_ADDR(ToBooleanIC_Miss); 203 FUNCTION_ADDR(ToBooleanIC_Miss);
182 descriptor->SetMissHandler( 204 descriptor->SetMissHandler(
183 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate)); 205 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate));
184 } 206 }
185 207
186 208
209 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor(
210 Isolate* isolate,
211 CodeStubInterfaceDescriptor* descriptor) {
212 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, 0);
213 }
214
215
216 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor(
217 Isolate* isolate,
218 CodeStubInterfaceDescriptor* descriptor) {
219 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, 1);
220 }
221
222
223 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
224 Isolate* isolate,
225 CodeStubInterfaceDescriptor* descriptor) {
226 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, -1);
227 }
228
229
187 #define __ ACCESS_MASM(masm) 230 #define __ ACCESS_MASM(masm)
188 231
189 static void EmitIdenticalObjectComparison(MacroAssembler* masm, 232 static void EmitIdenticalObjectComparison(MacroAssembler* masm,
190 Label* slow, 233 Label* slow,
191 Condition cond); 234 Condition cond);
192 static void EmitSmiNonsmiComparison(MacroAssembler* masm, 235 static void EmitSmiNonsmiComparison(MacroAssembler* masm,
193 Register lhs, 236 Register lhs,
194 Register rhs, 237 Register rhs,
195 Label* lhs_not_nan, 238 Label* lhs_not_nan,
196 Label* slow, 239 Label* slow,
(...skipping 4527 matching lines...) Expand 10 before | Expand all | Expand 10 after
4724 } 4767 }
4725 4768
4726 // Check that the function is really a JavaScript function. 4769 // Check that the function is really a JavaScript function.
4727 // r1: pushed function (to be verified) 4770 // r1: pushed function (to be verified)
4728 __ JumpIfSmi(r1, &non_function); 4771 __ JumpIfSmi(r1, &non_function);
4729 // Get the map of the function object. 4772 // Get the map of the function object.
4730 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); 4773 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE);
4731 __ b(ne, &slow); 4774 __ b(ne, &slow);
4732 4775
4733 if (RecordCallTarget()) { 4776 if (RecordCallTarget()) {
4734 GenerateRecordCallTargetNoArray(masm); 4777 if (FLAG_optimize_constructed_arrays) {
4778 GenerateRecordCallTarget(masm);
4779 } else {
4780 GenerateRecordCallTargetNoArray(masm);
4781 }
4735 } 4782 }
4736 4783
4737 // Fast-case: Invoke the function now. 4784 // Fast-case: Invoke the function now.
4738 // r1: pushed function 4785 // r1: pushed function
4739 ParameterCount actual(argc_); 4786 ParameterCount actual(argc_);
4740 4787
4741 if (ReceiverMightBeImplicit()) { 4788 if (ReceiverMightBeImplicit()) {
4742 Label call_as_function; 4789 Label call_as_function;
4743 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex); 4790 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex);
4744 __ b(eq, &call_as_function); 4791 __ b(eq, &call_as_function);
(...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after
7237 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { 7284 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) {
7238 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( 7285 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>(
7239 isolate); 7286 isolate);
7240 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( 7287 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
7241 isolate); 7288 isolate);
7242 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( 7289 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>(
7243 isolate); 7290 isolate);
7244 } 7291 }
7245 7292
7246 7293
7294 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(
7295 Isolate* isolate) {
7296 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS };
7297 for (int i = 0; i < 2; i++) {
7298 // For internal arrays we only need a few things
7299 InternalArrayNoArgumentConstructorStub stubh1(kinds[i]);
7300 stubh1.GetCode(isolate)->set_is_pregenerated(true);
7301 InternalArraySingleArgumentConstructorStub stubh2(kinds[i]);
7302 stubh2.GetCode(isolate)->set_is_pregenerated(true);
7303 InternalArrayNArgumentsConstructorStub stubh3(kinds[i]);
7304 stubh3.GetCode(isolate)->set_is_pregenerated(true);
7305 }
7306 }
7307
7308
7247 void ArrayConstructorStub::Generate(MacroAssembler* masm) { 7309 void ArrayConstructorStub::Generate(MacroAssembler* masm) {
7248 // ----------- S t a t e ------------- 7310 // ----------- S t a t e -------------
7249 // -- r0 : argc (only if argument_count_ == ANY) 7311 // -- r0 : argc (only if argument_count_ == ANY)
7250 // -- r1 : constructor 7312 // -- r1 : constructor
7251 // -- r2 : type info cell 7313 // -- r2 : type info cell
7252 // -- sp[0] : return address 7314 // -- sp[0] : return address
7253 // -- sp[4] : last argument 7315 // -- sp[4] : last argument
7254 // ----------------------------------- 7316 // -----------------------------------
7255 Handle<Object> undefined_sentinel( 7317 Handle<Object> undefined_sentinel(
7256 masm->isolate()->heap()->undefined_value(), 7318 masm->isolate()->heap()->undefined_value(),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
7323 // Jump to the generic construct code in case the specialized code cannot 7385 // Jump to the generic construct code in case the specialized code cannot
7324 // handle the construction. 7386 // handle the construction.
7325 __ bind(&generic_constructor); 7387 __ bind(&generic_constructor);
7326 Handle<Code> generic_construct_stub = 7388 Handle<Code> generic_construct_stub =
7327 masm->isolate()->builtins()->JSConstructStubGeneric(); 7389 masm->isolate()->builtins()->JSConstructStubGeneric();
7328 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 7390 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
7329 } 7391 }
7330 } 7392 }
7331 7393
7332 7394
7395 void InternalArrayConstructorStub::GenerateCase(
7396 MacroAssembler* masm, ElementsKind kind) {
7397 Label not_zero_case, not_one_case;
7398 Label normal_sequence;
7399
7400 __ tst(r0, r0);
7401 __ b(ne, &not_zero_case);
7402 InternalArrayNoArgumentConstructorStub stub0(kind);
7403 __ TailCallStub(&stub0);
7404
7405 __ bind(&not_zero_case);
7406 __ cmp(r0, Operand(1));
7407 __ b(gt, &not_one_case);
7408
7409 if (IsFastPackedElementsKind(kind)) {
7410 // We might need to create a holey array
7411 // look at the first argument
7412 __ ldr(r3, MemOperand(sp, 0));
7413 __ cmp(r3, Operand::Zero());
7414 __ b(eq, &normal_sequence);
7415
7416 InternalArraySingleArgumentConstructorStub
7417 stub1_holey(GetHoleyElementsKind(kind));
7418 __ TailCallStub(&stub1_holey);
7419 }
7420
7421 __ bind(&normal_sequence);
7422 InternalArraySingleArgumentConstructorStub stub1(kind);
7423 __ TailCallStub(&stub1);
7424
7425 __ bind(&not_one_case);
7426 InternalArrayNArgumentsConstructorStub stubN(kind);
7427 __ TailCallStub(&stubN);
7428 }
7429
7430
7431 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
7432 // ----------- S t a t e -------------
7433 // -- r0 : argc
7434 // -- r1 : constructor
7435 // -- sp[0] : return address
7436 // -- sp[4] : last argument
7437 // -----------------------------------
7438
7439 if (FLAG_debug_code) {
7440 // The array construct code is only set for the global and natives
7441 // builtin Array functions which always have maps.
7442
7443 // Initial map for the builtin Array function should be a map.
7444 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
7445 // Will both indicate a NULL and a Smi.
7446 __ tst(r3, Operand(kSmiTagMask));
7447 __ Assert(ne, "Unexpected initial map for Array function");
7448 __ CompareObjectType(r3, r3, r4, MAP_TYPE);
7449 __ Assert(eq, "Unexpected initial map for Array function");
7450 }
7451
7452 if (FLAG_optimize_constructed_arrays) {
7453 // Figure out the right elements kind
7454 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
7455
7456 // Load the map's "bit field 2" into |result|. We only need the first byte,
7457 // but the following bit field extraction takes care of that anyway.
7458 __ ldr(r3, FieldMemOperand(r3, Map::kBitField2Offset));
7459 // Retrieve elements_kind from bit field 2.
7460 __ ubfx(r3, r3, Map::kElementsKindShift, Map::kElementsKindBitCount);
7461
7462 if (FLAG_debug_code) {
7463 Label done;
7464 __ cmp(r3, Operand(FAST_ELEMENTS));
7465 __ b(eq, &done);
7466 __ cmp(r3, Operand(FAST_HOLEY_ELEMENTS));
7467 __ Assert(eq,
7468 "Invalid ElementsKind for InternalArray or InternalPackedArray");
7469 __ bind(&done);
7470 }
7471
7472 Label fast_elements_case;
7473 __ cmp(r3, Operand(FAST_ELEMENTS));
7474 __ b(eq, &fast_elements_case);
7475 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
7476
7477 __ bind(&fast_elements_case);
7478 GenerateCase(masm, FAST_ELEMENTS);
7479 } else {
7480 Label generic_constructor;
7481 // Run the native code for the Array function called as constructor.
7482 ArrayNativeCode(masm, &generic_constructor);
7483
7484 // Jump to the generic construct code in case the specialized code cannot
7485 // handle the construction.
7486 __ bind(&generic_constructor);
7487 Handle<Code> generic_construct_stub =
7488 masm->isolate()->builtins()->JSConstructStubGeneric();
7489 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
7490 }
7491 }
7492
7493
7333 #undef __ 7494 #undef __
7334 7495
7335 } } // namespace v8::internal 7496 } } // namespace v8::internal
7336 7497
7337 #endif // V8_TARGET_ARCH_ARM 7498 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698