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/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 10 matching lines...) Expand all Loading... |
21 default: | 21 default: |
22 break; | 22 break; |
23 } | 23 } |
24 return NoChange(); | 24 return NoChange(); |
25 } | 25 } |
26 | 26 |
27 | 27 |
28 Reduction LoadElimination::ReduceLoadField(Node* node) { | 28 Reduction LoadElimination::ReduceLoadField(Node* node) { |
29 DCHECK_EQ(IrOpcode::kLoadField, node->opcode()); | 29 DCHECK_EQ(IrOpcode::kLoadField, node->opcode()); |
30 FieldAccess const access = FieldAccessOf(node->op()); | 30 FieldAccess const access = FieldAccessOf(node->op()); |
31 Node* const object = NodeProperties::GetValueInput(node, 0); | 31 Node* object = NodeProperties::GetValueInput(node, 0); |
32 for (Node* effect = NodeProperties::GetEffectInput(node);; | 32 for (Node* effect = NodeProperties::GetEffectInput(node);; |
33 effect = NodeProperties::GetEffectInput(effect)) { | 33 effect = NodeProperties::GetEffectInput(effect)) { |
34 switch (effect->opcode()) { | 34 switch (effect->opcode()) { |
35 case IrOpcode::kLoadField: { | 35 case IrOpcode::kLoadField: { |
36 if (object == NodeProperties::GetValueInput(effect, 0) && | 36 if (object == NodeProperties::GetValueInput(effect, 0) && |
37 access == FieldAccessOf(effect->op())) { | 37 access == FieldAccessOf(effect->op())) { |
38 Node* const value = effect; | 38 Node* const value = effect; |
39 ReplaceWithValue(node, value); | 39 ReplaceWithValue(node, value); |
40 return Replace(value); | 40 return Replace(value); |
41 } | 41 } |
42 break; | 42 break; |
43 } | 43 } |
44 case IrOpcode::kStoreField: { | 44 case IrOpcode::kStoreField: { |
45 if (access == FieldAccessOf(effect->op())) { | 45 if (access == FieldAccessOf(effect->op())) { |
46 if (object == NodeProperties::GetValueInput(effect, 0)) { | 46 if (object == NodeProperties::GetValueInput(effect, 0)) { |
47 Node* const value = NodeProperties::GetValueInput(effect, 1); | 47 Node* const value = NodeProperties::GetValueInput(effect, 1); |
48 ReplaceWithValue(node, value); | 48 ReplaceWithValue(node, value); |
49 return Replace(value); | 49 return Replace(value); |
50 } | 50 } |
51 // TODO(turbofan): Alias analysis to the rescue? | 51 // TODO(turbofan): Alias analysis to the rescue? |
52 return NoChange(); | 52 return NoChange(); |
53 } | 53 } |
54 break; | 54 break; |
55 } | 55 } |
| 56 case IrOpcode::kBeginRegion: |
56 case IrOpcode::kStoreBuffer: | 57 case IrOpcode::kStoreBuffer: |
57 case IrOpcode::kStoreElement: { | 58 case IrOpcode::kStoreElement: { |
58 // These can never interfere with field loads. | 59 // These can never interfere with field loads. |
59 break; | 60 break; |
60 } | 61 } |
| 62 case IrOpcode::kFinishRegion: { |
| 63 // "Look through" FinishRegion nodes to make LoadElimination capable |
| 64 // of looking into atomic regions. |
| 65 if (object == effect) object = NodeProperties::GetValueInput(effect, 0); |
| 66 break; |
| 67 } |
| 68 case IrOpcode::kAllocate: { |
| 69 // Allocations don't interfere with field loads. In case we see the |
| 70 // actual allocation for the {object} we can abort. |
| 71 if (object == effect) return NoChange(); |
| 72 break; |
| 73 } |
61 default: { | 74 default: { |
62 if (!effect->op()->HasProperty(Operator::kNoWrite) || | 75 if (!effect->op()->HasProperty(Operator::kNoWrite) || |
63 effect->op()->EffectInputCount() != 1) { | 76 effect->op()->EffectInputCount() != 1) { |
64 return NoChange(); | 77 return NoChange(); |
65 } | 78 } |
66 break; | 79 break; |
67 } | 80 } |
68 } | 81 } |
69 } | 82 } |
70 UNREACHABLE(); | 83 UNREACHABLE(); |
71 return NoChange(); | 84 return NoChange(); |
72 } | 85 } |
73 | 86 |
74 } // namespace compiler | 87 } // namespace compiler |
75 } // namespace internal | 88 } // namespace internal |
76 } // namespace v8 | 89 } // namespace v8 |
OLD | NEW |