Index: src/compiler/checkpoint-elimination.cc |
diff --git a/src/compiler/checkpoint-elimination.cc b/src/compiler/checkpoint-elimination.cc |
index d81e1096820fbfba966ba1b34f6ee12bd8cac358..ce1a86105671088a2e0e9ec82dcad6a3573ca2a5 100644 |
--- a/src/compiler/checkpoint-elimination.cc |
+++ b/src/compiler/checkpoint-elimination.cc |
@@ -30,14 +30,39 @@ bool IsRedundantCheckpoint(Node* node) { |
} // namespace |
-Reduction CheckpointElimination::Reduce(Node* node) { |
- if (node->opcode() != IrOpcode::kCheckpoint) return NoChange(); |
+Reduction CheckpointElimination::ReduceCheckpoint(Node* node) { |
+ DCHECK_EQ(IrOpcode::kCheckpoint, node->opcode()); |
if (IsRedundantCheckpoint(node)) { |
return Replace(NodeProperties::GetEffectInput(node)); |
} |
return NoChange(); |
} |
+Reduction CheckpointElimination::ReduceReturn(Node* node) { |
+ DCHECK_EQ(IrOpcode::kReturn, node->opcode()); |
+ Node* effect = NodeProperties::GetEffectInput(node); |
+ if (effect->opcode() == IrOpcode::kCheckpoint && effect->OwnedBy(node)) { |
+ // Any checkpoint that is wholly owned by a {Return} node can never be used |
+ // for an actual bailout and can hence be cut out of the effect chain. |
+ Node* replacement = NodeProperties::GetEffectInput(effect); |
+ NodeProperties::ReplaceEffectInput(node, replacement); |
+ return Changed(node); |
+ } |
+ return NoChange(); |
+} |
+ |
+Reduction CheckpointElimination::Reduce(Node* node) { |
+ switch (node->opcode()) { |
+ case IrOpcode::kCheckpoint: |
+ return ReduceCheckpoint(node); |
+ case IrOpcode::kReturn: |
+ return ReduceReturn(node); |
+ default: |
+ break; |
+ } |
+ return NoChange(); |
+} |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |