| ... | @@ -1886,8 +1886,10 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -1886,8 +1886,10 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 1886 | .call_never_tail => cg.airCall(inst, .never_tail), | 1886 | .call_never_tail => cg.airCall(inst, .never_tail), |
| 1887 | .call_never_inline => cg.airCall(inst, .never_inline), | 1887 | .call_never_inline => cg.airCall(inst, .never_inline), |
| 1888 | | 1888 | |
| 1889 | .is_err => cg.airIsErr(inst, .i32_ne), | 1889 | .is_err => cg.airIsErr(inst, .i32_ne, .value), |
| 1890 | .is_non_err => cg.airIsErr(inst, .i32_eq), | 1890 | .is_non_err => cg.airIsErr(inst, .i32_eq, .value), |
| | 1891 | .is_err_ptr => cg.airIsErr(inst, .i32_ne, .ptr), |
| | 1892 | .is_non_err_ptr => cg.airIsErr(inst, .i32_eq, .ptr), |
| 1891 | | 1893 | |
| 1892 | .is_null => cg.airIsNull(inst, .i32_eq, .value), | 1894 | .is_null => cg.airIsNull(inst, .i32_eq, .value), |
| 1893 | .is_non_null => cg.airIsNull(inst, .i32_ne, .value), | 1895 | .is_non_null => cg.airIsNull(inst, .i32_ne, .value), |
| ... | @@ -1970,8 +1972,6 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -1970,8 +1972,6 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 1970 | .runtime_nav_ptr => cg.airRuntimeNavPtr(inst), | 1972 | .runtime_nav_ptr => cg.airRuntimeNavPtr(inst), |
| 1971 | | 1973 | |
| 1972 | .assembly, | 1974 | .assembly, |
| 1973 | .is_err_ptr, | | |
| 1974 | .is_non_err_ptr, | | |
| 1975 | | 1975 | |
| 1976 | .err_return_trace, | 1976 | .err_return_trace, |
| 1977 | .set_err_return_trace, | 1977 | .set_err_return_trace, |
| ... | @@ -4105,7 +4105,7 @@ fn airSwitchDispatch(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4105,7 +4105,7 @@ fn airSwitchDispatch(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4105 | return cg.finishAir(inst, .none, &.{br.operand}); | 4105 | return cg.finishAir(inst, .none, &.{br.operand}); |
| 4106 | } | 4106 | } |
| 4107 | | 4107 | |
| 4108 | fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerError!void { | 4108 | fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode, op_kind: enum { value, ptr }) InnerError!void { |
| 4109 | const zcu = cg.pt.zcu; | 4109 | const zcu = cg.pt.zcu; |
| 4110 | const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op; | 4110 | const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 4111 | const operand = try cg.resolveInst(un_op); | 4111 | const operand = try cg.resolveInst(un_op); |
| ... | @@ -4122,7 +4122,7 @@ fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerEr | ... | @@ -4122,7 +4122,7 @@ fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerEr |
| 4122 | } | 4122 | } |
| 4123 | | 4123 | |
| 4124 | try cg.emitWValue(operand); | 4124 | try cg.emitWValue(operand); |
| 4125 | if (pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) { | 4125 | if (op_kind == .ptr or pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) { |
| 4126 | try cg.addMemArg(.i32_load16_u, .{ | 4126 | try cg.addMemArg(.i32_load16_u, .{ |
| 4127 | .offset = operand.offset() + @as(u32, @intCast(errUnionErrorOffset(pl_ty, zcu))), | 4127 | .offset = operand.offset() + @as(u32, @intCast(errUnionErrorOffset(pl_ty, zcu))), |
| 4128 | .alignment = @intCast(Type.anyerror.abiAlignment(zcu).toByteUnits().?), | 4128 | .alignment = @intCast(Type.anyerror.abiAlignment(zcu).toByteUnits().?), |
| ... | @@ -6462,9 +6462,6 @@ fn lowerTry( | ... | @@ -6462,9 +6462,6 @@ fn lowerTry( |
| 6462 | operand_is_ptr: bool, | 6462 | operand_is_ptr: bool, |
| 6463 | ) InnerError!WValue { | 6463 | ) InnerError!WValue { |
| 6464 | const zcu = cg.pt.zcu; | 6464 | const zcu = cg.pt.zcu; |
| 6465 | if (operand_is_ptr) { | | |
| 6466 | return cg.fail("TODO: lowerTry for pointers", .{}); | | |
| 6467 | } | | |
| 6468 | | 6465 | |
| 6469 | const pl_ty = err_union_ty.errorUnionPayload(zcu); | 6466 | const pl_ty = err_union_ty.errorUnionPayload(zcu); |
| 6470 | const pl_has_bits = pl_ty.hasRuntimeBitsIgnoreComptime(zcu); | 6467 | const pl_has_bits = pl_ty.hasRuntimeBitsIgnoreComptime(zcu); |
| ... | @@ -6475,7 +6472,7 @@ fn lowerTry( | ... | @@ -6475,7 +6472,7 @@ fn lowerTry( |
| 6475 | | 6472 | |
| 6476 | // check if the error tag is set for the error union. | 6473 | // check if the error tag is set for the error union. |
| 6477 | try cg.emitWValue(err_union); | 6474 | try cg.emitWValue(err_union); |
| 6478 | if (pl_has_bits) { | 6475 | if (pl_has_bits or operand_is_ptr) { |
| 6479 | const err_offset: u32 = @intCast(errUnionErrorOffset(pl_ty, zcu)); | 6476 | const err_offset: u32 = @intCast(errUnionErrorOffset(pl_ty, zcu)); |
| 6480 | try cg.addMemArg(.i32_load16_u, .{ | 6477 | try cg.addMemArg(.i32_load16_u, .{ |
| 6481 | .offset = err_union.offset() + err_offset, | 6478 | .offset = err_union.offset() + err_offset, |
| ... | @@ -6497,12 +6494,12 @@ fn lowerTry( | ... | @@ -6497,12 +6494,12 @@ fn lowerTry( |
| 6497 | } | 6494 | } |
| 6498 | | 6495 | |
| 6499 | // if we reach here it means error was not set, and we want the payload | 6496 | // if we reach here it means error was not set, and we want the payload |
| 6500 | if (!pl_has_bits) { | 6497 | if (!pl_has_bits and !operand_is_ptr) { |
| 6501 | return .none; | 6498 | return .none; |
| 6502 | } | 6499 | } |
| 6503 | | 6500 | |
| 6504 | const pl_offset: u32 = @intCast(errUnionPayloadOffset(pl_ty, zcu)); | 6501 | const pl_offset: u32 = @intCast(errUnionPayloadOffset(pl_ty, zcu)); |
| 6505 | if (isByRef(pl_ty, zcu, cg.target)) { | 6502 | if (operand_is_ptr or isByRef(pl_ty, zcu, cg.target)) { |
| 6506 | return buildPointerOffset(cg, err_union, pl_offset, .new); | 6503 | return buildPointerOffset(cg, err_union, pl_offset, .new); |
| 6507 | } | 6504 | } |
| 6508 | const payload = try cg.load(err_union, pl_ty, pl_offset); | 6505 | const payload = try cg.load(err_union, pl_ty, pl_offset); |