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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 HValue* GetArgumentsLength() { | 74 HValue* GetArgumentsLength() { |
75 // This is initialized in BuildGraph() | 75 // This is initialized in BuildGraph() |
76 ASSERT(arguments_length_ != NULL); | 76 ASSERT(arguments_length_ != NULL); |
77 return arguments_length_; | 77 return arguments_length_; |
78 } | 78 } |
79 CompilationInfo* info() { return &info_; } | 79 CompilationInfo* info() { return &info_; } |
80 HydrogenCodeStub* stub() { return info_.code_stub(); } | 80 HydrogenCodeStub* stub() { return info_.code_stub(); } |
81 HContext* context() { return context_; } | 81 HContext* context() { return context_; } |
82 Isolate* isolate() { return info_.isolate(); } | 82 Isolate* isolate() { return info_.isolate(); } |
83 | 83 |
84 class ArrayContextChecker { | |
85 public: | |
86 ArrayContextChecker(HGraphBuilder* builder, HValue* constructor, | |
87 HValue* array_function) | |
88 : checker_(builder) { | |
89 checker_.If<HCompareObjectEqAndBranch, HValue*>(constructor, | |
90 array_function); | |
91 checker_.Then(); | |
92 } | |
93 | |
94 ~ArrayContextChecker() { | |
95 checker_.ElseDeopt("Array constructor called from different context"); | |
96 checker_.End(); | |
97 } | |
98 private: | |
99 IfBuilder checker_; | |
100 }; | |
101 | |
102 enum ArgumentClass { | 84 enum ArgumentClass { |
103 NONE, | 85 NONE, |
104 SINGLE, | 86 SINGLE, |
105 MULTIPLE | 87 MULTIPLE |
106 }; | 88 }; |
107 | 89 |
108 HValue* BuildArrayConstructor(ElementsKind kind, | 90 HValue* BuildArrayConstructor(ElementsKind kind, |
109 ContextCheckMode context_mode, | |
110 AllocationSiteOverrideMode override_mode, | 91 AllocationSiteOverrideMode override_mode, |
111 ArgumentClass argument_class); | 92 ArgumentClass argument_class); |
112 HValue* BuildInternalArrayConstructor(ElementsKind kind, | 93 HValue* BuildInternalArrayConstructor(ElementsKind kind, |
113 ArgumentClass argument_class); | 94 ArgumentClass argument_class); |
114 | 95 |
115 void BuildInstallOptimizedCode(HValue* js_function, HValue* native_context, | 96 void BuildInstallOptimizedCode(HValue* js_function, HValue* native_context, |
116 HValue* code_object); | 97 HValue* code_object); |
117 void BuildInstallCode(HValue* js_function, HValue* shared_info); | 98 void BuildInstallCode(HValue* js_function, HValue* shared_info); |
118 void BuildInstallFromOptimizedCodeMap(HValue* js_function, | 99 void BuildInstallFromOptimizedCodeMap(HValue* js_function, |
119 HValue* shared_info, | 100 HValue* shared_info, |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 return GetParameter(0); | 646 return GetParameter(0); |
666 } | 647 } |
667 | 648 |
668 | 649 |
669 Handle<Code> TransitionElementsKindStub::GenerateCode(Isolate* isolate) { | 650 Handle<Code> TransitionElementsKindStub::GenerateCode(Isolate* isolate) { |
670 return DoGenerateCode(isolate, this); | 651 return DoGenerateCode(isolate, this); |
671 } | 652 } |
672 | 653 |
673 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( | 654 HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( |
674 ElementsKind kind, | 655 ElementsKind kind, |
675 ContextCheckMode context_mode, | |
676 AllocationSiteOverrideMode override_mode, | 656 AllocationSiteOverrideMode override_mode, |
677 ArgumentClass argument_class) { | 657 ArgumentClass argument_class) { |
678 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); | 658 HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor); |
679 if (context_mode == CONTEXT_CHECK_REQUIRED) { | |
680 HInstruction* array_function = BuildGetArrayFunction(); | |
681 ArrayContextChecker checker(this, constructor, array_function); | |
682 } | |
683 | |
684 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); | 659 HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); |
685 // Walk through the property cell to the AllocationSite | 660 // Walk through the property cell to the AllocationSite |
686 HValue* alloc_site = Add<HLoadNamedField>(property_cell, | 661 HValue* alloc_site = Add<HLoadNamedField>(property_cell, |
687 HObjectAccess::ForCellValue()); | 662 HObjectAccess::ForCellValue()); |
688 JSArrayBuilder array_builder(this, kind, alloc_site, constructor, | 663 JSArrayBuilder array_builder(this, kind, alloc_site, constructor, |
689 override_mode); | 664 override_mode); |
690 HValue* result = NULL; | 665 HValue* result = NULL; |
691 switch (argument_class) { | 666 switch (argument_class) { |
692 case NONE: | 667 case NONE: |
693 result = array_builder.AllocateEmptyArray(); | 668 result = array_builder.AllocateEmptyArray(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 | 755 |
781 Add<HStoreKeyed>(elements, key, argument, kind); | 756 Add<HStoreKeyed>(elements, key, argument, kind); |
782 builder.EndBody(); | 757 builder.EndBody(); |
783 return new_object; | 758 return new_object; |
784 } | 759 } |
785 | 760 |
786 | 761 |
787 template <> | 762 template <> |
788 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { | 763 HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
789 ElementsKind kind = casted_stub()->elements_kind(); | 764 ElementsKind kind = casted_stub()->elements_kind(); |
790 ContextCheckMode context_mode = casted_stub()->context_mode(); | |
791 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); | 765 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
792 return BuildArrayConstructor(kind, context_mode, override_mode, NONE); | 766 return BuildArrayConstructor(kind, override_mode, NONE); |
793 } | 767 } |
794 | 768 |
795 | 769 |
796 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode(Isolate* isolate) { | 770 Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode(Isolate* isolate) { |
797 return DoGenerateCode(isolate, this); | 771 return DoGenerateCode(isolate, this); |
798 } | 772 } |
799 | 773 |
800 | 774 |
801 template <> | 775 template <> |
802 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: | 776 HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: |
803 BuildCodeStub() { | 777 BuildCodeStub() { |
804 ElementsKind kind = casted_stub()->elements_kind(); | 778 ElementsKind kind = casted_stub()->elements_kind(); |
805 ContextCheckMode context_mode = casted_stub()->context_mode(); | |
806 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); | 779 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
807 return BuildArrayConstructor(kind, context_mode, override_mode, SINGLE); | 780 return BuildArrayConstructor(kind, override_mode, SINGLE); |
808 } | 781 } |
809 | 782 |
810 | 783 |
811 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode( | 784 Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode( |
812 Isolate* isolate) { | 785 Isolate* isolate) { |
813 return DoGenerateCode(isolate, this); | 786 return DoGenerateCode(isolate, this); |
814 } | 787 } |
815 | 788 |
816 | 789 |
817 template <> | 790 template <> |
818 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { | 791 HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { |
819 ElementsKind kind = casted_stub()->elements_kind(); | 792 ElementsKind kind = casted_stub()->elements_kind(); |
820 ContextCheckMode context_mode = casted_stub()->context_mode(); | |
821 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); | 793 AllocationSiteOverrideMode override_mode = casted_stub()->override_mode(); |
822 return BuildArrayConstructor(kind, context_mode, override_mode, MULTIPLE); | 794 return BuildArrayConstructor(kind, override_mode, MULTIPLE); |
823 } | 795 } |
824 | 796 |
825 | 797 |
826 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode(Isolate* isolate) { | 798 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode(Isolate* isolate) { |
827 return DoGenerateCode(isolate, this); | 799 return DoGenerateCode(isolate, this); |
828 } | 800 } |
829 | 801 |
830 | 802 |
831 template <> | 803 template <> |
832 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: | 804 HValue* CodeStubGraphBuilder<InternalArrayNoArgumentConstructorStub>:: |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 return BuildUncheckedDictionaryElementLoad(receiver, key); | 1346 return BuildUncheckedDictionaryElementLoad(receiver, key); |
1375 } | 1347 } |
1376 | 1348 |
1377 | 1349 |
1378 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { | 1350 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { |
1379 return DoGenerateCode(isolate, this); | 1351 return DoGenerateCode(isolate, this); |
1380 } | 1352 } |
1381 | 1353 |
1382 | 1354 |
1383 } } // namespace v8::internal | 1355 } } // namespace v8::internal |
OLD | NEW |