| 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 "src/compiler/load-elimination.h" | 5 #include "src/compiler/load-elimination.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 enum Aliasing { kNoAlias, kMayAlias, kMustAlias }; | 17 enum Aliasing { kNoAlias, kMayAlias, kMustAlias }; |
| 18 | 18 |
| 19 Aliasing QueryAlias(Node* a, Node* b) { | 19 Aliasing QueryAlias(Node* a, Node* b) { |
| 20 if (a == b) return kMustAlias; | 20 if (a == b) return kMustAlias; |
| 21 if (!NodeProperties::GetType(a)->Maybe(NodeProperties::GetType(b))) { |
| 22 return kNoAlias; |
| 23 } |
| 21 if (b->opcode() == IrOpcode::kAllocate) { | 24 if (b->opcode() == IrOpcode::kAllocate) { |
| 22 switch (a->opcode()) { | 25 switch (a->opcode()) { |
| 23 case IrOpcode::kAllocate: | 26 case IrOpcode::kAllocate: |
| 24 case IrOpcode::kHeapConstant: | 27 case IrOpcode::kHeapConstant: |
| 25 case IrOpcode::kParameter: | 28 case IrOpcode::kParameter: |
| 26 return kNoAlias; | 29 return kNoAlias; |
| 27 case IrOpcode::kFinishRegion: | 30 case IrOpcode::kFinishRegion: |
| 28 return QueryAlias(a->InputAt(0), b); | 31 return QueryAlias(a->InputAt(0), b); |
| 29 default: | 32 default: |
| 30 break; | 33 break; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 AbstractElements* that = new (zone) AbstractElements(zone); | 107 AbstractElements* that = new (zone) AbstractElements(zone); |
| 105 for (Element const element : this->elements_) { | 108 for (Element const element : this->elements_) { |
| 106 if (element.object == nullptr) continue; | 109 if (element.object == nullptr) continue; |
| 107 DCHECK_NOT_NULL(element.index); | 110 DCHECK_NOT_NULL(element.index); |
| 108 DCHECK_NOT_NULL(element.value); | 111 DCHECK_NOT_NULL(element.value); |
| 109 if (!MayAlias(object, element.object) || | 112 if (!MayAlias(object, element.object) || |
| 110 !MayAlias(index, element.index)) { | 113 !MayAlias(index, element.index)) { |
| 111 that->elements_[that->next_index_++] = element; | 114 that->elements_[that->next_index_++] = element; |
| 112 } | 115 } |
| 113 } | 116 } |
| 117 that->next_index_ %= arraysize(elements_); |
| 114 return that; | 118 return that; |
| 115 } | 119 } |
| 116 } | 120 } |
| 117 return this; | 121 return this; |
| 118 } | 122 } |
| 119 | 123 |
| 120 bool LoadElimination::AbstractElements::Equals( | 124 bool LoadElimination::AbstractElements::Equals( |
| 121 AbstractElements const* that) const { | 125 AbstractElements const* that) const { |
| 122 if (this == that) return true; | 126 if (this == that) return true; |
| 123 for (size_t i = 0; i < arraysize(elements_); ++i) { | 127 for (size_t i = 0; i < arraysize(elements_); ++i) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 for (Element const this_element : this->elements_) { | 161 for (Element const this_element : this->elements_) { |
| 158 if (this_element.object == nullptr) continue; | 162 if (this_element.object == nullptr) continue; |
| 159 for (Element const that_element : that->elements_) { | 163 for (Element const that_element : that->elements_) { |
| 160 if (this_element.object == that_element.object && | 164 if (this_element.object == that_element.object && |
| 161 this_element.index == that_element.index && | 165 this_element.index == that_element.index && |
| 162 this_element.value == that_element.value) { | 166 this_element.value == that_element.value) { |
| 163 copy->elements_[copy->next_index_++] = this_element; | 167 copy->elements_[copy->next_index_++] = this_element; |
| 164 } | 168 } |
| 165 } | 169 } |
| 166 } | 170 } |
| 171 copy->next_index_ %= arraysize(elements_); |
| 167 return copy; | 172 return copy; |
| 168 } | 173 } |
| 169 | 174 |
| 170 Node* LoadElimination::AbstractField::Lookup(Node* object) const { | 175 Node* LoadElimination::AbstractField::Lookup(Node* object) const { |
| 171 for (auto pair : info_for_node_) { | 176 for (auto pair : info_for_node_) { |
| 172 if (MustAlias(object, pair.first)) return pair.second; | 177 if (MustAlias(object, pair.first)) return pair.second; |
| 173 } | 178 } |
| 174 return nullptr; | 179 return nullptr; |
| 175 } | 180 } |
| 176 | 181 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 DCHECK_EQ(kTaggedBase, access.base_is_tagged); | 691 DCHECK_EQ(kTaggedBase, access.base_is_tagged); |
| 687 DCHECK_EQ(0, access.offset % kPointerSize); | 692 DCHECK_EQ(0, access.offset % kPointerSize); |
| 688 int field_index = access.offset / kPointerSize; | 693 int field_index = access.offset / kPointerSize; |
| 689 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; | 694 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; |
| 690 return field_index; | 695 return field_index; |
| 691 } | 696 } |
| 692 | 697 |
| 693 } // namespace compiler | 698 } // namespace compiler |
| 694 } // namespace internal | 699 } // namespace internal |
| 695 } // namespace v8 | 700 } // namespace v8 |
| OLD | NEW |