| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 } | 27 } |
| 28 | 28 |
| 29 Reduction LoadElimination::ReduceLoadField(Node* node) { | 29 Reduction LoadElimination::ReduceLoadField(Node* node) { |
| 30 DCHECK_EQ(IrOpcode::kLoadField, node->opcode()); | 30 DCHECK_EQ(IrOpcode::kLoadField, node->opcode()); |
| 31 FieldAccess const access = FieldAccessOf(node->op()); | 31 FieldAccess const access = FieldAccessOf(node->op()); |
| 32 Node* object = NodeProperties::GetValueInput(node, 0); | 32 Node* object = NodeProperties::GetValueInput(node, 0); |
| 33 for (Node* effect = NodeProperties::GetEffectInput(node);; | 33 for (Node* effect = NodeProperties::GetEffectInput(node);; |
| 34 effect = NodeProperties::GetEffectInput(effect)) { | 34 effect = NodeProperties::GetEffectInput(effect)) { |
| 35 switch (effect->opcode()) { | 35 switch (effect->opcode()) { |
| 36 case IrOpcode::kLoadField: { | 36 case IrOpcode::kLoadField: { |
| 37 FieldAccess const effect_access = FieldAccessOf(effect->op()); |
| 37 if (object == NodeProperties::GetValueInput(effect, 0) && | 38 if (object == NodeProperties::GetValueInput(effect, 0) && |
| 38 access == FieldAccessOf(effect->op())) { | 39 access == effect_access && effect_access.type->Is(access.type)) { |
| 39 Node* const value = effect; | 40 Node* const value = effect; |
| 40 ReplaceWithValue(node, value); | 41 ReplaceWithValue(node, value); |
| 41 return Replace(value); | 42 return Replace(value); |
| 42 } | 43 } |
| 43 break; | 44 break; |
| 44 } | 45 } |
| 45 case IrOpcode::kStoreField: { | 46 case IrOpcode::kStoreField: { |
| 46 if (access == FieldAccessOf(effect->op())) { | 47 if (access == FieldAccessOf(effect->op())) { |
| 47 if (object == NodeProperties::GetValueInput(effect, 0)) { | 48 if (object == NodeProperties::GetValueInput(effect, 0)) { |
| 48 Node* const value = NodeProperties::GetValueInput(effect, 1); | 49 Node* const value = NodeProperties::GetValueInput(effect, 1); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 UNREACHABLE(); | 99 UNREACHABLE(); |
| 99 return NoChange(); | 100 return NoChange(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 } // namespace compiler | 103 } // namespace compiler |
| 103 } // namespace internal | 104 } // namespace internal |
| 104 } // namespace v8 | 105 } // namespace v8 |
| OLD | NEW |