| ... | ... | @@ -189,6 +189,9 @@ navs_exe: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, ZcuDataExe) = .emp |
| 189 | 189 | uavs_obj: std.AutoArrayHashMapUnmanaged(InternPool.Index, ZcuDataObj) = .empty, |
| 190 | 190 | /// Tracks ref count to optimize LEB encodings for UAV references. |
| 191 | 191 | uavs_exe: std.AutoArrayHashMapUnmanaged(InternPool.Index, ZcuDataExe) = .empty, |
| 192 | /// Sparse table of uavs that need to be emitted with greater alignment than |
| 193 | /// the default for the type. |
| 194 | overaligned_uavs: std.AutoArrayHashMapUnmanaged(InternPool.Index, Alignment) = .empty, |
| 192 | 195 | /// When the key is an enum type, this represents a `@tagName` function. |
| 193 | 196 | zcu_funcs: std.AutoArrayHashMapUnmanaged(InternPool.Index, ZcuFunc) = .empty, |
| 194 | 197 | nav_exports: std.AutoArrayHashMapUnmanaged(NavExport, Zcu.Export.Index) = .empty, |
| ... | ... | @@ -1945,6 +1948,7 @@ pub const DataSegmentId = enum(u32) { |
| 1945 | 1948 | const zcu = wasm.base.comp.zcu.?; |
| 1946 | 1949 | const ip = &zcu.intern_pool; |
| 1947 | 1950 | const ip_index = i.key(wasm).*; |
| 1951 | if (wasm.overaligned_uavs.get(ip_index)) |a| return a; |
| 1948 | 1952 | const ty: Zcu.Type = .fromInterned(ip.typeOf(ip_index)); |
| 1949 | 1953 | const result = ty.abiAlignment(zcu); |
| 1950 | 1954 | assert(result != .none); |
| ... | ... | @@ -3085,6 +3089,7 @@ pub fn deinit(wasm: *Wasm) void { |
| 3085 | 3089 | wasm.navs_obj.deinit(gpa); |
| 3086 | 3090 | wasm.uavs_exe.deinit(gpa); |
| 3087 | 3091 | wasm.uavs_obj.deinit(gpa); |
| 3092 | wasm.overaligned_uavs.deinit(gpa); |
| 3088 | 3093 | wasm.zcu_funcs.deinit(gpa); |
| 3089 | 3094 | wasm.nav_exports.deinit(gpa); |
| 3090 | 3095 | wasm.uav_exports.deinit(gpa); |
| ... | ... | @@ -4397,10 +4402,22 @@ pub fn symbolNameIndex(wasm: *Wasm, name: String) Allocator.Error!SymbolTableInd |
| 4397 | 4402 | return @enumFromInt(gop.index); |
| 4398 | 4403 | } |
| 4399 | 4404 | |
| 4400 | | pub fn refUavObj(wasm: *Wasm, ip_index: InternPool.Index) !UavsObjIndex { |
| 4405 | pub fn refUavObj(wasm: *Wasm, ip_index: InternPool.Index, orig_ptr_ty: InternPool.Index) !UavsObjIndex { |
| 4401 | 4406 | const comp = wasm.base.comp; |
| 4407 | const zcu = comp.zcu.?; |
| 4408 | const ip = &zcu.intern_pool; |
| 4402 | 4409 | const gpa = comp.gpa; |
| 4403 | 4410 | assert(comp.config.output_mode == .Obj); |
| 4411 | |
| 4412 | if (orig_ptr_ty != .none) { |
| 4413 | const abi_alignment = Zcu.Type.fromInterned(ip.typeOf(ip_index)).abiAlignment(zcu); |
| 4414 | const explicit_alignment = ip.indexToKey(orig_ptr_ty).ptr_type.flags.alignment; |
| 4415 | if (explicit_alignment.compare(.gt, abi_alignment)) { |
| 4416 | const gop = try wasm.overaligned_uavs.getOrPut(gpa, ip_index); |
| 4417 | gop.value_ptr.* = if (gop.found_existing) gop.value_ptr.maxStrict(explicit_alignment) else explicit_alignment; |
| 4418 | } |
| 4419 | } |
| 4420 | |
| 4404 | 4421 | const gop = try wasm.uavs_obj.getOrPut(gpa, ip_index); |
| 4405 | 4422 | if (!gop.found_existing) gop.value_ptr.* = .{ |
| 4406 | 4423 | // Lowering the value is delayed to avoid recursion. |
| ... | ... | @@ -4410,10 +4427,22 @@ pub fn refUavObj(wasm: *Wasm, ip_index: InternPool.Index) !UavsObjIndex { |
| 4410 | 4427 | return @enumFromInt(gop.index); |
| 4411 | 4428 | } |
| 4412 | 4429 | |
| 4413 | | pub fn refUavExe(wasm: *Wasm, ip_index: InternPool.Index) !UavsExeIndex { |
| 4430 | pub fn refUavExe(wasm: *Wasm, ip_index: InternPool.Index, orig_ptr_ty: InternPool.Index) !UavsExeIndex { |
| 4414 | 4431 | const comp = wasm.base.comp; |
| 4432 | const zcu = comp.zcu.?; |
| 4433 | const ip = &zcu.intern_pool; |
| 4415 | 4434 | const gpa = comp.gpa; |
| 4416 | 4435 | assert(comp.config.output_mode != .Obj); |
| 4436 | |
| 4437 | if (orig_ptr_ty != .none) { |
| 4438 | const abi_alignment = Zcu.Type.fromInterned(ip.typeOf(ip_index)).abiAlignment(zcu); |
| 4439 | const explicit_alignment = ip.indexToKey(orig_ptr_ty).ptr_type.flags.alignment; |
| 4440 | if (explicit_alignment.compare(.gt, abi_alignment)) { |
| 4441 | const gop = try wasm.overaligned_uavs.getOrPut(gpa, ip_index); |
| 4442 | gop.value_ptr.* = if (gop.found_existing) gop.value_ptr.maxStrict(explicit_alignment) else explicit_alignment; |
| 4443 | } |
| 4444 | } |
| 4445 | |
| 4417 | 4446 | const gop = try wasm.uavs_exe.getOrPut(gpa, ip_index); |
| 4418 | 4447 | if (gop.found_existing) { |
| 4419 | 4448 | gop.value_ptr.count += 1; |