mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
wasm: correctly get the type of a local for free
When determining the type of a local (read: register), we would previously subtract the stack locals also. However, this locals are also within the same `locals` list, meaning the type of the local we were retrieving was off by 2. This could create a validation error when we re-use a local of a different type.
This commit is contained in:
parent
e62bb1d689
commit
6fcd72355c
@ -106,8 +106,8 @@ const WValue = union(enum) {
|
||||
fn free(value: *WValue, gen: *Self) void {
|
||||
if (value.* != .local) return;
|
||||
const local_value = value.local.value;
|
||||
const reserved = gen.args.len + @boolToInt(gen.return_value != .none) + 2; // 2 for stack locals
|
||||
if (local_value < reserved) return; // reserved locals may never be re-used.
|
||||
const reserved = gen.args.len + @boolToInt(gen.return_value != .none);
|
||||
if (local_value < reserved + 2) return; // reserved locals may never be re-used. Also accounts for 2 stack locals.
|
||||
|
||||
const index = local_value - reserved;
|
||||
const valtype = @intToEnum(wasm.Valtype, gen.locals.items[index]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user