Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "src/compiler/checkpoint-elimination.h" | |
| 6 | |
| 7 #include "src/compiler/node-properties.h" | |
| 8 | |
| 9 namespace v8 { | |
| 10 namespace internal { | |
| 11 namespace compiler { | |
| 12 | |
| 13 CheckpointElimination::CheckpointElimination(Editor* editor) | |
| 14 : AdvancedReducer(editor) {} | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 // The given checkpoint is redundant if it is effect-wise dominated by another | |
| 19 // checkpoint and there is no observable write in between. For now we consider | |
| 20 // a linear effect chain only instead of true effect-wise dominance. | |
| 21 bool IsRedundantCheckPoint(Node* node) { | |
| 22 Node* effect = NodeProperties::GetEffectInput(node); | |
| 23 while (effect->op()->HasProperty(Operator::kNoWrite) && | |
| 24 effect->op()->EffectInputCount() == 1) { | |
| 25 if (effect->opcode() == IrOpcode::kCheckPoint) return true; | |
| 26 effect = NodeProperties::GetEffectInput(effect); | |
| 27 } | |
| 28 return false; | |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 33 Reduction CheckpointElimination::Reduce(Node* node) { | |
| 34 if (node->opcode() != IrOpcode::kCheckPoint) return NoChange(); | |
| 35 DCHECK_EQ(IrOpcode::kCheckPoint, node->opcode()); | |
|
Benedikt Meurer
2016/06/01 04:05:22
The DCHECK_EQ is exactly the same as the check in
Michael Starzinger
2016/06/01 08:11:10
Done.
| |
| 36 if (IsRedundantCheckPoint(node)) { | |
| 37 return Replace(NodeProperties::GetEffectInput(node)); | |
| 38 } | |
| 39 return NoChange(); | |
| 40 } | |
| 41 | |
| 42 } // namespace compiler | |
| 43 } // namespace internal | |
| 44 } // namespace v8 | |
| OLD | NEW |