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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 IfBuilder checker_; | 99 IfBuilder checker_; |
100 }; | 100 }; |
101 | 101 |
102 enum ArgumentClass { | 102 enum ArgumentClass { |
103 NONE, | 103 NONE, |
104 SINGLE, | 104 SINGLE, |
105 MULTIPLE | 105 MULTIPLE |
106 }; | 106 }; |
107 | 107 |
108 HValue* BuildArrayConstructor(ElementsKind kind, | 108 HValue* BuildArrayConstructor(ElementsKind kind, |
109 bool ensure_context, | |
danno
2013/06/27 08:53:04
Turn this boolean parameter into an enum, it make
mvstanton
2013/06/27 15:33:29
Done.
| |
109 bool disable_allocation_sites, | 110 bool disable_allocation_sites, |
danno
2013/06/27 08:53:04
Turn this boolean parameter into an enum, it make
mvstanton
2013/06/27 15:33:29
Done.
| |
110 ArgumentClass argument_class); | 111 ArgumentClass argument_class); |
112 HValue* BuildArrayConstructorImpl(ElementsKind kind, | |
113 HValue* constructor, | |
114 bool disable_allocation_sites, | |
danno
2013/06/27 08:53:04
Same as above
mvstanton
2013/06/27 15:33:29
Done.
| |
115 ArgumentClass argument_class); | |
111 HValue* BuildInternalArrayConstructor(ElementsKind kind, | 116 HValue* BuildInternalArrayConstructor(ElementsKind kind, |
112 ArgumentClass argument_class); | 117 ArgumentClass argument_class); |
113 | 118 |
114 private: | 119 private: |
115 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); | 120 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); |
116 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, | 121 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, |
117 ElementsKind kind); | 122 ElementsKind kind); |
118 | 123 |
119 SmartArrayPointer<HParameter*> parameters_; | 124 SmartArrayPointer<HParameter*> parameters_; |
120 HValue* arguments_length_; | 125 HValue* arguments_length_; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 | 532 |
528 return js_array; | 533 return js_array; |
529 } | 534 } |
530 | 535 |
531 | 536 |
532 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 537 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
533 return DoGenerateCode(this); | 538 return DoGenerateCode(this); |
534 } | 539 } |
535 | 540 |
536 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( | 541 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( |
537 ElementsKind kind, bool disable_allocation_sites, | 542 ElementsKind kind, |
543 bool ensure_context, | |
544 bool disable_allocation_sites, | |
538 ArgumentClass argument_class) { | 545 ArgumentClass argument_class) { |
539 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); | 546 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); |
547 if (ensure_context) { | |
548 HInstruction* array_function = BuildGetArrayFunction(context()); | |
549 ArrayContextChecker checker(this, constructor, array_function); | |
550 return BuildArrayConstructorImpl(kind, constructor, | |
danno
2013/06/27 08:53:04
the return clause is common code, how about factor
mvstanton
2013/06/27 15:33:29
Thanks, I initially tried that and ran into some I
| |
551 disable_allocation_sites, argument_class); | |
552 } else { | |
553 return BuildArrayConstructorImpl(kind, constructor, | |
554 disable_allocation_sites, argument_class); | |
555 } | |
556 } | |
557 | |
558 | |
559 HValue* CodeStubGraphBuilderBase::BuildArrayConstructorImpl( | |
560 ElementsKind kind, | |
561 HValue* constructor, | |
562 bool disable_allocation_sites, | |
563 ArgumentClass argument_class) { | |
540 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); | 564 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); |
541 HInstruction* array_function = BuildGetArrayFunction(context()); | 565 JSArrayBuilder array_builder(this, kind, property_cell, constructor, |
542 | |
543 ArrayContextChecker(this, constructor, array_function); | |
544 JSArrayBuilder array_builder(this, kind, property_cell, | |
545 disable_allocation_sites); | 566 disable_allocation_sites); |
546 HValue* result = NULL; | 567 HValue* result = NULL; |
547 switch (argument_class) { | 568 switch (argument_class) { |
548 case NONE: | 569 case NONE: |
549 result = array_builder.AllocateEmptyArray(); | 570 result = array_builder.AllocateEmptyArray(); |
550 break; | 571 break; |
551 case SINGLE: | 572 case SINGLE: |
552 result = BuildArraySingleArgumentConstructor(&array_builder); | 573 result = BuildArraySingleArgumentConstructor(&array_builder); |
553 break; | 574 break; |
554 case MULTIPLE: | 575 case MULTIPLE: |
555 result = BuildArrayNArgumentsConstructor(&array_builder, kind); | 576 result = BuildArrayNArgumentsConstructor(&array_builder, kind); |
556 break; | 577 break; |
557 } | 578 } |
579 | |
danno
2013/06/27 08:53:04
Not sure this additional line makes a big differen
mvstanton
2013/06/27 15:33:29
Done.
| |
558 return result; | 580 return result; |
559 } | 581 } |
560 | 582 |
561 | 583 |
562 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( | 584 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( |
563 ElementsKind kind, ArgumentClass argument_class) { | 585 ElementsKind kind, ArgumentClass argument_class) { |
564 HValue* constructor = GetParameter( | 586 HValue* constructor = GetParameter( |
565 InternalArrayConstructorStubBase::kConstructor); | 587 InternalArrayConstructorStubBase::kConstructor); |
566 JSArrayBuilder array_builder(this, kind, constructor); | 588 JSArrayBuilder array_builder(this, kind, constructor); |
567 | 589 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 | 667 |
646 AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind)); | 668 AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind)); |
647 builder.EndBody(); | 669 builder.EndBody(); |
648 return new_object; | 670 return new_object; |
649 } | 671 } |
650 | 672 |
651 | 673 |
652 template <> | 674 template <> |
653 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { | 675 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
654 ElementsKind kind = casted_stub()->elements_kind(); | 676 ElementsKind kind = casted_stub()->elements_kind(); |
677 bool ensure_context = casted_stub()->ensure_context(); | |
655 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 678 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); |
656 return BuildArrayConstructor(kind, disable_allocation_sites, NONE); | 679 return BuildArrayConstructor(kind, ensure_context, disable_allocation_sites, |
680 NONE); | |
657 } | 681 } |
658 | 682 |
659 | 683 |
660 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { | 684 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { |
661 return DoGenerateCode(this); | 685 return DoGenerateCode(this); |
662 } | 686 } |
663 | 687 |
664 | 688 |
665 template <> | 689 template <> |
666 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: | 690 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: |
667 BuildCodeStub() { | 691 BuildCodeStub() { |
668 ElementsKind kind = casted_stub()->elements_kind(); | 692 ElementsKind kind = casted_stub()->elements_kind(); |
693 bool ensure_context = casted_stub()->ensure_context(); | |
669 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 694 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); |
670 return BuildArrayConstructor(kind, disable_allocation_sites, SINGLE); | 695 return BuildArrayConstructor(kind, ensure_context, disable_allocation_sites, |
696 SINGLE); | |
671 } | 697 } |
672 | 698 |
673 | 699 |
674 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { | 700 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { |
675 return DoGenerateCode(this); | 701 return DoGenerateCode(this); |
676 } | 702 } |
677 | 703 |
678 | 704 |
679 template <> | 705 template <> |
680 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { | 706 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { |
681 ElementsKind kind = casted_stub()->elements_kind(); | 707 ElementsKind kind = casted_stub()->elements_kind(); |
708 bool ensure_context = casted_stub()->ensure_context(); | |
682 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 709 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); |
683 return BuildArrayConstructor(kind, disable_allocation_sites, MULTIPLE); | 710 return BuildArrayConstructor(kind, ensure_context, disable_allocation_sites, |
711 MULTIPLE); | |
684 } | 712 } |
685 | 713 |
686 | 714 |
687 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 715 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
688 return DoGenerateCode(this); | 716 return DoGenerateCode(this); |
689 } | 717 } |
690 | 718 |
691 | 719 |
692 template <> | 720 template <> |
693 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: | 721 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 return graph()->GetConstant0(); | 796 return graph()->GetConstant0(); |
769 } | 797 } |
770 | 798 |
771 | 799 |
772 Handle<Code> ToBooleanStub::GenerateCode() { | 800 Handle<Code> ToBooleanStub::GenerateCode() { |
773 return DoGenerateCode(this); | 801 return DoGenerateCode(this); |
774 } | 802 } |
775 | 803 |
776 | 804 |
777 } } // namespace v8::internal | 805 } } // namespace v8::internal |
OLD | NEW |