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 disable_allocation_sites, | 109 ContextCheckMode context_mode, |
| 110 AllocationSiteOverrideMode override_mode, |
110 ArgumentClass argument_class); | 111 ArgumentClass argument_class); |
111 HValue* BuildInternalArrayConstructor(ElementsKind kind, | 112 HValue* BuildInternalArrayConstructor(ElementsKind kind, |
112 ArgumentClass argument_class); | 113 ArgumentClass argument_class); |
113 | 114 |
114 private: | 115 private: |
115 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); | 116 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); |
116 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, | 117 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, |
117 ElementsKind kind); | 118 ElementsKind kind); |
118 | 119 |
119 SmartArrayPointer<HParameter*> parameters_; | 120 SmartArrayPointer<HParameter*> parameters_; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 528 |
528 return js_array; | 529 return js_array; |
529 } | 530 } |
530 | 531 |
531 | 532 |
532 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 533 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
533 return DoGenerateCode(this); | 534 return DoGenerateCode(this); |
534 } | 535 } |
535 | 536 |
536 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( | 537 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( |
537 ElementsKind kind, bool disable_allocation_sites, | 538 ElementsKind kind, |
| 539 ContextCheckMode context_mode, |
| 540 AllocationSiteOverrideMode override_mode, |
538 ArgumentClass argument_class) { | 541 ArgumentClass argument_class) { |
539 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); | 542 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); |
| 543 if (context_mode == CONTEXT_CHECK_REQUIRED) { |
| 544 HInstruction* array_function = BuildGetArrayFunction(context()); |
| 545 ArrayContextChecker checker(this, constructor, array_function); |
| 546 } |
| 547 |
540 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); | 548 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); |
541 HInstruction* array_function = BuildGetArrayFunction(context()); | 549 JSArrayBuilder array_builder(this, kind, property_cell, constructor, |
542 | 550 override_mode); |
543 ArrayContextChecker(this, constructor, array_function); | |
544 JSArrayBuilder array_builder(this, kind, property_cell, | |
545 disable_allocation_sites); | |
546 HValue* result = NULL; | 551 HValue* result = NULL; |
547 switch (argument_class) { | 552 switch (argument_class) { |
548 case NONE: | 553 case NONE: |
549 result = array_builder.AllocateEmptyArray(); | 554 result = array_builder.AllocateEmptyArray(); |
550 break; | 555 break; |
551 case SINGLE: | 556 case SINGLE: |
552 result = BuildArraySingleArgumentConstructor(&array_builder); | 557 result = BuildArraySingleArgumentConstructor(&array_builder); |
553 break; | 558 break; |
554 case MULTIPLE: | 559 case MULTIPLE: |
555 result = BuildArrayNArgumentsConstructor(&array_builder, kind); | 560 result = BuildArrayNArgumentsConstructor(&array_builder, kind); |
556 break; | 561 break; |
557 } | 562 } |
| 563 |
558 return result; | 564 return result; |
559 } | 565 } |
560 | 566 |
561 | 567 |
562 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( | 568 HValue* CodeStubGraphBuilderBase::BuildInternalArrayConstructor( |
563 ElementsKind kind, ArgumentClass argument_class) { | 569 ElementsKind kind, ArgumentClass argument_class) { |
564 HValue* constructor = GetParameter( | 570 HValue* constructor = GetParameter( |
565 InternalArrayConstructorStubBase::kConstructor); | 571 InternalArrayConstructorStubBase::kConstructor); |
566 JSArrayBuilder array_builder(this, kind, constructor); | 572 JSArrayBuilder array_builder(this, kind, constructor); |
567 | 573 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 651 |
646 AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind)); | 652 AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind)); |
647 builder.EndBody(); | 653 builder.EndBody(); |
648 return new_object; | 654 return new_object; |
649 } | 655 } |
650 | 656 |
651 | 657 |
652 template <> | 658 template <> |
653 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { | 659 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
654 ElementsKind kind = casted_stub()->elements_kind(); | 660 ElementsKind kind = casted_stub()->elements_kind(); |
655 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 661 ContextCheckMode context_mode = casted_stub()->context_mode(); |
656 return BuildArrayConstructor(kind, disable_allocation_sites, NONE); | 662 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
| 663 return BuildArrayConstructor(kind, context_mode, override_mode, NONE); |
657 } | 664 } |
658 | 665 |
659 | 666 |
660 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { | 667 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { |
661 return DoGenerateCode(this); | 668 return DoGenerateCode(this); |
662 } | 669 } |
663 | 670 |
664 | 671 |
665 template <> | 672 template <> |
666 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: | 673 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: |
667 BuildCodeStub() { | 674 BuildCodeStub() { |
668 ElementsKind kind = casted_stub()->elements_kind(); | 675 ElementsKind kind = casted_stub()->elements_kind(); |
669 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 676 ContextCheckMode context_mode = casted_stub()->context_mode(); |
670 return BuildArrayConstructor(kind, disable_allocation_sites, SINGLE); | 677 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
| 678 return BuildArrayConstructor(kind, context_mode, override_mode, SINGLE); |
671 } | 679 } |
672 | 680 |
673 | 681 |
674 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { | 682 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { |
675 return DoGenerateCode(this); | 683 return DoGenerateCode(this); |
676 } | 684 } |
677 | 685 |
678 | 686 |
679 template <> | 687 template <> |
680 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { | 688 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { |
681 ElementsKind kind = casted_stub()->elements_kind(); | 689 ElementsKind kind = casted_stub()->elements_kind(); |
682 bool disable_allocation_sites = casted_stub()->disable_allocation_sites(); | 690 ContextCheckMode context_mode = casted_stub()->context_mode(); |
683 return BuildArrayConstructor(kind, disable_allocation_sites, MULTIPLE); | 691 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
| 692 return BuildArrayConstructor(kind, context_mode, override_mode, MULTIPLE); |
684 } | 693 } |
685 | 694 |
686 | 695 |
687 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 696 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
688 return DoGenerateCode(this); | 697 return DoGenerateCode(this); |
689 } | 698 } |
690 | 699 |
691 | 700 |
692 template <> | 701 template <> |
693 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: | 702 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 return graph()->GetConstant0(); | 777 return graph()->GetConstant0(); |
769 } | 778 } |
770 | 779 |
771 | 780 |
772 Handle<Code> ToBooleanStub::GenerateCode() { | 781 Handle<Code> ToBooleanStub::GenerateCode() { |
773 return DoGenerateCode(this); | 782 return DoGenerateCode(this); |
774 } | 783 } |
775 | 784 |
776 | 785 |
777 } } // namespace v8::internal | 786 } } // namespace v8::internal |
OLD | NEW |