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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // Jump to the generic array code if the specialized code cannot handle | 525 // Jump to the generic array code if the specialized code cannot handle |
526 // the construction. | 526 // the construction. |
527 __ bind(&generic_array_code); | 527 __ bind(&generic_array_code); |
528 | 528 |
529 Handle<Code> array_code = | 529 Handle<Code> array_code = |
530 masm->isolate()->builtins()->ArrayCodeGeneric(); | 530 masm->isolate()->builtins()->ArrayCodeGeneric(); |
531 __ Jump(array_code, RelocInfo::CODE_TARGET); | 531 __ Jump(array_code, RelocInfo::CODE_TARGET); |
532 } | 532 } |
533 | 533 |
534 | 534 |
535 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 535 void Builtins::Generate_InternalArrayConstructCode(MacroAssembler* masm) { |
536 // ----------- S t a t e ------------- | 536 // ----------- S t a t e ------------- |
537 // -- r0 : number of arguments | 537 // -- r0 : number of arguments |
538 // -- r1 : constructor function | 538 // -- r1 : constructor function |
539 // -- r2 : type info cell | 539 // -- r2 : type info cell |
540 // -- lr : return address | 540 // -- lr : return address |
541 // -- sp[...]: constructor arguments | 541 // -- sp[...]: constructor arguments |
542 // ----------------------------------- | 542 // ----------------------------------- |
543 | 543 |
544 if (FLAG_debug_code) { | 544 if (FLAG_debug_code) { |
545 // The array construct code is only set for the builtin and internal | 545 // The array construct code is only set for the builtin and internal |
546 // Array functions which always have a map. | 546 // Array functions which always have a map. |
547 // Initial map for the builtin Array function should be a map. | 547 // Initial map for the builtin Array function should be a map. |
548 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 548 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); |
549 __ tst(r3, Operand(kSmiTagMask)); | 549 __ tst(r3, Operand(kSmiTagMask)); |
550 __ Assert(ne, "Unexpected initial map for Array function"); | 550 __ Assert(ne, "Unexpected initial map for Array function"); |
551 __ CompareObjectType(r3, r3, r4, MAP_TYPE); | 551 __ CompareObjectType(r3, r3, r4, MAP_TYPE); |
552 __ Assert(eq, "Unexpected initial map for Array function"); | 552 __ Assert(eq, "Unexpected initial map for Array function"); |
| 553 } |
| 554 Label generic_constructor; |
| 555 // Run the native code for the Array function called as a constructor. |
| 556 ArrayNativeCode(masm, &generic_constructor); |
553 | 557 |
554 if (FLAG_optimize_constructed_arrays) { | 558 // Jump to the generic construct code in case the specialized code cannot |
555 // We should either have undefined in r2 or a valid jsglobalpropertycell | 559 // handle the construction. |
556 Label okay_here; | 560 __ bind(&generic_constructor); |
557 Handle<Object> undefined_sentinel( | 561 Handle<Code> generic_construct_stub = |
558 masm->isolate()->heap()->undefined_value(), masm->isolate()); | 562 masm->isolate()->builtins()->JSConstructStubGeneric(); |
559 Handle<Map> global_property_cell_map( | 563 __ 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, ¬_zero_case); | |
574 ArrayNoArgumentConstructorStub no_argument_stub; | |
575 __ TailCallStub(&no_argument_stub); | |
576 | |
577 __ bind(¬_zero_case); | |
578 __ cmp(r0, Operand(1)); | |
579 __ b(gt, ¬_one_case); | |
580 ArraySingleArgumentConstructorStub single_argument_stub; | |
581 __ TailCallStub(&single_argument_stub); | |
582 | |
583 __ bind(¬_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 } | 564 } |
599 | 565 |
600 | 566 |
601 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 567 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
602 // ----------- S t a t e ------------- | 568 // ----------- S t a t e ------------- |
603 // -- r0 : number of arguments | 569 // -- r0 : number of arguments |
604 // -- r1 : constructor function | 570 // -- r1 : constructor function |
605 // -- lr : return address | 571 // -- lr : return address |
606 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 572 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
607 // -- sp[argc * 4] : receiver | 573 // -- sp[argc * 4] : receiver |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 __ bind(&dont_adapt_arguments); | 1871 __ bind(&dont_adapt_arguments); |
1906 __ Jump(r3); | 1872 __ Jump(r3); |
1907 } | 1873 } |
1908 | 1874 |
1909 | 1875 |
1910 #undef __ | 1876 #undef __ |
1911 | 1877 |
1912 } } // namespace v8::internal | 1878 } } // namespace v8::internal |
1913 | 1879 |
1914 #endif // V8_TARGET_ARCH_ARM | 1880 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |