| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_LOAD_ELIMINATION_H_ | 5 #ifndef V8_COMPILER_LOAD_ELIMINATION_H_ |
| 6 #define V8_COMPILER_LOAD_ELIMINATION_H_ | 6 #define V8_COMPILER_LOAD_ELIMINATION_H_ |
| 7 | 7 |
| 8 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
| 9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| 11 #include "src/machine-type.h" |
| 11 #include "src/zone/zone-handle-set.h" | 12 #include "src/zone/zone-handle-set.h" |
| 12 | 13 |
| 13 namespace v8 { | 14 namespace v8 { |
| 14 namespace internal { | 15 namespace internal { |
| 15 | 16 |
| 16 // Forward declarations. | 17 // Forward declarations. |
| 17 class Factory; | 18 class Factory; |
| 18 | 19 |
| 19 namespace compiler { | 20 namespace compiler { |
| 20 | 21 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 72 |
| 72 // Abstract state to approximate the current state of an element along the | 73 // Abstract state to approximate the current state of an element along the |
| 73 // effect paths through the graph. | 74 // effect paths through the graph. |
| 74 class AbstractElements final : public ZoneObject { | 75 class AbstractElements final : public ZoneObject { |
| 75 public: | 76 public: |
| 76 explicit AbstractElements(Zone* zone) { | 77 explicit AbstractElements(Zone* zone) { |
| 77 for (size_t i = 0; i < arraysize(elements_); ++i) { | 78 for (size_t i = 0; i < arraysize(elements_); ++i) { |
| 78 elements_[i] = Element(); | 79 elements_[i] = Element(); |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 AbstractElements(Node* object, Node* index, Node* value, Zone* zone) | 82 AbstractElements(Node* object, Node* index, Node* value, |
| 83 MachineRepresentation representation, Zone* zone) |
| 82 : AbstractElements(zone) { | 84 : AbstractElements(zone) { |
| 83 elements_[next_index_++] = Element(object, index, value); | 85 elements_[next_index_++] = Element(object, index, value, representation); |
| 84 } | 86 } |
| 85 | 87 |
| 86 AbstractElements const* Extend(Node* object, Node* index, Node* value, | 88 AbstractElements const* Extend(Node* object, Node* index, Node* value, |
| 89 MachineRepresentation representation, |
| 87 Zone* zone) const { | 90 Zone* zone) const { |
| 88 AbstractElements* that = new (zone) AbstractElements(*this); | 91 AbstractElements* that = new (zone) AbstractElements(*this); |
| 89 that->elements_[that->next_index_] = Element(object, index, value); | 92 that->elements_[that->next_index_] = |
| 93 Element(object, index, value, representation); |
| 90 that->next_index_ = (that->next_index_ + 1) % arraysize(elements_); | 94 that->next_index_ = (that->next_index_ + 1) % arraysize(elements_); |
| 91 return that; | 95 return that; |
| 92 } | 96 } |
| 93 Node* Lookup(Node* object, Node* index) const; | 97 Node* Lookup(Node* object, Node* index, |
| 98 MachineRepresentation representation) const; |
| 94 AbstractElements const* Kill(Node* object, Node* index, Zone* zone) const; | 99 AbstractElements const* Kill(Node* object, Node* index, Zone* zone) const; |
| 95 bool Equals(AbstractElements const* that) const; | 100 bool Equals(AbstractElements const* that) const; |
| 96 AbstractElements const* Merge(AbstractElements const* that, | 101 AbstractElements const* Merge(AbstractElements const* that, |
| 97 Zone* zone) const; | 102 Zone* zone) const; |
| 98 | 103 |
| 99 void Print() const; | 104 void Print() const; |
| 100 | 105 |
| 101 private: | 106 private: |
| 102 struct Element { | 107 struct Element { |
| 103 Element() {} | 108 Element() {} |
| 104 Element(Node* object, Node* index, Node* value) | 109 Element(Node* object, Node* index, Node* value, |
| 105 : object(object), index(index), value(value) {} | 110 MachineRepresentation representation) |
| 111 : object(object), |
| 112 index(index), |
| 113 value(value), |
| 114 representation(representation) {} |
| 106 | 115 |
| 107 Node* object = nullptr; | 116 Node* object = nullptr; |
| 108 Node* index = nullptr; | 117 Node* index = nullptr; |
| 109 Node* value = nullptr; | 118 Node* value = nullptr; |
| 119 MachineRepresentation representation = MachineRepresentation::kNone; |
| 110 }; | 120 }; |
| 111 | 121 |
| 112 Element elements_[kMaxTrackedElements]; | 122 Element elements_[kMaxTrackedElements]; |
| 113 size_t next_index_ = 0; | 123 size_t next_index_ = 0; |
| 114 }; | 124 }; |
| 115 | 125 |
| 116 // Abstract state to approximate the current state of a certain field along | 126 // Abstract state to approximate the current state of a certain field along |
| 117 // the effect paths through the graph. | 127 // the effect paths through the graph. |
| 118 class AbstractField final : public ZoneObject { | 128 class AbstractField final : public ZoneObject { |
| 119 public: | 129 public: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 bool LookupMaps(Node* object, ZoneHandleSet<Map>* object_maps) const; | 227 bool LookupMaps(Node* object, ZoneHandleSet<Map>* object_maps) const; |
| 218 | 228 |
| 219 AbstractState const* AddField(Node* object, size_t index, Node* value, | 229 AbstractState const* AddField(Node* object, size_t index, Node* value, |
| 220 Zone* zone) const; | 230 Zone* zone) const; |
| 221 AbstractState const* KillField(Node* object, size_t index, | 231 AbstractState const* KillField(Node* object, size_t index, |
| 222 Zone* zone) const; | 232 Zone* zone) const; |
| 223 AbstractState const* KillFields(Node* object, Zone* zone) const; | 233 AbstractState const* KillFields(Node* object, Zone* zone) const; |
| 224 Node* LookupField(Node* object, size_t index) const; | 234 Node* LookupField(Node* object, size_t index) const; |
| 225 | 235 |
| 226 AbstractState const* AddElement(Node* object, Node* index, Node* value, | 236 AbstractState const* AddElement(Node* object, Node* index, Node* value, |
| 237 MachineRepresentation representation, |
| 227 Zone* zone) const; | 238 Zone* zone) const; |
| 228 AbstractState const* KillElement(Node* object, Node* index, | 239 AbstractState const* KillElement(Node* object, Node* index, |
| 229 Zone* zone) const; | 240 Zone* zone) const; |
| 230 Node* LookupElement(Node* object, Node* index) const; | 241 Node* LookupElement(Node* object, Node* index, |
| 242 MachineRepresentation representation) const; |
| 231 | 243 |
| 232 AbstractState const* AddCheck(Node* node, Zone* zone) const; | 244 AbstractState const* AddCheck(Node* node, Zone* zone) const; |
| 233 Node* LookupCheck(Node* node) const; | 245 Node* LookupCheck(Node* node) const; |
| 234 | 246 |
| 235 void Print() const; | 247 void Print() const; |
| 236 | 248 |
| 237 private: | 249 private: |
| 238 AbstractChecks const* checks_ = nullptr; | 250 AbstractChecks const* checks_ = nullptr; |
| 239 AbstractElements const* elements_ = nullptr; | 251 AbstractElements const* elements_ = nullptr; |
| 240 AbstractField const* fields_[kMaxTrackedFields]; | 252 AbstractField const* fields_[kMaxTrackedFields]; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 JSGraph* const jsgraph_; | 299 JSGraph* const jsgraph_; |
| 288 | 300 |
| 289 DISALLOW_COPY_AND_ASSIGN(LoadElimination); | 301 DISALLOW_COPY_AND_ASSIGN(LoadElimination); |
| 290 }; | 302 }; |
| 291 | 303 |
| 292 } // namespace compiler | 304 } // namespace compiler |
| 293 } // namespace internal | 305 } // namespace internal |
| 294 } // namespace v8 | 306 } // namespace v8 |
| 295 | 307 |
| 296 #endif // V8_COMPILER_LOAD_ELIMINATION_H_ | 308 #endif // V8_COMPILER_LOAD_ELIMINATION_H_ |
| OLD | NEW |