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/redundancy-elimination.h" | 5 #include "src/compiler/redundancy-elimination.h" |
6 | 6 |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 namespace compiler { | 11 namespace compiler { |
12 | 12 |
13 RedundancyElimination::RedundancyElimination(Editor* editor, Zone* zone) | 13 RedundancyElimination::RedundancyElimination(Editor* editor, Zone* zone) |
14 : AdvancedReducer(editor), node_checks_(zone), zone_(zone) {} | 14 : AdvancedReducer(editor), node_checks_(zone), zone_(zone) {} |
15 | 15 |
16 RedundancyElimination::~RedundancyElimination() {} | 16 RedundancyElimination::~RedundancyElimination() {} |
17 | 17 |
18 Reduction RedundancyElimination::Reduce(Node* node) { | 18 Reduction RedundancyElimination::Reduce(Node* node) { |
19 if (node_checks_.Get(node)) return NoChange(); | 19 if (node_checks_.Get(node)) return NoChange(); |
20 switch (node->opcode()) { | 20 switch (node->opcode()) { |
21 case IrOpcode::kCheckBounds: | 21 case IrOpcode::kCheckBounds: |
22 case IrOpcode::kCheckFloat64Hole: | 22 case IrOpcode::kCheckFloat64Hole: |
23 case IrOpcode::kCheckHeapObject: | 23 case IrOpcode::kCheckHeapObject: |
24 case IrOpcode::kCheckIf: | 24 case IrOpcode::kCheckIf: |
| 25 case IrOpcode::kCheckInternalizedString: |
25 case IrOpcode::kCheckNumber: | 26 case IrOpcode::kCheckNumber: |
26 case IrOpcode::kCheckSmi: | 27 case IrOpcode::kCheckSmi: |
27 case IrOpcode::kCheckString: | 28 case IrOpcode::kCheckString: |
28 case IrOpcode::kCheckTaggedHole: | 29 case IrOpcode::kCheckTaggedHole: |
29 case IrOpcode::kCheckedFloat64ToInt32: | 30 case IrOpcode::kCheckedFloat64ToInt32: |
30 case IrOpcode::kCheckedInt32Add: | 31 case IrOpcode::kCheckedInt32Add: |
31 case IrOpcode::kCheckedInt32Sub: | 32 case IrOpcode::kCheckedInt32Sub: |
32 case IrOpcode::kCheckedInt32Div: | 33 case IrOpcode::kCheckedInt32Div: |
33 case IrOpcode::kCheckedInt32Mod: | 34 case IrOpcode::kCheckedInt32Mod: |
34 case IrOpcode::kCheckedInt32Mul: | 35 case IrOpcode::kCheckedInt32Mul: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 RedundancyElimination::EffectPathChecks::AddCheck(Zone* zone, | 114 RedundancyElimination::EffectPathChecks::AddCheck(Zone* zone, |
114 Node* node) const { | 115 Node* node) const { |
115 Check* head = new (zone->New(sizeof(Check))) Check(node, head_); | 116 Check* head = new (zone->New(sizeof(Check))) Check(node, head_); |
116 return new (zone->New(sizeof(EffectPathChecks))) | 117 return new (zone->New(sizeof(EffectPathChecks))) |
117 EffectPathChecks(head, size_ + 1); | 118 EffectPathChecks(head, size_ + 1); |
118 } | 119 } |
119 | 120 |
120 namespace { | 121 namespace { |
121 | 122 |
122 bool IsCompatibleCheck(Node const* a, Node const* b) { | 123 bool IsCompatibleCheck(Node const* a, Node const* b) { |
123 if (a->op() != b->op()) return false; | 124 if (a->op() != b->op()) { |
| 125 if (a->opcode() == IrOpcode::kCheckInternalizedString && |
| 126 b->opcode() == IrOpcode::kCheckString) { |
| 127 // CheckInternalizedString(node) implies CheckString(node) |
| 128 } else { |
| 129 return false; |
| 130 } |
| 131 } |
124 for (int i = a->op()->ValueInputCount(); --i >= 0;) { | 132 for (int i = a->op()->ValueInputCount(); --i >= 0;) { |
125 if (a->InputAt(i) != b->InputAt(i)) return false; | 133 if (a->InputAt(i) != b->InputAt(i)) return false; |
126 } | 134 } |
127 return true; | 135 return true; |
128 } | 136 } |
129 | 137 |
130 } // namespace | 138 } // namespace |
131 | 139 |
132 Node* RedundancyElimination::EffectPathChecks::LookupCheck(Node* node) const { | 140 Node* RedundancyElimination::EffectPathChecks::LookupCheck(Node* node) const { |
133 for (Check const* check = head_; check != nullptr; check = check->next) { | 141 for (Check const* check = head_; check != nullptr; check = check->next) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 node_checks_.Set(node, checks); | 286 node_checks_.Set(node, checks); |
279 return Changed(node); | 287 return Changed(node); |
280 } | 288 } |
281 } | 289 } |
282 return NoChange(); | 290 return NoChange(); |
283 } | 291 } |
284 | 292 |
285 } // namespace compiler | 293 } // namespace compiler |
286 } // namespace internal | 294 } // namespace internal |
287 } // namespace v8 | 295 } // namespace v8 |
OLD | NEW |