| ... | @@ -2960,10 +2960,21 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value) InnerError!WValue { | ... | @@ -2960,10 +2960,21 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value) InnerError!WValue { |
| 2960 | const offset = index * elem_type.abiSize(mod); | 2960 | const offset = index * elem_type.abiSize(mod); |
| 2961 | const array_ptr = try func.lowerParentPtr(elem.base.toValue()); | 2961 | const array_ptr = try func.lowerParentPtr(elem.base.toValue()); |
| 2962 | | 2962 | |
| 2963 | return WValue{ .memory_offset = .{ | 2963 | return switch (array_ptr) { |
| 2964 | .pointer = array_ptr.memory, | 2964 | .memory => |ptr_| WValue{ |
| 2965 | .offset = @intCast(u32, offset), | 2965 | .memory_offset = .{ |
| 2966 | } }; | 2966 | .pointer = ptr_, |
| | 2967 | .offset = @intCast(u32, offset), |
| | 2968 | }, |
| | 2969 | }, |
| | 2970 | .memory_offset => |mem_off| WValue{ |
| | 2971 | .memory_offset = .{ |
| | 2972 | .pointer = mem_off.pointer, |
| | 2973 | .offset = @intCast(u32, offset) + mem_off.offset, |
| | 2974 | }, |
| | 2975 | }, |
| | 2976 | else => unreachable, |
| | 2977 | }; |
| 2967 | }, | 2978 | }, |
| 2968 | .field => |field| { | 2979 | .field => |field| { |
| 2969 | const parent_ty = mod.intern_pool.typeOf(field.base).toType().childType(mod); | 2980 | const parent_ty = mod.intern_pool.typeOf(field.base).toType().childType(mod); |
| ... | @@ -3253,7 +3264,12 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue { | ... | @@ -3253,7 +3264,12 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue { |
| 3253 | }, | 3264 | }, |
| 3254 | else => unreachable, | 3265 | else => unreachable, |
| 3255 | }, | 3266 | }, |
| 3256 | .un => return func.fail("Wasm TODO: LowerConstant for {}", .{ty.fmt(mod)}), | 3267 | .un => |union_obj| { |
| | 3268 | // in this case we have a packed union which will not be passed by reference. |
| | 3269 | const field_index = ty.unionTagFieldIndex(union_obj.tag.toValue(), func.bin_file.base.options.module.?).?; |
| | 3270 | const field_ty = ty.unionFields(mod).values()[field_index].ty; |
| | 3271 | return func.lowerConstant(union_obj.val.toValue(), field_ty); |
| | 3272 | }, |
| 3257 | .memoized_call => unreachable, | 3273 | .memoized_call => unreachable, |
| 3258 | } | 3274 | } |
| 3259 | } | 3275 | } |
| ... | @@ -7173,7 +7189,7 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -7173,7 +7189,7 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 7173 | break :val try WValue.toLocal(.stack, func, result_ty); | 7189 | break :val try WValue.toLocal(.stack, func, result_ty); |
| 7174 | }; | 7190 | }; |
| 7175 | | 7191 | |
| 7176 | return func.finishAir(inst, result_ptr, &.{ extra.ptr, extra.new_value, extra.expected_value }); | 7192 | return func.finishAir(inst, result_ptr, &.{ extra.ptr, extra.expected_value, extra.new_value }); |
| 7177 | } | 7193 | } |
| 7178 | | 7194 | |
| 7179 | fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { | 7195 | fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |