Commit 4a80642e authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[turbofan] Simplify {IfException} discovery during inlining.

This unifies the search for a potential {IfException} projection with
the existing predicate on {NodeProperties} used by the rest of the
system. Also contains a related drive-by change to graph builders. This
is in preparation of eliding {IfSuccess} projections when possible.

R=jarin@chromium.org

Change-Id: I8ba0ae9e9fdb69a77bce01578200ceea434535f7
Reviewed-on: https://chromium-review.googlesource.com/448039Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43540}
parent f93b27e6
......@@ -2931,7 +2931,7 @@ Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count,
result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete);
if (!environment()->IsMarkedAsUnreachable()) {
// Update the current control dependency for control-producing nodes.
if (NodeProperties::IsControl(result)) {
if (result->op()->ControlOutputCount() > 0) {
environment_->UpdateControlDependency(result);
}
// Update the current effect dependency for effect-producing nodes.
......
......@@ -2310,7 +2310,7 @@ Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count,
}
result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete);
// Update the current control dependency for control-producing nodes.
if (NodeProperties::IsControl(result)) {
if (result->op()->ControlOutputCount() > 0) {
environment()->UpdateControlDependency(result);
}
// Update the current effect dependency for effect-producing nodes.
......
......@@ -513,20 +513,11 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
}
}
// Find the IfException node, if any.
// Calls surrounded by a local try-block are only inlined if the appropriate
// flag is active. We also discover the {IfException} projection this way.
Node* exception_target = nullptr;
for (Edge edge : node->use_edges()) {
if (NodeProperties::IsControlEdge(edge) &&
edge.from()->opcode() == IrOpcode::kIfException) {
DCHECK_NULL(exception_target);
exception_target = edge.from();
}
}
NodeVector uncaught_subcalls(local_zone_);
if (exception_target != nullptr) {
if (!FLAG_inline_into_try) {
if (NodeProperties::IsExceptionalCall(node, &exception_target) &&
!FLAG_inline_into_try) {
TRACE(
"Try block surrounds #%d:%s and --no-inline-into-try active, so not "
"inlining %s into %s.\n",
......@@ -534,14 +525,6 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get());
return NoChange();
} else {
TRACE(
"Inlining %s into %s regardless of surrounding try-block to catcher "
"#%d:%s\n",
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get(),
exception_target->id(), exception_target->op()->mnemonic());
}
}
ParseInfo parse_info(shared_info);
......@@ -570,9 +553,9 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
// After this point, we've made a decision to inline this function.
// We shall not bailout from inlining if we got here.
TRACE("Inlining %s into %s\n",
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get());
TRACE("Inlining %s into %s%s\n", shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get(),
(exception_target != nullptr) ? " (inside try-block)" : "");
// Determine the targets feedback vector and its context.
Node* context;
......@@ -595,6 +578,7 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
end = graph()->end();
}
NodeVector uncaught_subcalls(local_zone_);
if (exception_target != nullptr) {
// Find all uncaught 'calls' in the inlinee.
AllNodes inlined_nodes(local_zone_, end, graph());
......
......@@ -126,11 +126,14 @@ bool NodeProperties::IsControlEdge(Edge edge) {
// static
bool NodeProperties::IsExceptionalCall(Node* node) {
bool NodeProperties::IsExceptionalCall(Node* node, Node** out_exception) {
if (node->op()->HasProperty(Operator::kNoThrow)) return false;
for (Edge const edge : node->use_edges()) {
if (!NodeProperties::IsControlEdge(edge)) continue;
if (edge.from()->opcode() == IrOpcode::kIfException) return true;
if (edge.from()->opcode() == IrOpcode::kIfException) {
if (out_exception != nullptr) *out_exception = edge.from();
return true;
}
}
return false;
}
......
......@@ -75,8 +75,9 @@ class V8_EXPORT_PRIVATE NodeProperties final {
}
// Determines whether exceptions thrown by the given node are handled locally
// within the graph (i.e. an IfException projection is present).
static bool IsExceptionalCall(Node* node);
// within the graph (i.e. an IfException projection is present). Optionally
// the present IfException projection is returned via {out_exception}.
static bool IsExceptionalCall(Node* node, Node** out_exception = nullptr);
// ---------------------------------------------------------------------------
// Miscellaneous mutators.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment