Chromium Code Reviews| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 void ClearAllSideEffects() { | 640 void ClearAllSideEffects() { |
| 640 gvn_flags_.Remove(AllSideEffectsFlagSet()); | 641 gvn_flags_.Remove(AllSideEffectsFlagSet()); |
| 641 } | 642 } |
| 642 bool HasSideEffects() const { | 643 bool HasSideEffects() const { |
| 643 return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet()); | 644 return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet()); |
| 644 } | 645 } |
| 645 bool HasObservableSideEffects() const { | 646 bool HasObservableSideEffects() const { |
| 646 return gvn_flags_.ContainsAnyOf(AllObservableSideEffectsFlagSet()); | 647 return gvn_flags_.ContainsAnyOf(AllObservableSideEffectsFlagSet()); |
| 647 } | 648 } |
| 648 | 649 |
| 650 GVNFlagSet DependsOnFlags() const { | |
| 651 GVNFlagSet result = gvn_flags_; | |
| 652 result.Intersect(AllDependsOnFlagSet()); | |
| 653 return result; | |
| 654 } | |
| 655 | |
| 656 GVNFlagSet SideEffectFlags() const { | |
| 657 GVNFlagSet result = gvn_flags_; | |
| 658 result.Intersect(AllSideEffectsFlagSet()); | |
| 659 return result; | |
| 660 } | |
| 661 | |
| 649 GVNFlagSet ChangesFlags() const { | 662 GVNFlagSet ChangesFlags() const { |
| 650 GVNFlagSet result = gvn_flags_; | 663 GVNFlagSet result = gvn_flags_; |
| 651 result.Intersect(AllChangesFlagSet()); | 664 result.Intersect(AllChangesFlagSet()); |
| 652 return result; | 665 return result; |
| 653 } | 666 } |
| 654 | 667 |
| 655 GVNFlagSet ObservableChangesFlags() const { | 668 GVNFlagSet ObservableChangesFlags() const { |
| 656 GVNFlagSet result = gvn_flags_; | 669 GVNFlagSet result = gvn_flags_; |
| 657 result.Intersect(AllChangesFlagSet()); | 670 result.Intersect(AllChangesFlagSet()); |
| 658 result.Intersect(AllObservableSideEffectsFlagSet()); | 671 result.Intersect(AllObservableSideEffectsFlagSet()); |
| 659 return result; | 672 return result; |
| 660 } | 673 } |
| 661 | 674 |
| 675 virtual bool HasOneTimeSideEffects() const { | |
| 676 return false; | |
| 677 } | |
| 678 | |
| 662 Range* range() const { return range_; } | 679 Range* range() const { return range_; } |
| 663 bool HasRange() const { return range_ != NULL; } | 680 bool HasRange() const { return range_ != NULL; } |
| 664 void AddNewRange(Range* r); | 681 void AddNewRange(Range* r); |
| 665 void RemoveLastAddedRange(); | 682 void RemoveLastAddedRange(); |
| 666 void ComputeInitialRange(); | 683 void ComputeInitialRange(); |
| 667 | 684 |
| 668 // Representation helpers. | 685 // Representation helpers. |
| 669 virtual Representation RequiredInputRepresentation(int index) = 0; | 686 virtual Representation RequiredInputRepresentation(int index) = 0; |
| 670 | 687 |
| 671 virtual Representation InferredRepresentation() { | 688 virtual Representation InferredRepresentation() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 ASSERT(block_ != NULL); | 732 ASSERT(block_ != NULL); |
| 716 block_ = NULL; | 733 block_ = NULL; |
| 717 } | 734 } |
| 718 | 735 |
| 719 void set_representation(Representation r) { | 736 void set_representation(Representation r) { |
| 720 // Representation is set-once. | 737 // Representation is set-once. |
| 721 ASSERT(representation_.IsNone() && !r.IsNone()); | 738 ASSERT(representation_.IsNone() && !r.IsNone()); |
| 722 representation_ = r; | 739 representation_ = r; |
| 723 } | 740 } |
| 724 | 741 |
| 742 static GVNFlagSet AllDependsOnFlagSet() { | |
| 743 GVNFlagSet result; | |
| 744 // Create changes mask. | |
| 745 #define ADD_FLAG(type) result.Add(kDependsOn##type); | |
| 746 GVN_FLAG_LIST(ADD_FLAG) | |
| 747 #undef ADD_FLAG | |
| 748 return result; | |
| 749 } | |
| 750 | |
| 725 static GVNFlagSet AllChangesFlagSet() { | 751 static GVNFlagSet AllChangesFlagSet() { |
| 726 GVNFlagSet result; | 752 GVNFlagSet result; |
| 727 // Create changes mask. | 753 // Create changes mask. |
| 728 #define ADD_FLAG(type) result.Add(kChanges##type); | 754 #define ADD_FLAG(type) result.Add(kChanges##type); |
| 729 GVN_FLAG_LIST(ADD_FLAG) | 755 GVN_FLAG_LIST(ADD_FLAG) |
| 730 #undef ADD_FLAG | 756 #undef ADD_FLAG |
| 731 return result; | 757 return result; |
| 732 } | 758 } |
| 733 | 759 |
| 734 // A flag mask to mark an instruction as having arbitrary side effects. | 760 // A flag mask to mark an instruction as having arbitrary side effects. |
| 735 static GVNFlagSet AllSideEffectsFlagSet() { | 761 static GVNFlagSet AllSideEffectsFlagSet() { |
| 736 GVNFlagSet result = AllChangesFlagSet(); | 762 GVNFlagSet result = AllChangesFlagSet(); |
| 737 result.Remove(kChangesOsrEntries); | 763 result.Remove(kChangesOsrEntries); |
| 738 return result; | 764 return result; |
| 739 } | 765 } |
| 740 | 766 |
| 741 // A flag mask of all side effects that can make observable changes in | 767 // A flag mask of all side effects that can make observable changes in |
| 742 // an executing program (i.e. are not safe to repeat, move or remove); | 768 // an executing program (i.e. are not safe to repeat, move or remove); |
| 743 static GVNFlagSet AllObservableSideEffectsFlagSet() { | 769 static GVNFlagSet AllObservableSideEffectsFlagSet() { |
| 744 GVNFlagSet result = AllChangesFlagSet(); | 770 GVNFlagSet result = AllChangesFlagSet(); |
| 745 result.Remove(kChangesElementsKind); | 771 result.Remove(kChangesElementsKind); |
| 772 result.Remove(kChangesElementsPointer); | |
| 773 result.Remove(kChangesMaps); | |
| 746 return result; | 774 return result; |
| 747 } | 775 } |
| 748 | 776 |
| 749 // Remove the matching use from the use list if present. Returns the | 777 // Remove the matching use from the use list if present. Returns the |
| 750 // removed list node or NULL. | 778 // removed list node or NULL. |
| 751 HUseListNode* RemoveUse(HValue* value, int index); | 779 HUseListNode* RemoveUse(HValue* value, int index); |
| 752 | 780 |
| 753 void RegisterUse(int index, HValue* new_value); | 781 void RegisterUse(int index, HValue* new_value); |
| 754 | 782 |
| 755 HBasicBlock* block_; | 783 HBasicBlock* block_; |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1913 private: | 1941 private: |
| 1914 BuiltinFunctionId op_; | 1942 BuiltinFunctionId op_; |
| 1915 }; | 1943 }; |
| 1916 | 1944 |
| 1917 | 1945 |
| 1918 class HLoadElements: public HUnaryOperation { | 1946 class HLoadElements: public HUnaryOperation { |
| 1919 public: | 1947 public: |
| 1920 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { | 1948 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { |
| 1921 set_representation(Representation::Tagged()); | 1949 set_representation(Representation::Tagged()); |
| 1922 SetFlag(kUseGVN); | 1950 SetFlag(kUseGVN); |
| 1923 SetGVNFlag(kDependsOnMaps); | 1951 SetGVNFlag(kDependsOnElementsPointer); |
| 1924 SetGVNFlag(kDependsOnElementsKind); | |
| 1925 } | 1952 } |
| 1926 | 1953 |
| 1927 virtual Representation RequiredInputRepresentation(int index) { | 1954 virtual Representation RequiredInputRepresentation(int index) { |
| 1928 return Representation::Tagged(); | 1955 return Representation::Tagged(); |
| 1929 } | 1956 } |
| 1930 | 1957 |
| 1931 DECLARE_CONCRETE_INSTRUCTION(LoadElements) | 1958 DECLARE_CONCRETE_INSTRUCTION(LoadElements) |
| 1932 | 1959 |
| 1933 protected: | 1960 protected: |
| 1934 virtual bool DataEquals(HValue* other) { return true; } | 1961 virtual bool DataEquals(HValue* other) { return true; } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1965 CompareMapMode mode = REQUIRE_EXACT_MAP) | 1992 CompareMapMode mode = REQUIRE_EXACT_MAP) |
| 1966 : map_(map), | 1993 : map_(map), |
| 1967 mode_(mode) { | 1994 mode_(mode) { |
| 1968 SetOperandAt(0, value); | 1995 SetOperandAt(0, value); |
| 1969 // If callers don't depend on a typecheck, they can pass in NULL. In that | 1996 // If callers don't depend on a typecheck, they can pass in NULL. In that |
| 1970 // case we use a copy of the |value| argument as a dummy value. | 1997 // case we use a copy of the |value| argument as a dummy value. |
| 1971 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 1998 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
| 1972 set_representation(Representation::Tagged()); | 1999 set_representation(Representation::Tagged()); |
| 1973 SetFlag(kUseGVN); | 2000 SetFlag(kUseGVN); |
| 1974 SetGVNFlag(kDependsOnMaps); | 2001 SetGVNFlag(kDependsOnMaps); |
| 2002 // If the map to check doesn't have the untransitioned elements, it must not | |
| 2003 // be hoisted above TransitionElements instructions. | |
| 2004 if (mode == REQUIRE_EXACT_MAP || !map->has_fast_smi_only_elements()) { | |
| 2005 SetGVNFlag(kDependsOnElementsKind); | |
| 2006 } | |
| 1975 has_element_transitions_ = | 2007 has_element_transitions_ = |
| 1976 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL || | 2008 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL || |
| 1977 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL; | 2009 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL; |
| 1978 } | 2010 } |
| 1979 | 2011 |
| 1980 virtual Representation RequiredInputRepresentation(int index) { | 2012 virtual Representation RequiredInputRepresentation(int index) { |
| 1981 return Representation::Tagged(); | 2013 return Representation::Tagged(); |
| 1982 } | 2014 } |
| 1983 virtual void PrintDataTo(StringStream* stream); | 2015 virtual void PrintDataTo(StringStream* stream); |
| 1984 virtual HType CalculateInferredType(); | 2016 virtual HType CalculateInferredType(); |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4128 | 4160 |
| 4129 class HTransitionElementsKind: public HTemplateInstruction<1> { | 4161 class HTransitionElementsKind: public HTemplateInstruction<1> { |
| 4130 public: | 4162 public: |
| 4131 HTransitionElementsKind(HValue* object, | 4163 HTransitionElementsKind(HValue* object, |
| 4132 Handle<Map> original_map, | 4164 Handle<Map> original_map, |
| 4133 Handle<Map> transitioned_map) | 4165 Handle<Map> transitioned_map) |
| 4134 : original_map_(original_map), | 4166 : original_map_(original_map), |
| 4135 transitioned_map_(transitioned_map) { | 4167 transitioned_map_(transitioned_map) { |
| 4136 SetOperandAt(0, object); | 4168 SetOperandAt(0, object); |
| 4137 SetFlag(kUseGVN); | 4169 SetFlag(kUseGVN); |
| 4170 SetGVNFlag(kDependsOnMaps); | |
|
fschneider
2012/02/02 14:59:50
There is currently no instruction that has kChange
danno
2012/02/06 16:54:57
But if we ever add one, then it will be incorrect
| |
| 4138 SetGVNFlag(kChangesElementsKind); | 4171 SetGVNFlag(kChangesElementsKind); |
| 4172 if (original_map->has_fast_double_elements()) { | |
| 4173 SetGVNFlag(kChangesElementsPointer); | |
| 4174 SetGVNFlag(kDependsOnElementsPointer); | |
| 4175 SetGVNFlag(kDependsOnDoubleArrayElements); | |
| 4176 } else if (transitioned_map->has_fast_double_elements()) { | |
| 4177 SetGVNFlag(kChangesElementsPointer); | |
| 4178 SetGVNFlag(kDependsOnElementsPointer); | |
| 4179 SetGVNFlag(kDependsOnArrayElements); | |
| 4180 } | |
| 4139 set_representation(Representation::Tagged()); | 4181 set_representation(Representation::Tagged()); |
| 4140 } | 4182 } |
| 4141 | 4183 |
| 4142 virtual Representation RequiredInputRepresentation(int index) { | 4184 virtual Representation RequiredInputRepresentation(int index) { |
| 4143 return Representation::Tagged(); | 4185 return Representation::Tagged(); |
| 4144 } | 4186 } |
| 4145 | 4187 |
| 4188 virtual bool HasOneTimeSideEffects() const { | |
|
fschneider
2012/02/02 14:59:50
It may be not worth making a predicate that applie
danno
2012/02/06 16:54:57
Done.
| |
| 4189 return true; | |
| 4190 } | |
| 4191 | |
| 4146 HValue* object() { return OperandAt(0); } | 4192 HValue* object() { return OperandAt(0); } |
| 4147 Handle<Map> original_map() { return original_map_; } | 4193 Handle<Map> original_map() { return original_map_; } |
| 4148 Handle<Map> transitioned_map() { return transitioned_map_; } | 4194 Handle<Map> transitioned_map() { return transitioned_map_; } |
| 4149 | 4195 |
| 4150 virtual void PrintDataTo(StringStream* stream); | 4196 virtual void PrintDataTo(StringStream* stream); |
| 4151 | 4197 |
| 4152 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) | 4198 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) |
| 4153 | 4199 |
| 4154 protected: | 4200 protected: |
| 4155 virtual bool DataEquals(HValue* other) { | 4201 virtual bool DataEquals(HValue* other) { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4559 | 4605 |
| 4560 DECLARE_CONCRETE_INSTRUCTION(In) | 4606 DECLARE_CONCRETE_INSTRUCTION(In) |
| 4561 }; | 4607 }; |
| 4562 | 4608 |
| 4563 #undef DECLARE_INSTRUCTION | 4609 #undef DECLARE_INSTRUCTION |
| 4564 #undef DECLARE_CONCRETE_INSTRUCTION | 4610 #undef DECLARE_CONCRETE_INSTRUCTION |
| 4565 | 4611 |
| 4566 } } // namespace v8::internal | 4612 } } // namespace v8::internal |
| 4567 | 4613 |
| 4568 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4614 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |