diff options
| author | Luuk de Gram <luuk@degram.dev> | 2023-04-17 20:05:24 +0200 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2023-04-22 21:57:38 +0200 |
| commit | 6c1ab376ddcdbb05610487e5b813d42ff37da40d (patch) | |
| tree | 759a47fde287b33ae3e40b88a83dc8723b98b379 /src/arch/wasm/CodeGen.zig | |
| parent | d4ceb12ae9d409dbd52c1f5c96312a1e6ad7d6bc (diff) | |
| download | zig-6c1ab376ddcdbb05610487e5b813d42ff37da40d.tar.gz zig-6c1ab376ddcdbb05610487e5b813d42ff37da40d.zip | |
wasm: store `__zig_lt_errors_len` in linear data
Rather than using a function call to verify if an error fits within
the global error set's length, we now store the error set' size in
the .rodata segment of the linear memory and load that value onto
the stack to check with the integer value.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index c0bab03428..9bf39b73f1 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -3339,13 +3339,14 @@ fn airCmpVector(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { fn airCmpLtErrorsLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const un_op = func.air.instructions.items(.data)[inst].un_op; const operand = try func.resolveInst(un_op); - const sym_index = try func.bin_file.getGlobalSymbol("__zig_lt_errors_len", null); + const sym_index = try func.bin_file.getGlobalSymbol("__zig_errors_len", null); + const errors_len = WValue{ .memory = sym_index }; try func.emitWValue(operand); - try func.addLabel(.call, sym_index); - const result = try func.allocLocal(Type.bool); - try func.addLabel(.local_set, result.local.value); - return func.finishAir(inst, result, &.{un_op}); + const errors_len_val = try func.load(errors_len, Type.err_int, 0); + const result = try func.cmp(.stack, errors_len_val, Type.err_int, .lt); + + return func.finishAir(inst, try result.toLocal(func, Type.bool), &.{un_op}); } fn airBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { @@ -6518,7 +6519,6 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { fn airErrorSetHasValue(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const ty_op = func.air.instructions.items(.data)[inst].ty_op; - if (func.liveness.isUnused(inst)) return func.finishAir(inst, .none, &.{ty_op.operand}); const operand = try func.resolveInst(ty_op.operand); const error_set_ty = func.air.getRefType(ty_op.ty); |
