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

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: review feedback Created 8 years, 10 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
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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 private: 1934 private:
1913 BuiltinFunctionId op_; 1935 BuiltinFunctionId op_;
1914 }; 1936 };
1915 1937
1916 1938
1917 class HLoadElements: public HUnaryOperation { 1939 class HLoadElements: public HUnaryOperation {
1918 public: 1940 public:
1919 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { 1941 explicit HLoadElements(HValue* value) : HUnaryOperation(value) {
1920 set_representation(Representation::Tagged()); 1942 set_representation(Representation::Tagged());
1921 SetFlag(kUseGVN); 1943 SetFlag(kUseGVN);
1922 SetGVNFlag(kDependsOnMaps); 1944 SetGVNFlag(kDependsOnElementsPointer);
1923 SetGVNFlag(kDependsOnElementsKind);
1924 } 1945 }
1925 1946
1926 virtual Representation RequiredInputRepresentation(int index) { 1947 virtual Representation RequiredInputRepresentation(int index) {
1927 return Representation::Tagged(); 1948 return Representation::Tagged();
1928 } 1949 }
1929 1950
1930 DECLARE_CONCRETE_INSTRUCTION(LoadElements) 1951 DECLARE_CONCRETE_INSTRUCTION(LoadElements)
1931 1952
1932 protected: 1953 protected:
1933 virtual bool DataEquals(HValue* other) { return true; } 1954 virtual bool DataEquals(HValue* other) { return true; }
(...skipping 30 matching lines...) Expand all
1964 CompareMapMode mode = REQUIRE_EXACT_MAP) 1985 CompareMapMode mode = REQUIRE_EXACT_MAP)
1965 : map_(map), 1986 : map_(map),
1966 mode_(mode) { 1987 mode_(mode) {
1967 SetOperandAt(0, value); 1988 SetOperandAt(0, value);
1968 // If callers don't depend on a typecheck, they can pass in NULL. In that 1989 // If callers don't depend on a typecheck, they can pass in NULL. In that
1969 // case we use a copy of the |value| argument as a dummy value. 1990 // case we use a copy of the |value| argument as a dummy value.
1970 SetOperandAt(1, typecheck != NULL ? typecheck : value); 1991 SetOperandAt(1, typecheck != NULL ? typecheck : value);
1971 set_representation(Representation::Tagged()); 1992 set_representation(Representation::Tagged());
1972 SetFlag(kUseGVN); 1993 SetFlag(kUseGVN);
1973 SetGVNFlag(kDependsOnMaps); 1994 SetGVNFlag(kDependsOnMaps);
1995 if (mode == REQUIRE_EXACT_MAP) {
1996 SetGVNFlag(kDependsOnElementsKind);
1997 }
1974 has_element_transitions_ = 1998 has_element_transitions_ =
1975 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL || 1999 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL ||
1976 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL; 2000 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL;
1977 } 2001 }
1978 2002
1979 virtual Representation RequiredInputRepresentation(int index) { 2003 virtual Representation RequiredInputRepresentation(int index) {
1980 return Representation::Tagged(); 2004 return Representation::Tagged();
1981 } 2005 }
1982 virtual void PrintDataTo(StringStream* stream); 2006 virtual void PrintDataTo(StringStream* stream);
1983 virtual HType CalculateInferredType(); 2007 virtual HType CalculateInferredType();
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 4151
4128 class HTransitionElementsKind: public HTemplateInstruction<1> { 4152 class HTransitionElementsKind: public HTemplateInstruction<1> {
4129 public: 4153 public:
4130 HTransitionElementsKind(HValue* object, 4154 HTransitionElementsKind(HValue* object,
4131 Handle<Map> original_map, 4155 Handle<Map> original_map,
4132 Handle<Map> transitioned_map) 4156 Handle<Map> transitioned_map)
4133 : original_map_(original_map), 4157 : original_map_(original_map),
4134 transitioned_map_(transitioned_map) { 4158 transitioned_map_(transitioned_map) {
4135 SetOperandAt(0, object); 4159 SetOperandAt(0, object);
4136 SetFlag(kUseGVN); 4160 SetFlag(kUseGVN);
4161 SetGVNFlag(kDependsOnMaps);
4137 SetGVNFlag(kChangesElementsKind); 4162 SetGVNFlag(kChangesElementsKind);
4163 if (original_map->has_fast_double_elements()) {
4164 SetGVNFlag(kChangesElementsPointer);
4165 SetGVNFlag(kDependsOnElementsPointer);
4166 SetGVNFlag(kDependsOnDoubleArrayElements);
4167 } else if (transitioned_map->has_fast_double_elements()) {
4168 SetGVNFlag(kChangesElementsPointer);
4169 SetGVNFlag(kDependsOnElementsPointer);
4170 SetGVNFlag(kDependsOnArrayElements);
4171 }
4138 set_representation(Representation::Tagged()); 4172 set_representation(Representation::Tagged());
4139 } 4173 }
4140 4174
4141 virtual Representation RequiredInputRepresentation(int index) { 4175 virtual Representation RequiredInputRepresentation(int index) {
4142 return Representation::Tagged(); 4176 return Representation::Tagged();
4143 } 4177 }
4144 4178
4179 virtual bool HasOneTimeSideEffects() const {
4180 return true;
4181 }
4182
4145 HValue* object() { return OperandAt(0); } 4183 HValue* object() { return OperandAt(0); }
4146 Handle<Map> original_map() { return original_map_; } 4184 Handle<Map> original_map() { return original_map_; }
4147 Handle<Map> transitioned_map() { return transitioned_map_; } 4185 Handle<Map> transitioned_map() { return transitioned_map_; }
4148 4186
4149 virtual void PrintDataTo(StringStream* stream); 4187 virtual void PrintDataTo(StringStream* stream);
4150 4188
4151 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) 4189 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
4152 4190
4153 protected: 4191 protected:
4154 virtual bool DataEquals(HValue* other) { 4192 virtual bool DataEquals(HValue* other) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 4596
4559 DECLARE_CONCRETE_INSTRUCTION(In) 4597 DECLARE_CONCRETE_INSTRUCTION(In)
4560 }; 4598 };
4561 4599
4562 #undef DECLARE_INSTRUCTION 4600 #undef DECLARE_INSTRUCTION
4563 #undef DECLARE_CONCRETE_INSTRUCTION 4601 #undef DECLARE_CONCRETE_INSTRUCTION
4564 4602
4565 } } // namespace v8::internal 4603 } } // namespace v8::internal
4566 4604
4567 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4605 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698