| ... | @@ -106,8 +106,8 @@ const WValue = union(enum) { | ... | @@ -106,8 +106,8 @@ const WValue = union(enum) { |
| 106 | fn free(value: *WValue, gen: *Self) void { | 106 | fn free(value: *WValue, gen: *Self) void { |
| 107 | if (value.* != .local) return; | 107 | if (value.* != .local) return; |
| 108 | const local_value = value.local.value; | 108 | const local_value = value.local.value; |
| 109 | const reserved = gen.args.len + @boolToInt(gen.return_value != .none) + 2; // 2 for stack locals | 109 | const reserved = gen.args.len + @boolToInt(gen.return_value != .none); |
| 110 | if (local_value < reserved) return; // reserved locals may never be re-used. | 110 | if (local_value < reserved + 2) return; // reserved locals may never be re-used. Also accounts for 2 stack locals. |
| 111 | | 111 | |
| 112 | const index = local_value - reserved; | 112 | const index = local_value - reserved; |
| 113 | const valtype = @intToEnum(wasm.Valtype, gen.locals.items[index]); | 113 | const valtype = @intToEnum(wasm.Valtype, gen.locals.items[index]); |