Commit e60e9234 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [decoder] Only call interface methods for reachable instructions

Not all interface implementations can handle unreachable code
correctly. The baseline compiler will fail if it tries to pop a value
from an empty stack. Instead of fixing this in the interface (the
baseline compiler in this case), this CL fixes this by not calling the
interface for unreachable instructions.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: I567783ce4191ff907b2f90e73b66274728064092
Reviewed-on: https://chromium-review.googlesource.com/715638
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: 's avatarAndreas Rossberg <rossberg@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48544}
parent afd2f580
This diff is collapsed.
......@@ -203,11 +203,12 @@ class WasmGraphBuildingInterface {
}
void FallThruTo(Decoder* decoder, Control* c) {
DCHECK(!c->is_loop());
MergeValuesInto(decoder, c);
SetEnv(c->end_env);
}
void PopControl(Decoder* decoder, Control* block) {
if (!block->is_loop()) SetEnv(block->end_env);
if (block->is_onearmed_if()) {
Goto(decoder, block->false_env, block->end_env);
}
......@@ -245,6 +246,10 @@ class WasmGraphBuildingInterface {
void Drop(Decoder* decoder, const Value& value) {}
void DoReturn(Decoder* decoder, Vector<Value> values, bool implicit) {
if (implicit) {
DCHECK_EQ(1, decoder->control_depth());
SetEnv(decoder->control_at(0)->end_env);
}
size_t num_values = values.size();
TFNode** buffer = GetNodes(values);
for (size_t i = 0; i < num_values; ++i) {
......
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