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

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

Issue 12385014: Hydrogen stubs for array constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: We still generated the arrays with feature flag off. Fixed. Created 7 years, 8 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 | « no previous file | src/arm/code-stubs-arm.h » ('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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // r0: argc 299 // r0: argc
300 // r1: constructor (built-in Array function) 300 // r1: constructor (built-in Array function)
301 // lr: return address 301 // lr: return address
302 // sp[0]: last argument 302 // sp[0]: last argument
303 // This function is used for both construct and normal calls of Array. The only 303 // This function is used for both construct and normal calls of Array. The only
304 // difference between handling a construct call and a normal call is that for a 304 // difference between handling a construct call and a normal call is that for a
305 // construct call the constructor function in r1 needs to be preserved for 305 // construct call the constructor function in r1 needs to be preserved for
306 // entering the generic code. In both cases argc in r0 needs to be preserved. 306 // entering the generic code. In both cases argc in r0 needs to be preserved.
307 // Both registers are preserved by this code so no need to differentiate between 307 // Both registers are preserved by this code so no need to differentiate between
308 // construct call and normal call. 308 // construct call and normal call.
309 static void ArrayNativeCode(MacroAssembler* masm, 309 void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code) {
310 Label* call_generic_code) {
311 Counters* counters = masm->isolate()->counters(); 310 Counters* counters = masm->isolate()->counters();
312 Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array, 311 Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array,
313 has_non_smi_element, finish, cant_transition_map, not_double; 312 has_non_smi_element, finish, cant_transition_map, not_double;
314 313
315 // Check for array construction with zero arguments or one. 314 // Check for array construction with zero arguments or one.
316 __ cmp(r0, Operand::Zero()); 315 __ cmp(r0, Operand::Zero());
317 __ b(ne, &argc_one_or_more); 316 __ b(ne, &argc_one_or_more);
318 317
319 // Handle construction of an empty array. 318 // Handle construction of an empty array.
320 __ bind(&empty_array); 319 __ bind(&empty_array);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // Jump to the generic array code if the specialized code cannot handle 524 // Jump to the generic array code if the specialized code cannot handle
526 // the construction. 525 // the construction.
527 __ bind(&generic_array_code); 526 __ bind(&generic_array_code);
528 527
529 Handle<Code> array_code = 528 Handle<Code> array_code =
530 masm->isolate()->builtins()->ArrayCodeGeneric(); 529 masm->isolate()->builtins()->ArrayCodeGeneric();
531 __ Jump(array_code, RelocInfo::CODE_TARGET); 530 __ Jump(array_code, RelocInfo::CODE_TARGET);
532 } 531 }
533 532
534 533
535 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { 534 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) {
536 // ----------- S t a t e ------------- 535 // ----------- S t a t e -------------
537 // -- r0 : number of arguments 536 // -- r0 : number of arguments
538 // -- r1 : constructor function 537 // -- r1 : constructor function
539 // -- r2 : type info cell 538 // -- r2 : type info cell
540 // -- lr : return address 539 // -- lr : return address
541 // -- sp[...]: constructor arguments 540 // -- sp[...]: constructor arguments
542 // ----------------------------------- 541 // -----------------------------------
543 542
544 if (FLAG_debug_code) { 543 if (FLAG_debug_code) {
545 // The array construct code is only set for the builtin and internal 544 // The array construct code is only set for the builtin and internal
546 // Array functions which always have a map. 545 // Array functions which always have a map.
547 // Initial map for the builtin Array function should be a map. 546 // Initial map for the builtin Array function should be a map.
548 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); 547 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
549 __ tst(r3, Operand(kSmiTagMask)); 548 __ tst(r3, Operand(kSmiTagMask));
550 __ Assert(ne, "Unexpected initial map for Array function"); 549 __ Assert(ne, "Unexpected initial map for Array function");
551 __ CompareObjectType(r3, r3, r4, MAP_TYPE); 550 __ CompareObjectType(r3, r3, r4, MAP_TYPE);
552 __ Assert(eq, "Unexpected initial map for Array function"); 551 __ Assert(eq, "Unexpected initial map for Array function");
552 }
553 Label generic_constructor;
554 // Run the native code for the Array function called as a constructor.
555 ArrayNativeCode(masm, &generic_constructor);
553 556
554 if (FLAG_optimize_constructed_arrays) { 557 // Jump to the generic construct code in case the specialized code cannot
555 // We should either have undefined in r2 or a valid jsglobalpropertycell 558 // handle the construction.
556 Label okay_here; 559 __ bind(&generic_constructor);
557 Handle<Object> undefined_sentinel( 560 Handle<Code> generic_construct_stub =
558 masm->isolate()->heap()->undefined_value(), masm->isolate()); 561 masm->isolate()->builtins()->JSConstructStubGeneric();
559 Handle<Map> global_property_cell_map( 562 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
560 masm->isolate()->heap()->global_property_cell_map());
561 __ cmp(r2, Operand(undefined_sentinel));
562 __ b(eq, &okay_here);
563 __ ldr(r3, FieldMemOperand(r2, 0));
564 __ cmp(r3, Operand(global_property_cell_map));
565 __ Assert(eq, "Expected property cell in register ebx");
566 __ bind(&okay_here);
567 }
568 }
569
570 if (FLAG_optimize_constructed_arrays) {
571 Label not_zero_case, not_one_case;
572 __ tst(r0, r0);
573 __ b(ne, &not_zero_case);
574 ArrayNoArgumentConstructorStub no_argument_stub;
575 __ TailCallStub(&no_argument_stub);
576
577 __ bind(&not_zero_case);
578 __ cmp(r0, Operand(1));
579 __ b(gt, &not_one_case);
580 ArraySingleArgumentConstructorStub single_argument_stub;
581 __ TailCallStub(&single_argument_stub);
582
583 __ bind(&not_one_case);
584 ArrayNArgumentsConstructorStub n_argument_stub;
585 __ TailCallStub(&n_argument_stub);
586 } else {
587 Label generic_constructor;
588 // Run the native code for the Array function called as a constructor.
589 ArrayNativeCode(masm, &generic_constructor);
590
591 // Jump to the generic construct code in case the specialized code cannot
592 // handle the construction.
593 __ bind(&generic_constructor);
594 Handle<Code> generic_construct_stub =
595 masm->isolate()->builtins()->JSConstructStubGeneric();
596 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
597 }
598 } 563 }
599 564
600 565
601 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 566 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
602 // ----------- S t a t e ------------- 567 // ----------- S t a t e -------------
603 // -- r0 : number of arguments 568 // -- r0 : number of arguments
604 // -- r1 : constructor function 569 // -- r1 : constructor function
605 // -- lr : return address 570 // -- lr : return address
606 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 571 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
607 // -- sp[argc * 4] : receiver 572 // -- sp[argc * 4] : receiver
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 __ bind(&dont_adapt_arguments); 1870 __ bind(&dont_adapt_arguments);
1906 __ Jump(r3); 1871 __ Jump(r3);
1907 } 1872 }
1908 1873
1909 1874
1910 #undef __ 1875 #undef __
1911 1876
1912 } } // namespace v8::internal 1877 } } // namespace v8::internal
1913 1878
1914 #endif // V8_TARGET_ARCH_ARM 1879 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/code-stubs-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698