aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-01-13 19:37:18 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-01-15 15:11:36 -0800
commit4cc9cfa7e88b0dd4b47bedba9f190f6731422da6 (patch)
treeb17b2defe99d9f67469843e450ee82cf309a9953 /src/arch/wasm/CodeGen.zig
parentba4521ac85bbfc7cf6e6ea8d36e75907d94878c3 (diff)
downloadzig-4cc9cfa7e88b0dd4b47bedba9f190f6731422da6.tar.gz
zig-4cc9cfa7e88b0dd4b47bedba9f190f6731422da6.zip
wasm linker: track overaligned uavs
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
-rw-r--r--src/arch/wasm/CodeGen.zig11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index e44380d571..91bb00e61e 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -161,6 +161,7 @@ const WValue = union(enum) {
uav_ref: struct {
ip_index: InternPool.Index,
offset: i32 = 0,
+ orig_ptr_ty: InternPool.Index = .none,
},
/// Offset from the bottom of the virtual stack, with the offset
/// pointing to where the value lives.
@@ -1062,9 +1063,9 @@ fn emitWValue(cg: *CodeGen, value: WValue) InnerError!void {
try cg.addInst(.{
.tag = .uav_ref,
.data = if (is_obj) .{
- .uav_obj = try wasm.refUavObj(uav.ip_index),
+ .uav_obj = try wasm.refUavObj(uav.ip_index, uav.orig_ptr_ty),
} else .{
- .uav_exe = try wasm.refUavExe(uav.ip_index),
+ .uav_exe = try wasm.refUavExe(uav.ip_index, uav.orig_ptr_ty),
},
});
} else {
@@ -1072,10 +1073,10 @@ fn emitWValue(cg: *CodeGen, value: WValue) InnerError!void {
.tag = .uav_ref_off,
.data = .{
.payload = if (is_obj) try cg.addExtra(Mir.UavRefOffObj{
- .uav_obj = try wasm.refUavObj(uav.ip_index),
+ .uav_obj = try wasm.refUavObj(uav.ip_index, uav.orig_ptr_ty),
.offset = uav.offset,
}) else try cg.addExtra(Mir.UavRefOffExe{
- .uav_exe = try wasm.refUavExe(uav.ip_index),
+ .uav_exe = try wasm.refUavExe(uav.ip_index, uav.orig_ptr_ty),
.offset = uav.offset,
}),
},
@@ -3093,7 +3094,7 @@ fn lowerPtr(cg: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerErro
const offset: u64 = prev_offset + ptr.byte_offset;
return switch (ptr.base_addr) {
.nav => |nav| return .{ .nav_ref = .{ .nav_index = nav, .offset = @intCast(offset) } },
- .uav => |uav| return .{ .uav_ref = .{ .ip_index = uav.val, .offset = @intCast(offset) } },
+ .uav => |uav| return .{ .uav_ref = .{ .ip_index = uav.val, .offset = @intCast(offset), .orig_ptr_ty = uav.orig_ty } },
.int => return cg.lowerConstant(try pt.intValue(Type.usize, offset), Type.usize),
.eu_payload => return cg.fail("Wasm TODO: lower error union payload pointer", .{}),
.opt_payload => |opt_ptr| return cg.lowerPtr(opt_ptr, offset),