| 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()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 ASSERT(block_ != NULL); | 728 ASSERT(block_ != NULL); |
| 716 block_ = NULL; | 729 block_ = NULL; |
| 717 } | 730 } |
| 718 | 731 |
| 719 void set_representation(Representation r) { | 732 void set_representation(Representation r) { |
| 720 // Representation is set-once. | 733 // Representation is set-once. |
| 721 ASSERT(representation_.IsNone() && !r.IsNone()); | 734 ASSERT(representation_.IsNone() && !r.IsNone()); |
| 722 representation_ = r; | 735 representation_ = r; |
| 723 } | 736 } |
| 724 | 737 |
| 738 static GVNFlagSet AllDependsOnFlagSet() { |
| 739 GVNFlagSet result; |
| 740 // Create changes mask. |
| 741 #define ADD_FLAG(type) result.Add(kDependsOn##type); |
| 742 GVN_FLAG_LIST(ADD_FLAG) |
| 743 #undef ADD_FLAG |
| 744 return result; |
| 745 } |
| 746 |
| 725 static GVNFlagSet AllChangesFlagSet() { | 747 static GVNFlagSet AllChangesFlagSet() { |
| 726 GVNFlagSet result; | 748 GVNFlagSet result; |
| 727 // Create changes mask. | 749 // Create changes mask. |
| 728 #define ADD_FLAG(type) result.Add(kChanges##type); | 750 #define ADD_FLAG(type) result.Add(kChanges##type); |
| 729 GVN_FLAG_LIST(ADD_FLAG) | 751 GVN_FLAG_LIST(ADD_FLAG) |
| 730 #undef ADD_FLAG | 752 #undef ADD_FLAG |
| 731 return result; | 753 return result; |
| 732 } | 754 } |
| 733 | 755 |
| 734 // A flag mask to mark an instruction as having arbitrary side effects. | 756 // A flag mask to mark an instruction as having arbitrary side effects. |
| 735 static GVNFlagSet AllSideEffectsFlagSet() { | 757 static GVNFlagSet AllSideEffectsFlagSet() { |
| 736 GVNFlagSet result = AllChangesFlagSet(); | 758 GVNFlagSet result = AllChangesFlagSet(); |
| 737 result.Remove(kChangesOsrEntries); | 759 result.Remove(kChangesOsrEntries); |
| 738 return result; | 760 return result; |
| 739 } | 761 } |
| 740 | 762 |
| 741 // A flag mask of all side effects that can make observable changes in | 763 // 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); | 764 // an executing program (i.e. are not safe to repeat, move or remove); |
| 743 static GVNFlagSet AllObservableSideEffectsFlagSet() { | 765 static GVNFlagSet AllObservableSideEffectsFlagSet() { |
| 744 GVNFlagSet result = AllChangesFlagSet(); | 766 GVNFlagSet result = AllChangesFlagSet(); |
| 745 result.Remove(kChangesElementsKind); | 767 result.Remove(kChangesElementsKind); |
| 768 result.Remove(kChangesElementsPointer); |
| 769 result.Remove(kChangesMaps); |
| 746 return result; | 770 return result; |
| 747 } | 771 } |
| 748 | 772 |
| 749 // Remove the matching use from the use list if present. Returns the | 773 // Remove the matching use from the use list if present. Returns the |
| 750 // removed list node or NULL. | 774 // removed list node or NULL. |
| 751 HUseListNode* RemoveUse(HValue* value, int index); | 775 HUseListNode* RemoveUse(HValue* value, int index); |
| 752 | 776 |
| 753 void RegisterUse(int index, HValue* new_value); | 777 void RegisterUse(int index, HValue* new_value); |
| 754 | 778 |
| 755 HBasicBlock* block_; | 779 HBasicBlock* block_; |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 private: | 1937 private: |
| 1914 BuiltinFunctionId op_; | 1938 BuiltinFunctionId op_; |
| 1915 }; | 1939 }; |
| 1916 | 1940 |
| 1917 | 1941 |
| 1918 class HLoadElements: public HUnaryOperation { | 1942 class HLoadElements: public HUnaryOperation { |
| 1919 public: | 1943 public: |
| 1920 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { | 1944 explicit HLoadElements(HValue* value) : HUnaryOperation(value) { |
| 1921 set_representation(Representation::Tagged()); | 1945 set_representation(Representation::Tagged()); |
| 1922 SetFlag(kUseGVN); | 1946 SetFlag(kUseGVN); |
| 1923 SetGVNFlag(kDependsOnMaps); | 1947 SetGVNFlag(kDependsOnElementsPointer); |
| 1924 SetGVNFlag(kDependsOnElementsKind); | |
| 1925 } | 1948 } |
| 1926 | 1949 |
| 1927 virtual Representation RequiredInputRepresentation(int index) { | 1950 virtual Representation RequiredInputRepresentation(int index) { |
| 1928 return Representation::Tagged(); | 1951 return Representation::Tagged(); |
| 1929 } | 1952 } |
| 1930 | 1953 |
| 1931 DECLARE_CONCRETE_INSTRUCTION(LoadElements) | 1954 DECLARE_CONCRETE_INSTRUCTION(LoadElements) |
| 1932 | 1955 |
| 1933 protected: | 1956 protected: |
| 1934 virtual bool DataEquals(HValue* other) { return true; } | 1957 virtual bool DataEquals(HValue* other) { return true; } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1965 CompareMapMode mode = REQUIRE_EXACT_MAP) | 1988 CompareMapMode mode = REQUIRE_EXACT_MAP) |
| 1966 : map_(map), | 1989 : map_(map), |
| 1967 mode_(mode) { | 1990 mode_(mode) { |
| 1968 SetOperandAt(0, value); | 1991 SetOperandAt(0, value); |
| 1969 // If callers don't depend on a typecheck, they can pass in NULL. In that | 1992 // 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. | 1993 // case we use a copy of the |value| argument as a dummy value. |
| 1971 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 1994 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
| 1972 set_representation(Representation::Tagged()); | 1995 set_representation(Representation::Tagged()); |
| 1973 SetFlag(kUseGVN); | 1996 SetFlag(kUseGVN); |
| 1974 SetGVNFlag(kDependsOnMaps); | 1997 SetGVNFlag(kDependsOnMaps); |
| 1998 // If the map to check doesn't have the untransitioned elements, it must not |
| 1999 // be hoisted above TransitionElements instructions. |
| 2000 if (mode == REQUIRE_EXACT_MAP || !map->has_fast_smi_only_elements()) { |
| 2001 SetGVNFlag(kDependsOnElementsKind); |
| 2002 } |
| 1975 has_element_transitions_ = | 2003 has_element_transitions_ = |
| 1976 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL || | 2004 map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, NULL) != NULL || |
| 1977 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL; | 2005 map->LookupElementsTransitionMap(FAST_ELEMENTS, NULL) != NULL; |
| 1978 } | 2006 } |
| 1979 | 2007 |
| 1980 virtual Representation RequiredInputRepresentation(int index) { | 2008 virtual Representation RequiredInputRepresentation(int index) { |
| 1981 return Representation::Tagged(); | 2009 return Representation::Tagged(); |
| 1982 } | 2010 } |
| 1983 virtual void PrintDataTo(StringStream* stream); | 2011 virtual void PrintDataTo(StringStream* stream); |
| 1984 virtual HType CalculateInferredType(); | 2012 virtual HType CalculateInferredType(); |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4128 | 4156 |
| 4129 class HTransitionElementsKind: public HTemplateInstruction<1> { | 4157 class HTransitionElementsKind: public HTemplateInstruction<1> { |
| 4130 public: | 4158 public: |
| 4131 HTransitionElementsKind(HValue* object, | 4159 HTransitionElementsKind(HValue* object, |
| 4132 Handle<Map> original_map, | 4160 Handle<Map> original_map, |
| 4133 Handle<Map> transitioned_map) | 4161 Handle<Map> transitioned_map) |
| 4134 : original_map_(original_map), | 4162 : original_map_(original_map), |
| 4135 transitioned_map_(transitioned_map) { | 4163 transitioned_map_(transitioned_map) { |
| 4136 SetOperandAt(0, object); | 4164 SetOperandAt(0, object); |
| 4137 SetFlag(kUseGVN); | 4165 SetFlag(kUseGVN); |
| 4166 SetGVNFlag(kDependsOnMaps); |
| 4138 SetGVNFlag(kChangesElementsKind); | 4167 SetGVNFlag(kChangesElementsKind); |
| 4168 if (original_map->has_fast_double_elements()) { |
| 4169 SetGVNFlag(kChangesElementsPointer); |
| 4170 SetGVNFlag(kDependsOnElementsPointer); |
| 4171 SetGVNFlag(kDependsOnDoubleArrayElements); |
| 4172 } else if (transitioned_map->has_fast_double_elements()) { |
| 4173 SetGVNFlag(kChangesElementsPointer); |
| 4174 SetGVNFlag(kDependsOnElementsPointer); |
| 4175 SetGVNFlag(kDependsOnArrayElements); |
| 4176 } |
| 4139 set_representation(Representation::Tagged()); | 4177 set_representation(Representation::Tagged()); |
| 4140 } | 4178 } |
| 4141 | 4179 |
| 4142 virtual Representation RequiredInputRepresentation(int index) { | 4180 virtual Representation RequiredInputRepresentation(int index) { |
| 4143 return Representation::Tagged(); | 4181 return Representation::Tagged(); |
| 4144 } | 4182 } |
| 4145 | 4183 |
| 4146 HValue* object() { return OperandAt(0); } | 4184 HValue* object() { return OperandAt(0); } |
| 4147 Handle<Map> original_map() { return original_map_; } | 4185 Handle<Map> original_map() { return original_map_; } |
| 4148 Handle<Map> transitioned_map() { return transitioned_map_; } | 4186 Handle<Map> transitioned_map() { return transitioned_map_; } |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4559 | 4597 |
| 4560 DECLARE_CONCRETE_INSTRUCTION(In) | 4598 DECLARE_CONCRETE_INSTRUCTION(In) |
| 4561 }; | 4599 }; |
| 4562 | 4600 |
| 4563 #undef DECLARE_INSTRUCTION | 4601 #undef DECLARE_INSTRUCTION |
| 4564 #undef DECLARE_CONCRETE_INSTRUCTION | 4602 #undef DECLARE_CONCRETE_INSTRUCTION |
| 4565 | 4603 |
| 4566 } } // namespace v8::internal | 4604 } } // namespace v8::internal |
| 4567 | 4605 |
| 4568 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4606 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |