Commit 44d71893 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[Turbofan] Fix incorrect liveness in VisitThrow

While investigating loop peeling, I found that relatively simple code
like "if (x) { throw new Error('oh hai'); }" in a loop would fail to
peel. The reason is that the call (new Error(...)) was recorded by
loop analysis as being inside the loop but the only usage was in the throw,
which we currently model as being outside of the loop.

We have a regime that inserts LoopExit nodes to mark control exits from
the loops, and LoopExitValues that are meant to mark exiting values.
This wasn't done because of a bug in the bytecode graph builder
VisitThrow() method -- it used the *out* liveness to construct the
appropriate loop exit nodes, and it's more appropriate to use the *in*
liveness.

This addressed the concern. It doesn't fix bug 7099, but is a step on the
way.

Bug: v8:7099
Change-Id: Iaeea794843166063a55c6917e7b0ad4341581261
Reviewed-on: https://chromium-review.googlesource.com/793834Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49690}
parent d4c8393c
...@@ -1935,7 +1935,7 @@ void BytecodeGraphBuilder::VisitInvokeIntrinsic() { ...@@ -1935,7 +1935,7 @@ void BytecodeGraphBuilder::VisitInvokeIntrinsic() {
} }
void BytecodeGraphBuilder::VisitThrow() { void BytecodeGraphBuilder::VisitThrow() {
BuildLoopExitsForFunctionExit(bytecode_analysis()->GetOutLivenessFor( BuildLoopExitsForFunctionExit(bytecode_analysis()->GetInLivenessFor(
bytecode_iterator().current_offset())); bytecode_iterator().current_offset()));
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value);
...@@ -1945,7 +1945,7 @@ void BytecodeGraphBuilder::VisitThrow() { ...@@ -1945,7 +1945,7 @@ void BytecodeGraphBuilder::VisitThrow() {
} }
void BytecodeGraphBuilder::VisitAbort() { void BytecodeGraphBuilder::VisitAbort() {
BuildLoopExitsForFunctionExit(bytecode_analysis()->GetOutLivenessFor( BuildLoopExitsForFunctionExit(bytecode_analysis()->GetInLivenessFor(
bytecode_iterator().current_offset())); bytecode_iterator().current_offset()));
BailoutReason reason = BailoutReason reason =
static_cast<BailoutReason>(bytecode_iterator().GetIndexOperand(0)); static_cast<BailoutReason>(bytecode_iterator().GetIndexOperand(0));
...@@ -1955,7 +1955,7 @@ void BytecodeGraphBuilder::VisitAbort() { ...@@ -1955,7 +1955,7 @@ void BytecodeGraphBuilder::VisitAbort() {
} }
void BytecodeGraphBuilder::VisitReThrow() { void BytecodeGraphBuilder::VisitReThrow() {
BuildLoopExitsForFunctionExit(bytecode_analysis()->GetOutLivenessFor( BuildLoopExitsForFunctionExit(bytecode_analysis()->GetInLivenessFor(
bytecode_iterator().current_offset())); bytecode_iterator().current_offset()));
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
NewNode(javascript()->CallRuntime(Runtime::kReThrow), value); NewNode(javascript()->CallRuntime(Runtime::kReThrow), value);
......
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