authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-04 10:26:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:51:10-07:00
log44d8cf9331218653c283a930bbc74e6871fe1701
treebef2d41cc7eb71e0c05e02f3833d4801b37be48d
parentdce80f67d4ab9a9387be595c0275853369ffb7e4

wasm: address behavior test regressions


2 files changed, 23 insertions(+), 6 deletions(-)

src/arch/wasm/CodeGen.zig+22-6
......@@ -2960,10 +2960,21 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value) InnerError!WValue {
29602960 const offset = index * elem_type.abiSize(mod);
29612961 const array_ptr = try func.lowerParentPtr(elem.base.toValue());
29622962
2963 return WValue{ .memory_offset = .{
2964 .pointer = array_ptr.memory,
2965 .offset = @intCast(u32, offset),
2966 } };
2963 return switch (array_ptr) {
2964 .memory => |ptr_| WValue{
2965 .memory_offset = .{
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 };
29672978 },
29682979 .field => |field| {
29692980 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 {
32533264 },
32543265 else => unreachable,
32553266 },
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 },
32573273 .memoized_call => unreachable,
32583274 }
32593275}
......@@ -7173,7 +7189,7 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
71737189 break :val try WValue.toLocal(.stack, func, result_ty);
71747190 };
71757191
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 });
71777193}
71787194
71797195fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
test/behavior/bugs/1381.zig+1
......@@ -17,6 +17,7 @@ test "union that needs padding bytes inside an array" {
1717 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1818 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
1919 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
20 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
2021
2122 var as = [_]A{
2223 A{ .B = B{ .D = 1 } },