| ... | ... | @@ -1706,9 +1706,11 @@ fn isByRef(ty: Type, target: std.Target) bool { |
| 1706 | 1706 | return true; |
| 1707 | 1707 | }, |
| 1708 | 1708 | .Optional => { |
| 1709 | | if (ty.optionalReprIsPayload()) return false; |
| 1709 | if (ty.isPtrLikeOptional()) return false; |
| 1710 | 1710 | var buf: Type.Payload.ElemType = undefined; |
| 1711 | | return ty.optionalChild(&buf).hasRuntimeBitsIgnoreComptime(); |
| 1711 | const pl_type = ty.optionalChild(&buf); |
| 1712 | if (pl_type.zigTypeTag() == .ErrorSet) return false; |
| 1713 | return pl_type.hasRuntimeBitsIgnoreComptime(); |
| 1712 | 1714 | }, |
| 1713 | 1715 | .Pointer => { |
| 1714 | 1716 | // Slices act like struct and will be passed by reference |
| ... | ... | @@ -3869,14 +3871,17 @@ fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind: |
| 3869 | 3871 | /// NOTE: Leaves the result on the stack |
| 3870 | 3872 | fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcode) InnerError!WValue { |
| 3871 | 3873 | try func.emitWValue(operand); |
| 3874 | var buf: Type.Payload.ElemType = undefined; |
| 3875 | const payload_ty = optional_ty.optionalChild(&buf); |
| 3872 | 3876 | if (!optional_ty.optionalReprIsPayload()) { |
| 3873 | | var buf: Type.Payload.ElemType = undefined; |
| 3874 | | const payload_ty = optional_ty.optionalChild(&buf); |
| 3875 | 3877 | // When payload is zero-bits, we can treat operand as a value, rather than |
| 3876 | 3878 | // a pointer to the stack value |
| 3877 | 3879 | if (payload_ty.hasRuntimeBitsIgnoreComptime()) { |
| 3878 | 3880 | try func.addMemArg(.i32_load8_u, .{ .offset = operand.offset(), .alignment = 1 }); |
| 3879 | 3881 | } |
| 3882 | } else if (payload_ty.isSlice()) { |
| 3883 | // move the ptr on top of the stack |
| 3884 | _ = try func.load(operand, Type.usize, 0); |
| 3880 | 3885 | } |
| 3881 | 3886 | |
| 3882 | 3887 | // Compare the null value with '0' |