Commit 087847d9 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Properly terminate throwing control edges.

This merges all control edges that are known to unconditionally throw
directly into the graph end node. This applies to the "Throw" as well as
the "Rethrow" operation, and reduces their code size.

R=clemensh@chromium.org
BUG=v8:8091

Change-Id: Idd4918ab084bcc697d5798d512ccc695ca943b00
Reviewed-on: https://chromium-review.googlesource.com/c/1305273Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57119}
parent 59c324a0
......@@ -176,13 +176,20 @@ Node* WasmGraphBuilder::Loop(Node* entry) {
return graph()->NewNode(mcgraph()->common()->Loop(1), entry);
}
Node* WasmGraphBuilder::Terminate(Node* effect, Node* control) {
Node* WasmGraphBuilder::TerminateLoop(Node* effect, Node* control) {
Node* terminate =
graph()->NewNode(mcgraph()->common()->Terminate(), effect, control);
MergeControlToEnd(mcgraph(), terminate);
return terminate;
}
Node* WasmGraphBuilder::TerminateThrow(Node* effect, Node* control) {
Node* terminate =
graph()->NewNode(mcgraph()->common()->Throw(), effect, control);
MergeControlToEnd(mcgraph(), terminate);
return terminate;
}
bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) {
return phi && IrOpcode::IsPhiOpcode(phi->opcode()) &&
NodeProperties::GetControlInput(phi) == merge;
......
......@@ -159,7 +159,8 @@ class WasmGraphBuilder {
Node* Start(unsigned params);
Node* Param(unsigned index);
Node* Loop(Node* entry);
Node* Terminate(Node* effect, Node* control);
Node* TerminateLoop(Node* effect, Node* control);
Node* TerminateThrow(Node* effect, Node* control);
Node* Merge(unsigned count, Node** controls);
Node* Phi(wasm::ValueType type, unsigned count, Node** vals, Node* control);
Node* CreateOrMergeIntoPhi(MachineRepresentation rep, Node* merge,
......
......@@ -415,14 +415,14 @@ class WasmGraphBuildingInterface {
args[i] = value_args[i].node;
}
BUILD(Throw, imm.index, imm.exception, vec2vec(args));
Unreachable(decoder);
builder_->TerminateThrow(ssa_env_->effect, ssa_env_->control);
}
void Rethrow(FullDecoder* decoder, Control* block) {
DCHECK(block->is_try_catchall() || block->is_try_catch());
TFNode* exception = block->try_info->exception;
BUILD(Rethrow, exception);
Unreachable(decoder);
builder_->TerminateThrow(ssa_env_->effect, ssa_env_->control);
}
void CatchException(FullDecoder* decoder,
......@@ -700,7 +700,7 @@ class WasmGraphBuildingInterface {
env->control = builder_->Loop(env->control);
env->effect = builder_->EffectPhi(1, &env->effect, env->control);
builder_->Terminate(env->effect, env->control);
builder_->TerminateLoop(env->effect, env->control);
// The '+ 1' here is to be able to set the instance cache as assigned.
BitVector* assigned = WasmDecoder<validate>::AnalyzeLoopAssignment(
decoder, decoder->pc(), decoder->total_locals() + 1, decoder->zone());
......
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