OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 26 matching lines...) Expand all Loading... |
37 namespace internal { | 37 namespace internal { |
38 | 38 |
39 // This class extends GVNFlagSet with additional "special" dynamic side effects, | 39 // This class extends GVNFlagSet with additional "special" dynamic side effects, |
40 // which can be used to represent side effects that cannot be expressed using | 40 // which can be used to represent side effects that cannot be expressed using |
41 // the GVNFlags of an HInstruction. These special side effects are tracked by a | 41 // the GVNFlags of an HInstruction. These special side effects are tracked by a |
42 // SideEffectsTracker (see below). | 42 // SideEffectsTracker (see below). |
43 class SideEffects V8_FINAL { | 43 class SideEffects V8_FINAL { |
44 public: | 44 public: |
45 static const int kNumberOfSpecials = 64 - kNumberOfFlags; | 45 static const int kNumberOfSpecials = 64 - kNumberOfFlags; |
46 | 46 |
47 SideEffects() : bits_(0) {} | 47 SideEffects() : bits_(0) { |
| 48 ASSERT(kNumberOfFlags + kNumberOfSpecials == sizeof(bits_) * CHAR_BIT); |
| 49 } |
48 explicit SideEffects(GVNFlagSet flags) : bits_(flags.ToIntegral()) {} | 50 explicit SideEffects(GVNFlagSet flags) : bits_(flags.ToIntegral()) {} |
49 bool IsEmpty() const { return bits_ == 0; } | 51 bool IsEmpty() const { return bits_ == 0; } |
50 bool ContainsFlag(GVNFlag flag) const { | 52 bool ContainsFlag(GVNFlag flag) const { |
51 return (bits_ & MaskFlag(flag)) != 0; | 53 return (bits_ & MaskFlag(flag)) != 0; |
52 } | 54 } |
53 bool ContainsSpecial(int special) const { | 55 bool ContainsSpecial(int special) const { |
54 return (bits_ & MaskSpecial(special)) != 0; | 56 return (bits_ & MaskSpecial(special)) != 0; |
55 } | 57 } |
56 bool ContainsAnyOf(SideEffects set) const { return (bits_ & set.bits_) != 0; } | 58 bool ContainsAnyOf(SideEffects set) const { return (bits_ & set.bits_) != 0; } |
57 void Add(SideEffects set) { bits_ |= set.bits_; } | 59 void Add(SideEffects set) { bits_ |= set.bits_; } |
58 void AddSpecial(int special) { bits_ |= MaskSpecial(special); } | 60 void AddSpecial(int special) { bits_ |= MaskSpecial(special); } |
59 void AddAllSpecial() { bits_ |= ~static_cast<uint64_t>(0) << kNumberOfFlags; } | 61 void AddAllSpecial() { bits_ |= ~static_cast<uint64_t>(0) << kNumberOfFlags; } |
60 void RemoveFlag(GVNFlag flag) { bits_ &= ~MaskFlag(flag); } | 62 void RemoveFlag(GVNFlag flag) { bits_ &= ~MaskFlag(flag); } |
61 void RemoveAll() { bits_ = 0; } | 63 void RemoveAll() { bits_ = 0; } |
62 uint64_t ToIntegral() const { return bits_; } | 64 uint64_t ToIntegral() const { return bits_; } |
63 void PrintTo(StringStream* stream) const; | 65 void PrintTo(StringStream* stream) const; |
64 | 66 |
65 private: | 67 private: |
66 uint64_t MaskFlag(GVNFlag flag) const { | 68 uint64_t MaskFlag(GVNFlag flag) const { |
67 return static_cast<uint64_t>(1) << static_cast<unsigned>(flag); | 69 return static_cast<uint64_t>(1) << static_cast<unsigned>(flag); |
68 } | 70 } |
69 uint64_t MaskSpecial(int special) const { | 71 uint64_t MaskSpecial(int special) const { |
70 ASSERT(special >= 0); | 72 ASSERT(special >= 0); |
71 ASSERT(special < kNumberOfSpecials); | 73 ASSERT(special < kNumberOfSpecials); |
72 return static_cast<uint64_t>(1) << static_cast<unsigned>( | 74 return static_cast<uint64_t>(1) << static_cast<unsigned>( |
73 special + kNumberOfFlags); | 75 special + kNumberOfFlags); |
74 } | 76 } |
75 | 77 |
76 uint64_t bits_; | 78 uint64_t bits_; |
77 STATIC_ASSERT(kNumberOfFlags + kNumberOfSpecials == sizeof(bits_) * CHAR_BIT); | |
78 }; | 79 }; |
79 | 80 |
80 | 81 |
81 // Tracks inobject field loads/stores in a fine grained fashion, and represents | 82 // Tracks inobject field loads/stores in a fine grained fashion, and represents |
82 // them using the "special" dynamic side effects of the SideEffects class (see | 83 // them using the "special" dynamic side effects of the SideEffects class (see |
83 // above). This way unrelated inobject field stores don't prevent hoisting and | 84 // above). This way unrelated inobject field stores don't prevent hoisting and |
84 // merging of inobject field loads. | 85 // merging of inobject field loads. |
85 class SideEffectsTracker V8_FINAL BASE_EMBEDDED { | 86 class SideEffectsTracker V8_FINAL BASE_EMBEDDED { |
86 public: | 87 public: |
87 SideEffectsTracker() : num_inobject_fields_(0) {} | 88 SideEffectsTracker() : num_inobject_fields_(0) {} |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // Used when collecting side effects on paths from dominator to | 130 // Used when collecting side effects on paths from dominator to |
130 // dominated. | 131 // dominated. |
131 BitVector visited_on_paths_; | 132 BitVector visited_on_paths_; |
132 | 133 |
133 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase); | 134 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase); |
134 }; | 135 }; |
135 | 136 |
136 } } // namespace v8::internal | 137 } } // namespace v8::internal |
137 | 138 |
138 #endif // V8_HYDROGEN_GVN_H_ | 139 #endif // V8_HYDROGEN_GVN_H_ |
OLD | NEW |