Skip to content

Commit

Permalink
[wasm] Support block parameters
Browse files Browse the repository at this point in the history
This adds support for parameters on block, loop, if, cf the multi-value proposal at:
https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md

With this CL, we ssucceed on all tests in:
WebAssembly/multi-value#2
except those involving multiple returns from functions.

R=titzer@chromium.org

Change-Id: I14a33e86450148f6aed2b8b8cc6bebb2303625c6
Reviewed-on: https://chromium-review.googlesource.com/712578
Commit-Queue: Andreas Rossberg <rossberg@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48871}
  • Loading branch information
rossberg authored and Commit Bot committed Oct 24, 2017
1 parent d75ecf1 commit 06061b7
Show file tree
Hide file tree
Showing 8 changed files with 567 additions and 229 deletions.
14 changes: 7 additions & 7 deletions src/wasm/baseline/liftoff-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ class LiftoffCompiler {
}

void FallThruTo(Decoder* decoder, Control* c) {
if (c->merge.reached) {
if (c->end_merge.reached) {
__ MergeFullStackWith(c->label_state);
} else {
c->label_state.Split(*__ cache_state());
}
}

void PopControl(Decoder* decoder, Control* c) {
if (!c->is_loop() && c->merge.reached) {
if (!c->is_loop() && c->end_merge.reached) {
__ cache_state()->Steal(c->label_state);
}
if (!c->label->is_bound()) {
Expand Down Expand Up @@ -383,12 +383,12 @@ class LiftoffCompiler {
unsupported(decoder, "select");
}

void BreakTo(Decoder* decoder, Control* target) {
if (!target->merge.reached) {
void Br(Decoder* decoder, Control* target) {
if (!target->br_merge()->reached) {
target->label_state.InitMerge(*__ cache_state(), __ num_locals(),
target->break_arity());
target->br_merge()->arity);
}
__ MergeStackWith(target->label_state, target->break_arity());
__ MergeStackWith(target->label_state, target->br_merge()->arity);
__ jmp(target->label.get());
}

Expand All @@ -397,7 +397,7 @@ class LiftoffCompiler {
Register value = __ PopToRegister(kWasmI32);
__ JumpIfZero(value, &cont_false);

BreakTo(decoder, target);
Br(decoder, target);
__ bind(&cont_false);
}

Expand Down
Loading

0 comments on commit 06061b7

Please sign in to comment.