| ... | ... | @@ -253,6 +253,13 @@ all_zcu_locals: std.ArrayListUnmanaged(u8) = .empty, |
| 253 | 253 | params_scratch: std.ArrayListUnmanaged(std.wasm.Valtype) = .empty, |
| 254 | 254 | returns_scratch: std.ArrayListUnmanaged(std.wasm.Valtype) = .empty, |
| 255 | 255 | |
| 256 | /// All Zcu error names in order, null-terminated, concatenated. No need to |
| 257 | /// serialize; trivially reconstructed. |
| 258 | error_name_bytes: std.ArrayListUnmanaged(u8) = .empty, |
| 259 | /// For each Zcu error, in order, offset into `error_name_bytes` where the name |
| 260 | /// is stored. No need to serialize; trivially reconstructed. |
| 261 | error_name_offs: std.ArrayListUnmanaged(u32) = .empty, |
| 262 | |
| 256 | 263 | pub const UavFixup = extern struct { |
| 257 | 264 | uavs_exe_index: UavsExeIndex, |
| 258 | 265 | /// Index into `string_bytes`. |
| ... | ... | @@ -979,12 +986,11 @@ pub const GlobalImport = extern struct { |
| 979 | 986 | __tls_align, |
| 980 | 987 | __tls_base, |
| 981 | 988 | __tls_size, |
| 982 | | __zig_error_name_table, |
| 983 | 989 | // Next, index into `object_globals`. |
| 984 | 990 | // Next, index into `navs_obj` or `navs_exe` depending on whether emitting an object. |
| 985 | 991 | _, |
| 986 | 992 | |
| 987 | | const first_object_global = @intFromEnum(Resolution.__zig_error_name_table) + 1; |
| 993 | const first_object_global = @intFromEnum(Resolution.__tls_size) + 1; |
| 988 | 994 | |
| 989 | 995 | pub const Unpacked = union(enum) { |
| 990 | 996 | unresolved, |
| ... | ... | @@ -994,7 +1000,6 @@ pub const GlobalImport = extern struct { |
| 994 | 1000 | __tls_align, |
| 995 | 1001 | __tls_base, |
| 996 | 1002 | __tls_size, |
| 997 | | __zig_error_name_table, |
| 998 | 1003 | object_global: ObjectGlobalIndex, |
| 999 | 1004 | nav_exe: NavsExeIndex, |
| 1000 | 1005 | nav_obj: NavsObjIndex, |
| ... | ... | @@ -1009,7 +1014,6 @@ pub const GlobalImport = extern struct { |
| 1009 | 1014 | .__tls_align => .__tls_align, |
| 1010 | 1015 | .__tls_base => .__tls_base, |
| 1011 | 1016 | .__tls_size => .__tls_size, |
| 1012 | | .__zig_error_name_table => .__zig_error_name_table, |
| 1013 | 1017 | _ => { |
| 1014 | 1018 | const i: u32 = @intFromEnum(r); |
| 1015 | 1019 | const object_global_index = i - first_object_global; |
| ... | ... | @@ -1036,7 +1040,6 @@ pub const GlobalImport = extern struct { |
| 1036 | 1040 | .__tls_align => .__tls_align, |
| 1037 | 1041 | .__tls_base => .__tls_base, |
| 1038 | 1042 | .__tls_size => .__tls_size, |
| 1039 | | .__zig_error_name_table => .__zig_error_name_table, |
| 1040 | 1043 | .object_global => |i| @enumFromInt(first_object_global + @intFromEnum(i)), |
| 1041 | 1044 | .nav_obj => |i| @enumFromInt(first_object_global + wasm.object_globals.items.len + @intFromEnum(i)), |
| 1042 | 1045 | .nav_exe => |i| @enumFromInt(first_object_global + wasm.object_globals.items.len + @intFromEnum(i)), |
| ... | ... | @@ -1062,7 +1065,6 @@ pub const GlobalImport = extern struct { |
| 1062 | 1065 | .__tls_align => @tagName(Unpacked.__tls_align), |
| 1063 | 1066 | .__tls_base => @tagName(Unpacked.__tls_base), |
| 1064 | 1067 | .__tls_size => @tagName(Unpacked.__tls_size), |
| 1065 | | .__zig_error_name_table => @tagName(Unpacked.__zig_error_name_table), |
| 1066 | 1068 | .object_global => |i| i.name(wasm).slice(wasm), |
| 1067 | 1069 | .nav_obj => |i| i.name(wasm), |
| 1068 | 1070 | .nav_exe => |i| i.name(wasm), |
| ... | ... | @@ -1332,6 +1334,7 @@ pub const DataSegment = extern struct { |
| 1332 | 1334 | }; |
| 1333 | 1335 | |
| 1334 | 1336 | pub const Id = enum(u32) { |
| 1337 | __zig_error_names, |
| 1335 | 1338 | __zig_error_name_table, |
| 1336 | 1339 | /// First, an `ObjectDataSegmentIndex`. |
| 1337 | 1340 | /// Next, index into `uavs_obj` or `uavs_exe` depending on whether emitting an object. |
| ... | ... | @@ -1341,6 +1344,7 @@ pub const DataSegment = extern struct { |
| 1341 | 1344 | const first_object = @intFromEnum(Id.__zig_error_name_table) + 1; |
| 1342 | 1345 | |
| 1343 | 1346 | pub const Unpacked = union(enum) { |
| 1347 | __zig_error_names, |
| 1344 | 1348 | __zig_error_name_table, |
| 1345 | 1349 | object: ObjectDataSegmentIndex, |
| 1346 | 1350 | uav_exe: UavsExeIndex, |
| ... | ... | @@ -1351,6 +1355,7 @@ pub const DataSegment = extern struct { |
| 1351 | 1355 | |
| 1352 | 1356 | pub fn pack(wasm: *const Wasm, unpacked: Unpacked) Id { |
| 1353 | 1357 | return switch (unpacked) { |
| 1358 | .__zig_error_names => .__zig_error_names, |
| 1354 | 1359 | .__zig_error_name_table => .__zig_error_name_table, |
| 1355 | 1360 | .object => |i| @enumFromInt(first_object + @intFromEnum(i)), |
| 1356 | 1361 | inline .uav_exe, .uav_obj => |i| @enumFromInt(first_object + wasm.object_data_segments.items.len + @intFromEnum(i)), |
| ... | ... | @@ -1361,6 +1366,7 @@ pub const DataSegment = extern struct { |
| 1361 | 1366 | |
| 1362 | 1367 | pub fn unpack(id: Id, wasm: *const Wasm) Unpacked { |
| 1363 | 1368 | return switch (id) { |
| 1369 | .__zig_error_names => .__zig_error_names, |
| 1364 | 1370 | .__zig_error_name_table => .__zig_error_name_table, |
| 1365 | 1371 | _ => { |
| 1366 | 1372 | const object_index = @intFromEnum(id) - first_object; |
| ... | ... | @@ -1393,7 +1399,7 @@ pub const DataSegment = extern struct { |
| 1393 | 1399 | |
| 1394 | 1400 | pub fn category(id: Id, wasm: *const Wasm) Category { |
| 1395 | 1401 | return switch (unpack(id, wasm)) { |
| 1396 | | .__zig_error_name_table => .data, |
| 1402 | .__zig_error_names, .__zig_error_name_table => .data, |
| 1397 | 1403 | .object => |i| { |
| 1398 | 1404 | const ptr = i.ptr(wasm); |
| 1399 | 1405 | if (ptr.flags.tls) return .tls; |
| ... | ... | @@ -1414,7 +1420,7 @@ pub const DataSegment = extern struct { |
| 1414 | 1420 | |
| 1415 | 1421 | pub fn isTls(id: Id, wasm: *const Wasm) bool { |
| 1416 | 1422 | return switch (unpack(id, wasm)) { |
| 1417 | | .__zig_error_name_table => false, |
| 1423 | .__zig_error_names, .__zig_error_name_table => false, |
| 1418 | 1424 | .object => |i| i.ptr(wasm).flags.tls, |
| 1419 | 1425 | .uav_exe, .uav_obj => false, |
| 1420 | 1426 | inline .nav_exe, .nav_obj => |i| { |
| ... | ... | @@ -1432,7 +1438,7 @@ pub const DataSegment = extern struct { |
| 1432 | 1438 | |
| 1433 | 1439 | pub fn name(id: Id, wasm: *const Wasm) []const u8 { |
| 1434 | 1440 | return switch (unpack(id, wasm)) { |
| 1435 | | .__zig_error_name_table, .uav_exe, .uav_obj => ".data", |
| 1441 | .__zig_error_names, .__zig_error_name_table, .uav_exe, .uav_obj => ".data", |
| 1436 | 1442 | .object => |i| i.ptr(wasm).name.unwrap().?.slice(wasm), |
| 1437 | 1443 | inline .nav_exe, .nav_obj => |i| { |
| 1438 | 1444 | const zcu = wasm.base.comp.zcu.?; |
| ... | ... | @@ -1445,6 +1451,7 @@ pub const DataSegment = extern struct { |
| 1445 | 1451 | |
| 1446 | 1452 | pub fn alignment(id: Id, wasm: *const Wasm) Alignment { |
| 1447 | 1453 | return switch (unpack(id, wasm)) { |
| 1454 | .__zig_error_names => .@"1", |
| 1448 | 1455 | .__zig_error_name_table => wasm.pointerAlignment(), |
| 1449 | 1456 | .object => |i| i.ptr(wasm).flags.alignment, |
| 1450 | 1457 | inline .uav_exe, .uav_obj => |i| { |
| ... | ... | @@ -1472,6 +1479,7 @@ pub const DataSegment = extern struct { |
| 1472 | 1479 | |
| 1473 | 1480 | pub fn refCount(id: Id, wasm: *const Wasm) u32 { |
| 1474 | 1481 | return switch (unpack(id, wasm)) { |
| 1482 | .__zig_error_names => @intCast(wasm.error_name_offs.items.len), |
| 1475 | 1483 | .__zig_error_name_table => wasm.error_name_table_ref_count, |
| 1476 | 1484 | .object, .uav_obj, .nav_obj => 0, |
| 1477 | 1485 | inline .uav_exe, .nav_exe => |i| i.value(wasm).count, |
| ... | ... | @@ -1481,7 +1489,7 @@ pub const DataSegment = extern struct { |
| 1481 | 1489 | pub fn isPassive(id: Id, wasm: *const Wasm) bool { |
| 1482 | 1490 | if (wasm.base.comp.config.import_memory and !id.isBss(wasm)) return true; |
| 1483 | 1491 | return switch (unpack(id, wasm)) { |
| 1484 | | .__zig_error_name_table => false, |
| 1492 | .__zig_error_names, .__zig_error_name_table => false, |
| 1485 | 1493 | .object => |i| i.ptr(wasm).flags.is_passive, |
| 1486 | 1494 | .uav_exe, .uav_obj, .nav_exe, .nav_obj => false, |
| 1487 | 1495 | }; |
| ... | ... | @@ -1489,7 +1497,7 @@ pub const DataSegment = extern struct { |
| 1489 | 1497 | |
| 1490 | 1498 | pub fn isEmpty(id: Id, wasm: *const Wasm) bool { |
| 1491 | 1499 | return switch (unpack(id, wasm)) { |
| 1492 | | .__zig_error_name_table => false, |
| 1500 | .__zig_error_names, .__zig_error_name_table => false, |
| 1493 | 1501 | .object => |i| i.ptr(wasm).payload.off == .none, |
| 1494 | 1502 | inline .uav_exe, .uav_obj, .nav_exe, .nav_obj => |i| i.value(wasm).code.off == .none, |
| 1495 | 1503 | }; |
| ... | ... | @@ -1497,10 +1505,11 @@ pub const DataSegment = extern struct { |
| 1497 | 1505 | |
| 1498 | 1506 | pub fn size(id: Id, wasm: *const Wasm) u32 { |
| 1499 | 1507 | return switch (unpack(id, wasm)) { |
| 1508 | .__zig_error_names => @intCast(wasm.error_name_bytes.items.len), |
| 1500 | 1509 | .__zig_error_name_table => { |
| 1501 | 1510 | const comp = wasm.base.comp; |
| 1502 | 1511 | const zcu = comp.zcu.?; |
| 1503 | | const errors_len = 1 + zcu.intern_pool.global_error_set.getNamesFromMainThread().len; |
| 1512 | const errors_len = wasm.error_name_offs.items.len; |
| 1504 | 1513 | const elem_size = ZcuType.slice_const_u8_sentinel_0.abiSize(zcu); |
| 1505 | 1514 | return @intCast(errors_len * elem_size); |
| 1506 | 1515 | }, |
| ... | ... | @@ -1589,8 +1598,8 @@ const PreloadedStrings = struct { |
| 1589 | 1598 | __wasm_init_memory: String, |
| 1590 | 1599 | __wasm_init_memory_flag: String, |
| 1591 | 1600 | __wasm_init_tls: String, |
| 1592 | | __zig_error_name_table: String, |
| 1593 | 1601 | __zig_error_names: String, |
| 1602 | __zig_error_name_table: String, |
| 1594 | 1603 | __zig_errors_len: String, |
| 1595 | 1604 | _initialize: String, |
| 1596 | 1605 | _start: String, |
| ... | ... | @@ -2367,6 +2376,9 @@ pub fn deinit(wasm: *Wasm) void { |
| 2367 | 2376 | wasm.params_scratch.deinit(gpa); |
| 2368 | 2377 | wasm.returns_scratch.deinit(gpa); |
| 2369 | 2378 | |
| 2379 | wasm.error_name_bytes.deinit(gpa); |
| 2380 | wasm.error_name_offs.deinit(gpa); |
| 2381 | |
| 2370 | 2382 | wasm.missing_exports.deinit(gpa); |
| 2371 | 2383 | } |
| 2372 | 2384 | |