| 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/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
| 8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 FieldAccess const& access = FieldAccessOf(node->op()); | 305 FieldAccess const& access = FieldAccessOf(node->op()); |
| 306 Node* const object = NodeProperties::GetValueInput(node, 0); | 306 Node* const object = NodeProperties::GetValueInput(node, 0); |
| 307 Node* const effect = NodeProperties::GetEffectInput(node); | 307 Node* const effect = NodeProperties::GetEffectInput(node); |
| 308 AbstractState const* state = node_states_.Get(effect); | 308 AbstractState const* state = node_states_.Get(effect); |
| 309 if (state == nullptr) return NoChange(); | 309 if (state == nullptr) return NoChange(); |
| 310 int field_index = FieldIndexOf(access); | 310 int field_index = FieldIndexOf(access); |
| 311 if (field_index >= 0) { | 311 if (field_index >= 0) { |
| 312 if (Node* const replacement = state->LookupField(object, field_index)) { | 312 if (Node* const replacement = state->LookupField(object, field_index)) { |
| 313 // Make sure the {replacement} has at least as good type | 313 // Make sure the {replacement} has at least as good type |
| 314 // as the original {node}. | 314 // as the original {node}. |
| 315 if (NodeProperties::GetType(replacement) | 315 if (!replacement->IsDead() && |
| 316 NodeProperties::GetType(replacement) |
| 316 ->Is(NodeProperties::GetType(node))) { | 317 ->Is(NodeProperties::GetType(node))) { |
| 317 ReplaceWithValue(node, replacement, effect); | 318 ReplaceWithValue(node, replacement, effect); |
| 318 DCHECK(!replacement->IsDead()); | |
| 319 return Replace(replacement); | 319 return Replace(replacement); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 state = state->AddField(object, field_index, node, zone()); | 322 state = state->AddField(object, field_index, node, zone()); |
| 323 } | 323 } |
| 324 return UpdateState(node, state); | 324 return UpdateState(node, state); |
| 325 } | 325 } |
| 326 | 326 |
| 327 Reduction LoadElimination::ReduceStoreField(Node* node) { | 327 Reduction LoadElimination::ReduceStoreField(Node* node) { |
| 328 FieldAccess const& access = FieldAccessOf(node->op()); | 328 FieldAccess const& access = FieldAccessOf(node->op()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 350 | 350 |
| 351 Reduction LoadElimination::ReduceLoadElement(Node* node) { | 351 Reduction LoadElimination::ReduceLoadElement(Node* node) { |
| 352 Node* const object = NodeProperties::GetValueInput(node, 0); | 352 Node* const object = NodeProperties::GetValueInput(node, 0); |
| 353 Node* const index = NodeProperties::GetValueInput(node, 1); | 353 Node* const index = NodeProperties::GetValueInput(node, 1); |
| 354 Node* const effect = NodeProperties::GetEffectInput(node); | 354 Node* const effect = NodeProperties::GetEffectInput(node); |
| 355 AbstractState const* state = node_states_.Get(effect); | 355 AbstractState const* state = node_states_.Get(effect); |
| 356 if (state == nullptr) return NoChange(); | 356 if (state == nullptr) return NoChange(); |
| 357 if (Node* const replacement = state->LookupElement(object, index)) { | 357 if (Node* const replacement = state->LookupElement(object, index)) { |
| 358 // Make sure the {replacement} has at least as good type | 358 // Make sure the {replacement} has at least as good type |
| 359 // as the original {node}. | 359 // as the original {node}. |
| 360 if (NodeProperties::GetType(replacement) | 360 if (!replacement->IsDead() && |
| 361 NodeProperties::GetType(replacement) |
| 361 ->Is(NodeProperties::GetType(node))) { | 362 ->Is(NodeProperties::GetType(node))) { |
| 362 ReplaceWithValue(node, replacement, effect); | 363 ReplaceWithValue(node, replacement, effect); |
| 363 DCHECK(!replacement->IsDead()); | |
| 364 return Replace(replacement); | 364 return Replace(replacement); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 state = state->AddElement(object, index, node, zone()); | 367 state = state->AddElement(object, index, node, zone()); |
| 368 return UpdateState(node, state); | 368 return UpdateState(node, state); |
| 369 } | 369 } |
| 370 | 370 |
| 371 Reduction LoadElimination::ReduceStoreElement(Node* node) { | 371 Reduction LoadElimination::ReduceStoreElement(Node* node) { |
| 372 ElementAccess const& access = ElementAccessOf(node->op()); | 372 ElementAccess const& access = ElementAccessOf(node->op()); |
| 373 Node* const object = NodeProperties::GetValueInput(node, 0); | 373 Node* const object = NodeProperties::GetValueInput(node, 0); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 DCHECK_EQ(kTaggedBase, access.base_is_tagged); | 542 DCHECK_EQ(kTaggedBase, access.base_is_tagged); |
| 543 DCHECK_EQ(0, access.offset % kPointerSize); | 543 DCHECK_EQ(0, access.offset % kPointerSize); |
| 544 int field_index = access.offset / kPointerSize; | 544 int field_index = access.offset / kPointerSize; |
| 545 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; | 545 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; |
| 546 return field_index; | 546 return field_index; |
| 547 } | 547 } |
| 548 | 548 |
| 549 } // namespace compiler | 549 } // namespace compiler |
| 550 } // namespace internal | 550 } // namespace internal |
| 551 } // namespace v8 | 551 } // namespace v8 |
| OLD | NEW |