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 {...@@ -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());
29622962
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 };
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 });
7177}7193}
71787194
7179fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7195fn 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" {...@@ -17,6 +17,7 @@ test "union that needs padding bytes inside an array" {
17 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;17 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
18 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO18 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
19 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;19 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
20 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
2021
21 var as = [_]A{22 var as = [_]A{
22 A{ .B = B{ .D = 1 } },23 A{ .B = B{ .D = 1 } },