| 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 #include <iterator> | 5 #include <iterator> |
| 6 | 6 |
| 7 #include "src/compiler/store-store-elimination.h" | 7 #include "src/compiler/store-store-elimination.h" |
| 8 | 8 |
| 9 #include "src/compiler/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Assumption: every byte of a JS object is only ever accessed through one | 65 // Assumption: every byte of a JS object is only ever accessed through one |
| 66 // offset. For instance, byte 15 of a given object may be accessed using a | 66 // offset. For instance, byte 15 of a given object may be accessed using a |
| 67 // two-byte read at offset 14, or a four-byte read at offset 12, but never | 67 // two-byte read at offset 14, or a four-byte read at offset 12, but never |
| 68 // both in the same program. | 68 // both in the same program. |
| 69 // | 69 // |
| 70 // This implementation needs all dead nodes removed from the graph, and the | 70 // This implementation needs all dead nodes removed from the graph, and the |
| 71 // graph should be trimmed. | 71 // graph should be trimmed. |
| 72 | 72 |
| 73 namespace { | 73 namespace { |
| 74 | 74 |
| 75 // 16 bits was chosen fairly arbitrarily; it seems enough now. 8 bits is too | 75 typedef uint32_t StoreOffset; |
| 76 // few. | |
| 77 typedef uint16_t StoreOffset; | |
| 78 | 76 |
| 79 struct UnobservableStore { | 77 struct UnobservableStore { |
| 80 NodeId id_; | 78 NodeId id_; |
| 81 StoreOffset offset_; | 79 StoreOffset offset_; |
| 82 | 80 |
| 83 bool operator==(const UnobservableStore) const; | 81 bool operator==(const UnobservableStore) const; |
| 84 bool operator!=(const UnobservableStore) const; | 82 bool operator!=(const UnobservableStore) const; |
| 85 bool operator<(const UnobservableStore) const; | 83 bool operator<(const UnobservableStore) const; |
| 86 }; | 84 }; |
| 87 | 85 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 Zone* const temp_zone_; | 162 Zone* const temp_zone_; |
| 165 | 163 |
| 166 ZoneStack<Node*> revisit_; | 164 ZoneStack<Node*> revisit_; |
| 167 ZoneVector<bool> in_revisit_; | 165 ZoneVector<bool> in_revisit_; |
| 168 // Maps node IDs to UnobservableNodeSets. | 166 // Maps node IDs to UnobservableNodeSets. |
| 169 ZoneVector<UnobservablesSet> unobservable_; | 167 ZoneVector<UnobservablesSet> unobservable_; |
| 170 ZoneSet<Node*> to_remove_; | 168 ZoneSet<Node*> to_remove_; |
| 171 const UnobservablesSet unobservables_visited_empty_; | 169 const UnobservablesSet unobservables_visited_empty_; |
| 172 }; | 170 }; |
| 173 | 171 |
| 174 // To safely cast an offset from a FieldAccess, which has a wider range | 172 // To safely cast an offset from a FieldAccess, which has a potentially wider |
| 175 // (namely int). | 173 // range (namely int). |
| 176 StoreOffset ToOffset(int offset) { | 174 StoreOffset ToOffset(int offset) { |
| 177 CHECK(0 <= offset && offset < (1 << 8 * sizeof(StoreOffset))); | 175 CHECK(0 <= offset); |
| 178 return (StoreOffset)offset; | 176 return static_cast<StoreOffset>(offset); |
| 179 } | 177 } |
| 180 | 178 |
| 181 StoreOffset ToOffset(const FieldAccess& access) { | 179 StoreOffset ToOffset(const FieldAccess& access) { |
| 182 return ToOffset(access.offset); | 180 return ToOffset(access.offset); |
| 183 } | 181 } |
| 184 | 182 |
| 185 unsigned int RepSizeOf(MachineRepresentation rep) { | 183 unsigned int RepSizeOf(MachineRepresentation rep) { |
| 186 return 1u << ElementSizeLog2Of(rep); | 184 return 1u << ElementSizeLog2Of(rep); |
| 187 } | 185 } |
| 188 unsigned int RepSizeOf(FieldAccess access) { | 186 unsigned int RepSizeOf(FieldAccess access) { |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 return !(*this == other); | 559 return !(*this == other); |
| 562 } | 560 } |
| 563 | 561 |
| 564 bool UnobservableStore::operator<(const UnobservableStore other) const { | 562 bool UnobservableStore::operator<(const UnobservableStore other) const { |
| 565 return (id_ < other.id_) || (id_ == other.id_ && offset_ < other.offset_); | 563 return (id_ < other.id_) || (id_ == other.id_ && offset_ < other.offset_); |
| 566 } | 564 } |
| 567 | 565 |
| 568 } // namespace compiler | 566 } // namespace compiler |
| 569 } // namespace internal | 567 } // namespace internal |
| 570 } // namespace v8 | 568 } // namespace v8 |
| OLD | NEW |