Index: src/compiler/js-inlining.cc |
diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc |
index 00a0eed26db580a889b1e85ec5d8a3cf9474a93e..4f1dc7c708fb0328bb39b12170a0c910353e1ea2 100644 |
--- a/src/compiler/js-inlining.cc |
+++ b/src/compiler/js-inlining.cc |
@@ -434,18 +434,21 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) { |
frame_state_before, effect); |
NodeProperties::ReplaceEffectInput(node, create); |
// Insert a check of the return value to determine whether the return |
- // value |
- // or the implicit receiver should be selected as a result of the call. |
+ // value or the implicit receiver should be selected as a result of the |
+ // call. The check is wired into the successful control completion. |
+ Node* success = graph()->NewNode(common()->IfSuccess(), node); |
Node* check = graph()->NewNode( |
javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), node, |
- context, node, start); |
+ context, node, success); |
Node* select = |
graph()->NewNode(common()->Select(MachineRepresentation::kTagged), |
check, node, create); |
- NodeProperties::ReplaceUses(node, select, check, node, node); |
- NodeProperties::ReplaceValueInput(select, node, 1); |
- NodeProperties::ReplaceValueInput(check, node, 0); |
- NodeProperties::ReplaceEffectInput(check, node); |
+ NodeProperties::ReplaceUses(node, select, check, check, node); |
+ // Fix-up inputs that have been mangled by the {ReplaceUses} call above. |
+ NodeProperties::ReplaceValueInput(select, node, 1); // Fix-up input. |
+ NodeProperties::ReplaceValueInput(check, node, 0); // Fix-up input. |
+ NodeProperties::ReplaceEffectInput(check, node); // Fix-up input. |
+ NodeProperties::ReplaceControlInput(success, node); // Fix-up input. |
receiver = create; // The implicit receiver. |
} |