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

Side by Side Diff: src/hydrogen-instructions.h

Issue 9141016: Improve GVN handling of ElementTransitions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove debugging code Created 8 years, 11 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
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | no next file » | 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 V(UnaryMathOperation) \ 179 V(UnaryMathOperation) \
180 V(UnknownOSRValue) \ 180 V(UnknownOSRValue) \
181 V(UseConst) \ 181 V(UseConst) \
182 V(ValueOf) 182 V(ValueOf)
183 183
184 #define GVN_FLAG_LIST(V) \ 184 #define GVN_FLAG_LIST(V) \
185 V(Calls) \ 185 V(Calls) \
186 V(InobjectFields) \ 186 V(InobjectFields) \
187 V(BackingStoreFields) \ 187 V(BackingStoreFields) \
188 V(ElementsKind) \ 188 V(ElementsKind) \
189 V(ElementsPointer) \
189 V(ArrayElements) \ 190 V(ArrayElements) \
190 V(DoubleArrayElements) \ 191 V(DoubleArrayElements) \
191 V(SpecializedArrayElements) \ 192 V(SpecializedArrayElements) \
192 V(GlobalVars) \ 193 V(GlobalVars) \
193 V(Maps) \ 194 V(Maps) \
194 V(ArrayLengths) \ 195 V(ArrayLengths) \
195 V(ContextSlots) \ 196 V(ContextSlots) \
196 V(OsrEntries) 197 V(OsrEntries)
197 198
198 #define DECLARE_ABSTRACT_INSTRUCTION(type) \ 199 #define DECLARE_ABSTRACT_INSTRUCTION(type) \
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 void ClearAllSideEffects() { 639 void ClearAllSideEffects() {
639 gvn_flags_.Remove(AllSideEffectsFlagSet()); 640 gvn_flags_.Remove(AllSideEffectsFlagSet());
640 } 641 }
641 bool HasSideEffects() const { 642 bool HasSideEffects() const {
642 return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet()); 643 return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet());
643 } 644 }
644 bool HasObservableSideEffects() const { 645 bool HasObservableSideEffects() const {
645 return gvn_flags_.ContainsAnyOf(AllObservableSideEffectsFlagSet()); 646 return gvn_flags_.ContainsAnyOf(AllObservableSideEffectsFlagSet());
646 } 647 }
647 648
649 GVNFlagSet DependsOnFlags() const {
650 GVNFlagSet result = gvn_flags_;
651 result.Intersect(AllDependsOnFlagSet());
652 return result;
653 }
654
648 GVNFlagSet ChangesFlags() const { 655 GVNFlagSet ChangesFlags() const {
649 GVNFlagSet result = gvn_flags_; 656 GVNFlagSet result = gvn_flags_;
650 result.Intersect(AllChangesFlagSet()); 657 result.Intersect(AllChangesFlagSet());
651 return result; 658 return result;
652 } 659 }
653 660
654 GVNFlagSet ObservableChangesFlags() const { 661 GVNFlagSet ObservableChangesFlags() const {
655 GVNFlagSet result = gvn_flags_; 662 GVNFlagSet result = gvn_flags_;
656 result.Intersect(AllChangesFlagSet()); 663 result.Intersect(AllChangesFlagSet());
657 result.Intersect(AllObservableSideEffectsFlagSet()); 664 result.Intersect(AllObservableSideEffectsFlagSet());
658 return result; 665 return result;
659 } 666 }
660 667
668 virtual bool HasOneTimeSideEffects() const {
669 return false;
670 }
671
661 Range* range() const { return range_; } 672 Range* range() const { return range_; }
662 bool HasRange() const { return range_ != NULL; } 673 bool HasRange() const { return range_ != NULL; }
663 void AddNewRange(Range* r); 674 void AddNewRange(Range* r);
664 void RemoveLastAddedRange(); 675 void RemoveLastAddedRange();
665 void ComputeInitialRange(); 676 void ComputeInitialRange();
666 677
667 // Representation helpers. 678 // Representation helpers.
668 virtual Representation RequiredInputRepresentation(int index) = 0; 679 virtual Representation RequiredInputRepresentation(int index) = 0;
669 680
670 virtual Representation InferredRepresentation() { 681 virtual Representation InferredRepresentation() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 ASSERT(block_ != NULL); 725 ASSERT(block_ != NULL);
715 block_ = NULL; 726 block_ = NULL;
716 } 727 }
717 728
718 void set_representation(Representation r) { 729 void set_representation(Representation r) {
719 // Representation is set-once. 730 // Representation is set-once.
720 ASSERT(representation_.IsNone() && !r.IsNone()); 731 ASSERT(representation_.IsNone() && !r.IsNone());
721 representation_ = r; 732 representation_ = r;
722 } 733 }
723 734
735 static GVNFlagSet AllDependsOnFlagSet() {
736 GVNFlagSet result;
737 // Create changes mask.
738 #define ADD_FLAG(type) result.Add(kDependsOn##type);
739 GVN_FLAG_LIST(ADD_FLAG)
740 #undef ADD_FLAG
741 return result;
742 }
743
724 static GVNFlagSet AllChangesFlagSet() { 744 static GVNFlagSet AllChangesFlagSet() {
725 GVNFlagSet result; 745 GVNFlagSet result;
726 // Create changes mask. 746 // Create changes mask.
727 #define ADD_FLAG(type) result.Add(kChanges##type); 747 #define ADD_FLAG(type) result.Add(kChanges##type);
728 GVN_FLAG_LIST(ADD_FLAG) 748 GVN_FLAG_LIST(ADD_FLAG)
729 #undef ADD_FLAG 749 #undef ADD_FLAG
730 return result; 750 return result;
731 } 751 }
732 752
733 // A flag mask to mark an instruction as having arbitrary side effects. 753 // A flag mask to mark an instruction as having arbitrary side effects.
734 static GVNFlagSet AllSideEffectsFlagSet() { 754 static GVNFlagSet AllSideEffectsFlagSet() {
735 GVNFlagSet result = AllChangesFlagSet(); 755 GVNFlagSet result = AllChangesFlagSet();
736 result.Remove(kChangesOsrEntries); 756 result.Remove(kChangesOsrEntries);
737 return result; 757 return result;
738 } 758 }
739 759
740 // A flag mask of all side effects that can make observable changes in 760 // A flag mask of all side effects that can make observable changes in
741 // an executing program (i.e. are not safe to repeat, move or remove); 761 // an executing program (i.e. are not safe to repeat, move or remove);
742 static GVNFlagSet AllObservableSideEffectsFlagSet() { 762 static GVNFlagSet AllObservableSideEffectsFlagSet() {
743 GVNFlagSet result = AllChangesFlagSet(); 763 GVNFlagSet result = AllChangesFlagSet();
744 result.Remove(kChangesElementsKind); 764 result.Remove(kChangesElementsKind);
765 result.Remove(kChangesElementsPointer);
766 result.Remove(kChangesMaps);
745 return result; 767 return result;
746 } 768 }
747 769
748 // Remove the matching use from the use list if present. Returns the 770 // Remove the matching use from the use list if present. Returns the
749 // removed list node or NULL. 771 // removed list node or NULL.
750 HUseListNode* RemoveUse(HValue* value, int index); 772 HUseListNode* RemoveUse(HValue* value, int index);
751 773
752 void RegisterUse(int index, HValue* new_value); 774 void RegisterUse(int index, HValue* new_value);
753 775
754 HBasicBlock* block_; 776 HBasicBlock* block_;
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 private: 1929 private:
1908 BuiltinFunctionId op_; 1930 BuiltinFunctionId op_;
1909 }; 1931 };
1910 1932
1911 1933
1912 class HLoadElements: public HUnaryOperation { 1934 class HLoadElements: public HUnaryOperation {
1913 public: 1935 public:
1914 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { 1936 explicit HLoadElements(HValue* value) : HUnaryOperation(value) {
1915 set_representation(Representation::Tagged()); 1937 set_representation(Representation::Tagged());
1916 SetFlag(kUseGVN); 1938 SetFlag(kUseGVN);
1917 SetGVNFlag(kDependsOnMaps); 1939 SetGVNFlag(kDependsOnElementsPointer);
1918 SetGVNFlag(kDependsOnElementsKind);
1919 } 1940 }
1920 1941
1921 virtual Representation RequiredInputRepresentation(int index) { 1942 virtual Representation RequiredInputRepresentation(int index) {
1922 return Representation::Tagged(); 1943 return Representation::Tagged();
1923 } 1944 }
1924 1945
1925 DECLARE_CONCRETE_INSTRUCTION(LoadElements) 1946 DECLARE_CONCRETE_INSTRUCTION(LoadElements)
1926 1947
1927 protected: 1948 protected:
1928 virtual bool DataEquals(HValue* other) { return true; } 1949 virtual bool DataEquals(HValue* other) { return true; }
(...skipping 30 matching lines...) Expand all
1959 CompareMapMode mode = REQUIRE_EXACT_MAP) 1980 CompareMapMode mode = REQUIRE_EXACT_MAP)
1960 : map_(map), 1981 : map_(map),
1961 mode_(mode) { 1982 mode_(mode) {
1962 SetOperandAt(0, value); 1983 SetOperandAt(0, value);
1963 // If callers don't depend on a typecheck, they can pass in NULL. In that 1984 // If callers don't depend on a typecheck, they can pass in NULL. In that
1964 // case we use a copy of the |value| argument as a dummy value. 1985 // case we use a copy of the |value| argument as a dummy value.
1965 SetOperandAt(1, typecheck != NULL ? typecheck : value); 1986 SetOperandAt(1, typecheck != NULL ? typecheck : value);
1966 set_representation(Representation::Tagged()); 1987 set_representation(Representation::Tagged());
1967 SetFlag(kUseGVN); 1988 SetFlag(kUseGVN);
1968 SetGVNFlag(kDependsOnMaps); 1989 SetGVNFlag(kDependsOnMaps);
1990 if (mode == REQUIRE_EXACT_MAP) {
1991 SetGVNFlag(kDependsOnElementsKind);
1992 }
1969 has_element_transitions_ = 1993 has_element_transitions_ =
1970 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL || 1994 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL ||
1971 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL; 1995 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL;
1972 } 1996 }
1973 1997
1974 virtual Representation RequiredInputRepresentation(int index) { 1998 virtual Representation RequiredInputRepresentation(int index) {
1975 return Representation::Tagged(); 1999 return Representation::Tagged();
1976 } 2000 }
1977 virtual void PrintDataTo(StringStream* stream); 2001 virtual void PrintDataTo(StringStream* stream);
1978 virtual HType CalculateInferredType(); 2002 virtual HType CalculateInferredType();
(...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4120 4144
4121 class HTransitionElementsKind: public HTemplateInstruction<1> { 4145 class HTransitionElementsKind: public HTemplateInstruction<1> {
4122 public: 4146 public:
4123 HTransitionElementsKind(HValue* object, 4147 HTransitionElementsKind(HValue* object,
4124 Handle<Map> original_map, 4148 Handle<Map> original_map,
4125 Handle<Map> transitioned_map) 4149 Handle<Map> transitioned_map)
4126 : original_map_(original_map), 4150 : original_map_(original_map),
4127 transitioned_map_(transitioned_map) { 4151 transitioned_map_(transitioned_map) {
4128 SetOperandAt(0, object); 4152 SetOperandAt(0, object);
4129 SetFlag(kUseGVN); 4153 SetFlag(kUseGVN);
4154 SetGVNFlag(kDependsOnMaps);
4130 SetGVNFlag(kChangesElementsKind); 4155 SetGVNFlag(kChangesElementsKind);
4156 if (original_map->has_fast_double_elements() ||
4157 transitioned_map->has_fast_double_elements()) {
4158 SetGVNFlag(kChangesElementsPointer);
4159 SetGVNFlag(kDependsOnElementsPointer);
4160 }
4131 set_representation(Representation::Tagged()); 4161 set_representation(Representation::Tagged());
4132 } 4162 }
4133 4163
4134 virtual Representation RequiredInputRepresentation(int index) { 4164 virtual Representation RequiredInputRepresentation(int index) {
4135 return Representation::Tagged(); 4165 return Representation::Tagged();
4136 } 4166 }
4137 4167
4168 virtual bool HasOneTimeSideEffects() const {
4169 return true;
4170 }
4171
4138 HValue* object() { return OperandAt(0); } 4172 HValue* object() { return OperandAt(0); }
4139 Handle<Map> original_map() { return original_map_; } 4173 Handle<Map> original_map() { return original_map_; }
4140 Handle<Map> transitioned_map() { return transitioned_map_; } 4174 Handle<Map> transitioned_map() { return transitioned_map_; }
4141 4175
4142 virtual void PrintDataTo(StringStream* stream); 4176 virtual void PrintDataTo(StringStream* stream);
4143 4177
4144 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) 4178 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
4145 4179
4146 protected: 4180 protected:
4147 virtual bool DataEquals(HValue* other) { 4181 virtual bool DataEquals(HValue* other) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
4551 4585
4552 DECLARE_CONCRETE_INSTRUCTION(In) 4586 DECLARE_CONCRETE_INSTRUCTION(In)
4553 }; 4587 };
4554 4588
4555 #undef DECLARE_INSTRUCTION 4589 #undef DECLARE_INSTRUCTION
4556 #undef DECLARE_CONCRETE_INSTRUCTION 4590 #undef DECLARE_CONCRETE_INSTRUCTION
4557 4591
4558 } } // namespace v8::internal 4592 } } // namespace v8::internal
4559 4593
4560 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4594 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698