Skip to content

Commit

Permalink
fix bug due to interaction with WebAssembly#6549
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Apr 29, 2024
1 parent f5449d8 commit 1f07285
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/wasm/wasm-stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@ void BinaryInstWriter::visitBreak(Break* curr) {

assert(curr->type.hasRef());

auto emitCast = [&](Type to) {
auto emitCast = [&](Type to, Type from) {
// Shim a tiny bit of IR, just enough to get visitRefCast to see what we
// are casting, and to emit the proper thing.
LocalGet get;
get.type = from;
RefCast cast;
cast.type = to;
cast.ref = &get;
visitRefCast(&cast);
};

if (!type.isTuple()) {
// Simple: Just emit a cast, and then the type matches Binaryen IR's.
emitCast(type);
emitCast(type, unrefinedType);
} else {
// Tuples are trickier to handle, and we need to use scratch locals. Stash
// all the values on the stack to those locals, then reload them, casting
Expand All @@ -100,7 +105,7 @@ void BinaryInstWriter::visitBreak(Break* curr) {
if (type[i].isRef()) {
// Note that we cast all types here, when perhaps only some of the
// tuple's lanes need that. This is simpler.
emitCast(type[i]);
emitCast(type[i], unrefinedType[i]);
}
}
}
Expand Down

0 comments on commit 1f07285

Please sign in to comment.