| author | |
| committer | |
| log | af5e731729592af4a5716edd3b1e03264d66ea46 |
| tree | e0d804ee5280c48654e9789c2bade7eca6c1fbc5 |
| parent | b976e89c16b4cfd97986f0dd642f987c9ca6ec64 |
| parent | 5776d8f27022926b0538e818c7408f760bf2d144 |
| signature |
lldb: add more stage2 pretty printers15 files changed, 725 insertions(+), 287 deletions(-)
lib/std/dwarf/AT.zig-1| ... | ... | @@ -225,7 +225,6 @@ pub const ZIG_padding = 0x2cce; |
| 225 | 225 | pub const ZIG_relative_decl = 0x2cd0; |
| 226 | 226 | pub const ZIG_decl_line_relative = 0x2cd1; |
| 227 | 227 | pub const ZIG_comptime_value = 0x2cd2; |
| 228 | pub const ZIG_comptime_default_value = 0x2cd3; | |
| 229 | 228 | pub const ZIG_sentinel = 0x2ce2; |
| 230 | 229 | |
| 231 | 230 | // UPC extension. |
src/Compilation.zig+16-8| ... | ... | @@ -2181,7 +2181,8 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | if (comp.zcu) |zcu| { |
| 2184 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; | |
| 2184 | const pt: Zcu.PerThread = .activate(zcu, .main); | |
| 2185 | defer pt.deactivate(); | |
| 2185 | 2186 | |
| 2186 | 2187 | zcu.compile_log_text.shrinkAndFree(gpa, 0); |
| 2187 | 2188 | |
| ... | ... | @@ -2251,7 +2252,8 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2251 | 2252 | try comp.performAllTheWork(main_progress_node); |
| 2252 | 2253 | |
| 2253 | 2254 | if (comp.zcu) |zcu| { |
| 2254 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; | |
| 2255 | const pt: Zcu.PerThread = .activate(zcu, .main); | |
| 2256 | defer pt.deactivate(); | |
| 2255 | 2257 | |
| 2256 | 2258 | if (build_options.enable_debug_extensions and comp.verbose_intern_pool) { |
| 2257 | 2259 | std.debug.print("intern pool stats for '{s}':\n", .{ |
| ... | ... | @@ -3609,7 +3611,8 @@ fn performAllTheWorkInner( |
| 3609 | 3611 | } |
| 3610 | 3612 | |
| 3611 | 3613 | if (comp.zcu) |zcu| { |
| 3612 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = .main }; | |
| 3614 | const pt: Zcu.PerThread = .activate(zcu, .main); | |
| 3615 | defer pt.deactivate(); | |
| 3613 | 3616 | if (comp.incremental) { |
| 3614 | 3617 | const update_zir_refs_node = main_progress_node.start("Update ZIR References", 0); |
| 3615 | 3618 | defer update_zir_refs_node.end(); |
| ... | ... | @@ -3683,14 +3686,16 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3683 | 3686 | const named_frame = tracy.namedFrame("analyze_func"); |
| 3684 | 3687 | defer named_frame.end(); |
| 3685 | 3688 | |
| 3686 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3689 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 3690 | defer pt.deactivate(); | |
| 3687 | 3691 | pt.ensureFuncBodyAnalyzed(func) catch |err| switch (err) { |
| 3688 | 3692 | error.OutOfMemory => return error.OutOfMemory, |
| 3689 | 3693 | error.AnalysisFail => return, |
| 3690 | 3694 | }; |
| 3691 | 3695 | }, |
| 3692 | 3696 | .analyze_cau => |cau_index| { |
| 3693 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3697 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 3698 | defer pt.deactivate(); | |
| 3694 | 3699 | pt.ensureCauAnalyzed(cau_index) catch |err| switch (err) { |
| 3695 | 3700 | error.OutOfMemory => return error.OutOfMemory, |
| 3696 | 3701 | error.AnalysisFail => return, |
| ... | ... | @@ -3719,7 +3724,8 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3719 | 3724 | const named_frame = tracy.namedFrame("resolve_type_fully"); |
| 3720 | 3725 | defer named_frame.end(); |
| 3721 | 3726 | |
| 3722 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3727 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 3728 | defer pt.deactivate(); | |
| 3723 | 3729 | Type.fromInterned(ty).resolveFully(pt) catch |err| switch (err) { |
| 3724 | 3730 | error.OutOfMemory => return error.OutOfMemory, |
| 3725 | 3731 | error.AnalysisFail => return, |
| ... | ... | @@ -3729,7 +3735,8 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre |
| 3729 | 3735 | const named_frame = tracy.namedFrame("analyze_mod"); |
| 3730 | 3736 | defer named_frame.end(); |
| 3731 | 3737 | |
| 3732 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 3738 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 3739 | defer pt.deactivate(); | |
| 3733 | 3740 | pt.semaPkg(mod) catch |err| switch (err) { |
| 3734 | 3741 | error.OutOfMemory => return error.OutOfMemory, |
| 3735 | 3742 | error.AnalysisFail => return, |
| ... | ... | @@ -4183,7 +4190,8 @@ fn workerAstGenFile( |
| 4183 | 4190 | const child_prog_node = prog_node.start(file.sub_file_path, 0); |
| 4184 | 4191 | defer child_prog_node.end(); |
| 4185 | 4192 | |
| 4186 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 4193 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 4194 | defer pt.deactivate(); | |
| 4187 | 4195 | pt.astGenFile(file, path_digest) catch |err| switch (err) { |
| 4188 | 4196 | error.AnalysisFail => return, |
| 4189 | 4197 | else => { |
src/InternPool.zig+357-119| ... | ... | @@ -470,6 +470,8 @@ pub const Cau = struct { |
| 470 | 470 | _ => @enumFromInt(@intFromEnum(opt)), |
| 471 | 471 | }; |
| 472 | 472 | } |
| 473 | ||
| 474 | const debug_state = InternPool.debug_state; | |
| 473 | 475 | }; |
| 474 | 476 | pub fn toOptional(i: Cau.Index) Optional { |
| 475 | 477 | return @enumFromInt(@intFromEnum(i)); |
| ... | ... | @@ -491,6 +493,8 @@ pub const Cau = struct { |
| 491 | 493 | .index = @intFromEnum(cau_index) & ip.getIndexMask(u31), |
| 492 | 494 | }; |
| 493 | 495 | } |
| 496 | ||
| 497 | const debug_state = InternPool.debug_state; | |
| 494 | 498 | }; |
| 495 | 499 | }; |
| 496 | 500 | |
| ... | ... | @@ -568,6 +572,8 @@ pub const Nav = struct { |
| 568 | 572 | _ => @enumFromInt(@intFromEnum(opt)), |
| 569 | 573 | }; |
| 570 | 574 | } |
| 575 | ||
| 576 | const debug_state = InternPool.debug_state; | |
| 571 | 577 | }; |
| 572 | 578 | pub fn toOptional(i: Nav.Index) Optional { |
| 573 | 579 | return @enumFromInt(@intFromEnum(i)); |
| ... | ... | @@ -589,6 +595,8 @@ pub const Nav = struct { |
| 589 | 595 | .index = @intFromEnum(nav_index) & ip.getIndexMask(u32), |
| 590 | 596 | }; |
| 591 | 597 | } |
| 598 | ||
| 599 | const debug_state = InternPool.debug_state; | |
| 592 | 600 | }; |
| 593 | 601 | |
| 594 | 602 | /// The compact in-memory representation of a `Nav`. |
| ... | ... | @@ -1580,6 +1588,8 @@ pub const String = enum(u32) { |
| 1580 | 1588 | const strings = ip.getLocalShared(unwrapped_string.tid).strings.acquire(); |
| 1581 | 1589 | return strings.view().items(.@"0")[unwrapped_string.index..]; |
| 1582 | 1590 | } |
| 1591 | ||
| 1592 | const debug_state = InternPool.debug_state; | |
| 1583 | 1593 | }; |
| 1584 | 1594 | |
| 1585 | 1595 | /// An index into `strings` which might be `none`. |
| ... | ... | @@ -1596,6 +1606,8 @@ pub const OptionalString = enum(u32) { |
| 1596 | 1606 | pub fn toSlice(string: OptionalString, len: u64, ip: *const InternPool) ?[]const u8 { |
| 1597 | 1607 | return (string.unwrap() orelse return null).toSlice(len, ip); |
| 1598 | 1608 | } |
| 1609 | ||
| 1610 | const debug_state = InternPool.debug_state; | |
| 1599 | 1611 | }; |
| 1600 | 1612 | |
| 1601 | 1613 | /// An index into `strings`. |
| ... | ... | @@ -1692,6 +1704,8 @@ pub const NullTerminatedString = enum(u32) { |
| 1692 | 1704 | pub fn fmt(string: NullTerminatedString, ip: *const InternPool) std.fmt.Formatter(format) { |
| 1693 | 1705 | return .{ .data = .{ .string = string, .ip = ip } }; |
| 1694 | 1706 | } |
| 1707 | ||
| 1708 | const debug_state = InternPool.debug_state; | |
| 1695 | 1709 | }; |
| 1696 | 1710 | |
| 1697 | 1711 | /// An index into `strings` which might be `none`. |
| ... | ... | @@ -1708,6 +1722,8 @@ pub const OptionalNullTerminatedString = enum(u32) { |
| 1708 | 1722 | pub fn toSlice(string: OptionalNullTerminatedString, ip: *const InternPool) ?[:0]const u8 { |
| 1709 | 1723 | return (string.unwrap() orelse return null).toSlice(ip); |
| 1710 | 1724 | } |
| 1725 | ||
| 1726 | const debug_state = InternPool.debug_state; | |
| 1711 | 1727 | }; |
| 1712 | 1728 | |
| 1713 | 1729 | /// A single value captured in the closure of a namespace type. This is not a plain |
| ... | ... | @@ -4519,6 +4535,8 @@ pub const Index = enum(u32) { |
| 4519 | 4535 | .data_ptr = &slice.items(.data)[unwrapped.index], |
| 4520 | 4536 | }; |
| 4521 | 4537 | } |
| 4538 | ||
| 4539 | const debug_state = InternPool.debug_state; | |
| 4522 | 4540 | }; |
| 4523 | 4541 | pub fn unwrap(index: Index, ip: *const InternPool) Unwrapped { |
| 4524 | 4542 | return if (single_threaded) .{ |
| ... | ... | @@ -4532,7 +4550,6 @@ pub const Index = enum(u32) { |
| 4532 | 4550 | |
| 4533 | 4551 | /// This function is used in the debugger pretty formatters in tools/ to fetch the |
| 4534 | 4552 | /// Tag to encoding mapping to facilitate fancy debug printing for this type. |
| 4535 | /// TODO merge this with `Tag.Payload`. | |
| 4536 | 4553 | fn dbHelper(self: *Index, tag_to_encoding_map: *struct { |
| 4537 | 4554 | const DataIsIndex = struct { data: Index }; |
| 4538 | 4555 | const DataIsExtraIndexOfEnumExplicit = struct { |
| ... | ... | @@ -4689,44 +4706,38 @@ pub const Index = enum(u32) { |
| 4689 | 4706 | } |
| 4690 | 4707 | } |
| 4691 | 4708 | } |
| 4692 | ||
| 4693 | 4709 | comptime { |
| 4694 | 4710 | if (!builtin.strip_debug_info) switch (builtin.zig_backend) { |
| 4695 | 4711 | .stage2_llvm => _ = &dbHelper, |
| 4696 | .stage2_x86_64 => { | |
| 4697 | for (@typeInfo(Tag).@"enum".fields) |tag| { | |
| 4698 | if (!@hasField(@TypeOf(Tag.encodings), tag.name)) { | |
| 4699 | if (false) @compileLog("missing: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name); | |
| 4700 | continue; | |
| 4701 | } | |
| 4702 | const encoding = @field(Tag.encodings, tag.name); | |
| 4703 | for (@typeInfo(encoding.trailing).@"struct".fields) |field| { | |
| 4704 | struct { | |
| 4705 | fn checkConfig(name: []const u8) void { | |
| 4706 | if (!@hasField(@TypeOf(encoding.config), name)) @compileError("missing field: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name ++ ".config.@\"" ++ name ++ "\""); | |
| 4707 | const FieldType = @TypeOf(@field(encoding.config, name)); | |
| 4708 | if (@typeInfo(FieldType) != .enum_literal) @compileError("expected enum literal: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name ++ ".config.@\"" ++ name ++ "\": " ++ @typeName(FieldType)); | |
| 4709 | } | |
| 4710 | fn checkField(name: []const u8, Type: type) void { | |
| 4711 | switch (@typeInfo(Type)) { | |
| 4712 | .int => {}, | |
| 4713 | .@"enum" => {}, | |
| 4714 | .@"struct" => |info| assert(info.layout == .@"packed"), | |
| 4715 | .optional => |info| { | |
| 4716 | checkConfig(name ++ ".?"); | |
| 4717 | checkField(name ++ ".?", info.child); | |
| 4718 | }, | |
| 4719 | .pointer => |info| { | |
| 4720 | assert(info.size == .Slice); | |
| 4721 | checkConfig(name ++ ".len"); | |
| 4722 | checkField(name ++ "[0]", info.child); | |
| 4723 | }, | |
| 4724 | else => @compileError("unsupported type: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name ++ "." ++ name ++ ": " ++ @typeName(Type)), | |
| 4725 | } | |
| 4712 | .stage2_x86_64 => for (@typeInfo(Tag).@"enum".fields) |tag| { | |
| 4713 | if (!@hasField(@TypeOf(Tag.encodings), tag.name)) @compileLog("missing: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name); | |
| 4714 | const encoding = @field(Tag.encodings, tag.name); | |
| 4715 | if (@hasField(@TypeOf(encoding), "trailing")) for (@typeInfo(encoding.trailing).@"struct".fields) |field| { | |
| 4716 | struct { | |
| 4717 | fn checkConfig(name: []const u8) void { | |
| 4718 | if (!@hasField(@TypeOf(encoding.config), name)) @compileError("missing field: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name ++ ".config.@\"" ++ name ++ "\""); | |
| 4719 | const FieldType = @TypeOf(@field(encoding.config, name)); | |
| 4720 | if (@typeInfo(FieldType) != .enum_literal) @compileError("expected enum literal: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name ++ ".config.@\"" ++ name ++ "\": " ++ @typeName(FieldType)); | |
| 4721 | } | |
| 4722 | fn checkField(name: []const u8, Type: type) void { | |
| 4723 | switch (@typeInfo(Type)) { | |
| 4724 | .int => {}, | |
| 4725 | .@"enum" => {}, | |
| 4726 | .@"struct" => |info| assert(info.layout == .@"packed"), | |
| 4727 | .optional => |info| { | |
| 4728 | checkConfig(name ++ ".?"); | |
| 4729 | checkField(name ++ ".?", info.child); | |
| 4730 | }, | |
| 4731 | .pointer => |info| { | |
| 4732 | assert(info.size == .Slice); | |
| 4733 | checkConfig(name ++ ".len"); | |
| 4734 | checkField(name ++ "[0]", info.child); | |
| 4735 | }, | |
| 4736 | else => @compileError("unsupported type: " ++ @typeName(Tag) ++ ".encodings." ++ tag.name ++ "." ++ name ++ ": " ++ @typeName(Type)), | |
| 4726 | 4737 | } |
| 4727 | }.checkField("trailing." ++ field.name, field.type); | |
| 4728 | } | |
| 4729 | } | |
| 4738 | } | |
| 4739 | }.checkField("trailing." ++ field.name, field.type); | |
| 4740 | }; | |
| 4730 | 4741 | }, |
| 4731 | 4742 | else => {}, |
| 4732 | 4743 | }; |
| ... | ... | @@ -5035,7 +5046,6 @@ pub const Tag = enum(u8) { |
| 5035 | 5046 | /// data is payload index to `EnumExplicit`. |
| 5036 | 5047 | type_enum_nonexhaustive, |
| 5037 | 5048 | /// A type that can be represented with only an enum tag. |
| 5038 | /// data is SimpleType enum value. | |
| 5039 | 5049 | simple_type, |
| 5040 | 5050 | /// An opaque type. |
| 5041 | 5051 | /// data is index of Tag.TypeOpaque in extra. |
| ... | ... | @@ -5064,7 +5074,6 @@ pub const Tag = enum(u8) { |
| 5064 | 5074 | /// Untyped `undefined` is stored instead via `simple_value`. |
| 5065 | 5075 | undef, |
| 5066 | 5076 | /// A value that can be represented with only an enum tag. |
| 5067 | /// data is SimpleValue enum value. | |
| 5068 | 5077 | simple_value, |
| 5069 | 5078 | /// A pointer to a `Nav`. |
| 5070 | 5079 | /// data is extra index of `PtrNav`, which contains the type and address. |
| ... | ... | @@ -5244,95 +5253,90 @@ pub const Tag = enum(u8) { |
| 5244 | 5253 | const Union = Key.Union; |
| 5245 | 5254 | const TypePointer = Key.PtrType; |
| 5246 | 5255 | |
| 5247 | fn Payload(comptime tag: Tag) type { | |
| 5248 | return switch (tag) { | |
| 5249 | .removed => unreachable, | |
| 5250 | .type_int_signed => unreachable, | |
| 5251 | .type_int_unsigned => unreachable, | |
| 5252 | .type_array_big => Array, | |
| 5253 | .type_array_small => Vector, | |
| 5254 | .type_vector => Vector, | |
| 5255 | .type_pointer => TypePointer, | |
| 5256 | .type_slice => unreachable, | |
| 5257 | .type_optional => unreachable, | |
| 5258 | .type_anyframe => unreachable, | |
| 5259 | .type_error_union => ErrorUnionType, | |
| 5260 | .type_anyerror_union => unreachable, | |
| 5261 | .type_error_set => ErrorSet, | |
| 5262 | .type_inferred_error_set => unreachable, | |
| 5263 | .type_enum_auto => EnumAuto, | |
| 5264 | .type_enum_explicit => EnumExplicit, | |
| 5265 | .type_enum_nonexhaustive => EnumExplicit, | |
| 5266 | .simple_type => unreachable, | |
| 5267 | .type_opaque => TypeOpaque, | |
| 5268 | .type_struct => TypeStruct, | |
| 5269 | .type_struct_packed, .type_struct_packed_inits => TypeStructPacked, | |
| 5270 | .type_tuple => TypeTuple, | |
| 5271 | .type_union => TypeUnion, | |
| 5272 | .type_function => TypeFunction, | |
| 5273 | ||
| 5274 | .undef => unreachable, | |
| 5275 | .simple_value => unreachable, | |
| 5276 | .ptr_nav => PtrNav, | |
| 5277 | .ptr_comptime_alloc => PtrComptimeAlloc, | |
| 5278 | .ptr_uav => PtrUav, | |
| 5279 | .ptr_uav_aligned => PtrUavAligned, | |
| 5280 | .ptr_comptime_field => PtrComptimeField, | |
| 5281 | .ptr_int => PtrInt, | |
| 5282 | .ptr_eu_payload => PtrBase, | |
| 5283 | .ptr_opt_payload => PtrBase, | |
| 5284 | .ptr_elem => PtrBaseIndex, | |
| 5285 | .ptr_field => PtrBaseIndex, | |
| 5286 | .ptr_slice => PtrSlice, | |
| 5287 | .opt_payload => TypeValue, | |
| 5288 | .opt_null => unreachable, | |
| 5289 | .int_u8 => unreachable, | |
| 5290 | .int_u16 => unreachable, | |
| 5291 | .int_u32 => unreachable, | |
| 5292 | .int_i32 => unreachable, | |
| 5293 | .int_usize => unreachable, | |
| 5294 | .int_comptime_int_u32 => unreachable, | |
| 5295 | .int_comptime_int_i32 => unreachable, | |
| 5296 | .int_small => IntSmall, | |
| 5297 | .int_positive => unreachable, | |
| 5298 | .int_negative => unreachable, | |
| 5299 | .int_lazy_align => IntLazy, | |
| 5300 | .int_lazy_size => IntLazy, | |
| 5301 | .error_set_error => Error, | |
| 5302 | .error_union_error => Error, | |
| 5303 | .error_union_payload => TypeValue, | |
| 5304 | .enum_literal => unreachable, | |
| 5305 | .enum_tag => EnumTag, | |
| 5306 | .float_f16 => unreachable, | |
| 5307 | .float_f32 => unreachable, | |
| 5308 | .float_f64 => unreachable, | |
| 5309 | .float_f80 => unreachable, | |
| 5310 | .float_f128 => unreachable, | |
| 5311 | .float_c_longdouble_f80 => unreachable, | |
| 5312 | .float_c_longdouble_f128 => unreachable, | |
| 5313 | .float_comptime_float => unreachable, | |
| 5314 | .variable => Variable, | |
| 5315 | .@"extern" => Extern, | |
| 5316 | .func_decl => FuncDecl, | |
| 5317 | .func_instance => FuncInstance, | |
| 5318 | .func_coerced => FuncCoerced, | |
| 5319 | .only_possible_value => unreachable, | |
| 5320 | .union_value => Union, | |
| 5321 | .bytes => Bytes, | |
| 5322 | .aggregate => Aggregate, | |
| 5323 | .repeated => Repeated, | |
| 5324 | .memoized_call => MemoizedCall, | |
| 5325 | }; | |
| 5326 | } | |
| 5327 | ||
| 5256 | const enum_explicit_encoding = .{ | |
| 5257 | .summary = .@"{.payload.name%summary#\"}", | |
| 5258 | .payload = EnumExplicit, | |
| 5259 | .trailing = struct { | |
| 5260 | owner_union: Index, | |
| 5261 | cau: ?Cau.Index, | |
| 5262 | captures: ?[]CaptureValue, | |
| 5263 | type_hash: ?u64, | |
| 5264 | field_names: []NullTerminatedString, | |
| 5265 | tag_values: []Index, | |
| 5266 | }, | |
| 5267 | .config = .{ | |
| 5268 | .@"trailing.owner_union.?" = .@"payload.zir_index == .none", | |
| 5269 | .@"trailing.cau.?" = .@"payload.zir_index != .none", | |
| 5270 | .@"trailing.captures.?" = .@"payload.captures_len < 0xffffffff", | |
| 5271 | .@"trailing.captures.?.len" = .@"payload.captures_len", | |
| 5272 | .@"trailing.type_hash.?" = .@"payload.captures_len == 0xffffffff", | |
| 5273 | .@"trailing.field_names.len" = .@"payload.fields_len", | |
| 5274 | .@"trailing.tag_values.len" = .@"payload.fields_len", | |
| 5275 | }, | |
| 5276 | }; | |
| 5328 | 5277 | const encodings = .{ |
| 5278 | .removed = .{}, | |
| 5279 | ||
| 5280 | .type_int_signed = .{ .summary = .@"i{.data%value}", .data = u32 }, | |
| 5281 | .type_int_unsigned = .{ .summary = .@"u{.data%value}", .data = u32 }, | |
| 5282 | .type_array_big = .{ | |
| 5283 | .summary = .@"[{.payload.len1%value} << 32 | {.payload.len0%value}:{.payload.sentinel%summary}]{.payload.child%summary}", | |
| 5284 | .payload = Array, | |
| 5285 | }, | |
| 5286 | .type_array_small = .{ .summary = .@"[{.payload.len%value}]{.payload.child%summary}", .payload = Vector }, | |
| 5287 | .type_vector = .{ .summary = .@"@Vector({.payload.len%value}, {.payload.child%summary})", .payload = Vector }, | |
| 5288 | .type_pointer = .{ .summary = .@"*... {.payload.child%summary}", .payload = TypePointer }, | |
| 5289 | .type_slice = .{ .summary = .@"[]... {.data.unwrapped.payload.child%summary}", .data = Index }, | |
| 5290 | .type_optional = .{ .summary = .@"?{.data%summary}", .data = Index }, | |
| 5291 | .type_anyframe = .{ .summary = .@"anyframe->{.data%summary}", .data = Index }, | |
| 5292 | .type_error_union = .{ | |
| 5293 | .summary = .@"{.payload.error_set_type%summary}!{.payload.payload_type%summary}", | |
| 5294 | .payload = ErrorUnionType, | |
| 5295 | }, | |
| 5296 | .type_anyerror_union = .{ .summary = .@"anyerror!{.data%summary}", .data = Index }, | |
| 5297 | .type_error_set = .{ .summary = .@"error{...}", .payload = ErrorSet }, | |
| 5298 | .type_inferred_error_set = .{ | |
| 5299 | .summary = .@"@typeInfo(@typeInfo(@TypeOf({.data%summary})).@\"fn\".return_type.?).error_union.error_set", | |
| 5300 | .data = Index, | |
| 5301 | }, | |
| 5302 | .type_enum_auto = .{ | |
| 5303 | .summary = .@"{.payload.name%summary#\"}", | |
| 5304 | .payload = EnumAuto, | |
| 5305 | .trailing = struct { | |
| 5306 | owner_union: ?Index, | |
| 5307 | cau: ?Cau.Index, | |
| 5308 | captures: ?[]CaptureValue, | |
| 5309 | type_hash: ?u64, | |
| 5310 | field_names: []NullTerminatedString, | |
| 5311 | }, | |
| 5312 | .config = .{ | |
| 5313 | .@"trailing.owner_union.?" = .@"payload.zir_index == .none", | |
| 5314 | .@"trailing.cau.?" = .@"payload.zir_index != .none", | |
| 5315 | .@"trailing.captures.?" = .@"payload.captures_len < 0xffffffff", | |
| 5316 | .@"trailing.captures.?.len" = .@"payload.captures_len", | |
| 5317 | .@"trailing.type_hash.?" = .@"payload.captures_len == 0xffffffff", | |
| 5318 | .@"trailing.field_names.len" = .@"payload.fields_len", | |
| 5319 | }, | |
| 5320 | }, | |
| 5321 | .type_enum_explicit = enum_explicit_encoding, | |
| 5322 | .type_enum_nonexhaustive = enum_explicit_encoding, | |
| 5323 | .simple_type = .{ .summary = .@"{.index%value#.}", .index = SimpleType }, | |
| 5324 | .type_opaque = .{ | |
| 5325 | .summary = .@"{.payload.name%summary#\"}", | |
| 5326 | .payload = TypeOpaque, | |
| 5327 | .trailing = struct { captures: []CaptureValue }, | |
| 5328 | .config = .{ .@"trailing.captures.len" = .@"payload.captures_len" }, | |
| 5329 | }, | |
| 5329 | 5330 | .type_struct = .{ |
| 5331 | .summary = .@"{.payload.name%summary#\"}", | |
| 5330 | 5332 | .payload = TypeStruct, |
| 5331 | 5333 | .trailing = struct { |
| 5332 | 5334 | captures_len: ?u32, |
| 5333 | 5335 | captures: ?[]CaptureValue, |
| 5334 | 5336 | type_hash: ?u64, |
| 5335 | 5337 | field_types: []Index, |
| 5338 | field_names_map: OptionalMapIndex, | |
| 5339 | field_names: []NullTerminatedString, | |
| 5336 | 5340 | field_inits: ?[]Index, |
| 5337 | 5341 | field_aligns: ?[]Alignment, |
| 5338 | 5342 | field_is_comptime_bits: ?[]u32, |
| ... | ... | @@ -5342,9 +5346,10 @@ pub const Tag = enum(u8) { |
| 5342 | 5346 | .config = .{ |
| 5343 | 5347 | .@"trailing.captures_len.?" = .@"payload.flags.any_captures", |
| 5344 | 5348 | .@"trailing.captures.?" = .@"payload.flags.any_captures", |
| 5345 | .@"trailing.captures.?.len" = .@"trailing.captures_len", | |
| 5349 | .@"trailing.captures.?.len" = .@"trailing.captures_len.?", | |
| 5346 | 5350 | .@"trailing.type_hash.?" = .@"payload.flags.is_reified", |
| 5347 | 5351 | .@"trailing.field_types.len" = .@"payload.fields_len", |
| 5352 | .@"trailing.field_names.len" = .@"payload.fields_len", | |
| 5348 | 5353 | .@"trailing.field_inits.?" = .@"payload.flags.any_default_inits", |
| 5349 | 5354 | .@"trailing.field_inits.?.len" = .@"payload.fields_len", |
| 5350 | 5355 | .@"trailing.field_aligns.?" = .@"payload.flags.any_aligned_fields", |
| ... | ... | @@ -5356,7 +5361,212 @@ pub const Tag = enum(u8) { |
| 5356 | 5361 | .@"trailing.field_offset.len" = .@"payload.fields_len", |
| 5357 | 5362 | }, |
| 5358 | 5363 | }, |
| 5364 | .type_struct_packed = .{ | |
| 5365 | .summary = .@"{.payload.name%summary#\"}", | |
| 5366 | .payload = TypeStructPacked, | |
| 5367 | .trailing = struct { | |
| 5368 | captures_len: ?u32, | |
| 5369 | captures: ?[]CaptureValue, | |
| 5370 | type_hash: ?u64, | |
| 5371 | field_types: []Index, | |
| 5372 | field_names: []NullTerminatedString, | |
| 5373 | }, | |
| 5374 | .config = .{ | |
| 5375 | .@"trailing.captures_len.?" = .@"payload.flags.any_captures", | |
| 5376 | .@"trailing.captures.?" = .@"payload.flags.any_captures", | |
| 5377 | .@"trailing.captures.?.len" = .@"trailing.captures_len.?", | |
| 5378 | .@"trailing.type_hash.?" = .@"payload.is_flags.is_reified", | |
| 5379 | .@"trailing.field_types.len" = .@"payload.fields_len", | |
| 5380 | .@"trailing.field_names.len" = .@"payload.fields_len", | |
| 5381 | }, | |
| 5382 | }, | |
| 5383 | .type_struct_packed_inits = .{ | |
| 5384 | .summary = .@"{.payload.name%summary#\"}", | |
| 5385 | .payload = TypeStructPacked, | |
| 5386 | .trailing = struct { | |
| 5387 | captures_len: ?u32, | |
| 5388 | captures: ?[]CaptureValue, | |
| 5389 | type_hash: ?u64, | |
| 5390 | field_types: []Index, | |
| 5391 | field_names: []NullTerminatedString, | |
| 5392 | field_inits: []Index, | |
| 5393 | }, | |
| 5394 | .config = .{ | |
| 5395 | .@"trailing.captures_len.?" = .@"payload.flags.any_captures", | |
| 5396 | .@"trailing.captures.?" = .@"payload.flags.any_captures", | |
| 5397 | .@"trailing.captures.?.len" = .@"trailing.captures_len.?", | |
| 5398 | .@"trailing.type_hash.?" = .@"payload.is_flags.is_reified", | |
| 5399 | .@"trailing.field_types.len" = .@"payload.fields_len", | |
| 5400 | .@"trailing.field_names.len" = .@"payload.fields_len", | |
| 5401 | .@"trailing.field_inits.len" = .@"payload.fields_len", | |
| 5402 | }, | |
| 5403 | }, | |
| 5404 | .type_tuple = .{ | |
| 5405 | .summary = .@"struct {...}", | |
| 5406 | .payload = TypeTuple, | |
| 5407 | .trailing = struct { | |
| 5408 | field_types: []Index, | |
| 5409 | field_values: []Index, | |
| 5410 | }, | |
| 5411 | .config = .{ | |
| 5412 | .@"trailing.field_types.len" = .@"payload.fields_len", | |
| 5413 | .@"trailing.field_values.len" = .@"payload.fields_len", | |
| 5414 | }, | |
| 5415 | }, | |
| 5416 | .type_union = .{ | |
| 5417 | .summary = .@"{.payload.name%summary#\"#\"}", | |
| 5418 | .payload = TypeUnion, | |
| 5419 | .trailing = struct { | |
| 5420 | captures_len: ?u32, | |
| 5421 | captures: ?[]CaptureValue, | |
| 5422 | type_hash: ?u64, | |
| 5423 | field_types: []Index, | |
| 5424 | field_aligns: []Alignment, | |
| 5425 | }, | |
| 5426 | .config = .{ | |
| 5427 | .@"trailing.captures_len.?" = .@"payload.flags.any_captures", | |
| 5428 | .@"trailing.captures.?" = .@"payload.flags.any_captures", | |
| 5429 | .@"trailing.captures.?.len" = .@"trailing.captures_len.?", | |
| 5430 | .@"trailing.type_hash.?" = .@"payload.is_flags.is_reified", | |
| 5431 | .@"trailing.field_types.len" = .@"payload.fields_len", | |
| 5432 | .@"trailing.field_aligns.len" = .@"payload.fields_len", | |
| 5433 | }, | |
| 5434 | }, | |
| 5435 | .type_function = .{ | |
| 5436 | .summary = .@"fn (...) ... {.payload.return_type%summary}", | |
| 5437 | .payload = TypeFunction, | |
| 5438 | .trailing = struct { | |
| 5439 | param_comptime_bits: ?[]u32, | |
| 5440 | param_noalias_bits: ?[]u32, | |
| 5441 | param_type: []Index, | |
| 5442 | }, | |
| 5443 | .config = .{ | |
| 5444 | .@"trailing.param_comptime_bits.?" = .@"payload.flags.has_comptime_bits", | |
| 5445 | .@"trailing.param_comptime_bits.?.len" = .@"(payload.params_len + 31) / 32", | |
| 5446 | .@"trailing.param_noalias_bits.?" = .@"payload.flags.has_noalias_bits", | |
| 5447 | .@"trailing.param_noalias_bits.?.len" = .@"(payload.params_len + 31) / 32", | |
| 5448 | .@"trailing.param_type.len" = .@"payload.params_len", | |
| 5449 | }, | |
| 5450 | }, | |
| 5451 | ||
| 5452 | .undef = .{ .summary = .@"@as({.data%summary}, undefined)", .data = Index }, | |
| 5453 | .simple_value = .{ .summary = .@"{.index%value#.}", .index = SimpleValue }, | |
| 5454 | .ptr_nav = .{ | |
| 5455 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&{.payload.nav.fqn%summary#\"}) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5456 | .payload = PtrNav, | |
| 5457 | }, | |
| 5458 | .ptr_comptime_alloc = .{ | |
| 5459 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&comptime_allocs[{.payload.index%summary}]) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5460 | .payload = PtrComptimeAlloc, | |
| 5461 | }, | |
| 5462 | .ptr_uav = .{ | |
| 5463 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&{.payload.val%summary}) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5464 | .payload = PtrUav, | |
| 5465 | }, | |
| 5466 | .ptr_uav_aligned = .{ | |
| 5467 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(@as({.payload.orig_ty%summary}, &{.payload.val%summary})) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5468 | .payload = PtrUavAligned, | |
| 5469 | }, | |
| 5470 | .ptr_comptime_field = .{ | |
| 5471 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&{.payload.field_val%summary}) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5472 | .payload = PtrComptimeField, | |
| 5473 | }, | |
| 5474 | .ptr_int = .{ | |
| 5475 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value}))", | |
| 5476 | .payload = PtrInt, | |
| 5477 | }, | |
| 5478 | .ptr_eu_payload = .{ | |
| 5479 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&({.payload.base%summary} catch unreachable)) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5480 | .payload = PtrBase, | |
| 5481 | }, | |
| 5482 | .ptr_opt_payload = .{ | |
| 5483 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&{.payload.base%summary}.?) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5484 | .payload = PtrBase, | |
| 5485 | }, | |
| 5486 | .ptr_elem = .{ | |
| 5487 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&{.payload.base%summary}[{.payload.index%summary}]) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5488 | .payload = PtrBaseIndex, | |
| 5489 | }, | |
| 5490 | .ptr_field = .{ | |
| 5491 | .summary = .@"@as({.payload.ty%summary}, @ptrFromInt(@intFromPtr(&{.payload.base%summary}[{.payload.index%summary}]) + ({.payload.byte_offset_a%value} << 32 | {.payload.byte_offset_b%value})))", | |
| 5492 | .payload = PtrBaseIndex, | |
| 5493 | }, | |
| 5494 | .ptr_slice = .{ | |
| 5495 | .summary = .@"{.payload.ptr%summary}[0..{.payload.len%summary}]", | |
| 5496 | .payload = PtrSlice, | |
| 5497 | }, | |
| 5498 | .opt_payload = .{ .summary = .@"@as({.payload.ty%summary}, {.payload.val%summary})", .payload = TypeValue }, | |
| 5499 | .opt_null = .{ .summary = .@"@as({.data%summary}, null)", .data = Index }, | |
| 5500 | .int_u8 = .{ .summary = .@"@as(u8, {.data%value})", .data = u8 }, | |
| 5501 | .int_u16 = .{ .summary = .@"@as(u16, {.data%value})", .data = u16 }, | |
| 5502 | .int_u32 = .{ .summary = .@"@as(u32, {.data%value})", .data = u32 }, | |
| 5503 | .int_i32 = .{ .summary = .@"@as(i32, {.data%value})", .data = i32 }, | |
| 5504 | .int_usize = .{ .summary = .@"@as(usize, {.data%value})", .data = u32 }, | |
| 5505 | .int_comptime_int_u32 = .{ .summary = .@"{.data%value}", .data = u32 }, | |
| 5506 | .int_comptime_int_i32 = .{ .summary = .@"{.data%value}", .data = i32 }, | |
| 5507 | .int_small = .{ .summary = .@"@as({.payload.ty%summary}, {.payload.value%value})", .payload = IntSmall }, | |
| 5508 | .int_positive = .{}, | |
| 5509 | .int_negative = .{}, | |
| 5510 | .int_lazy_align = .{ .summary = .@"@as({.payload.ty%summary}, @alignOf({.payload.lazy_ty%summary}))", .payload = IntLazy }, | |
| 5511 | .int_lazy_size = .{ .summary = .@"@as({.payload.ty%summary}, @sizeOf({.payload.lazy_ty%summary}))", .payload = IntLazy }, | |
| 5512 | .error_set_error = .{ .summary = .@"@as({.payload.ty%summary}, error.@{.payload.name%summary})", .payload = Error }, | |
| 5513 | .error_union_error = .{ .summary = .@"@as({.payload.ty%summary}, error.@{.payload.name%summary})", .payload = Error }, | |
| 5514 | .error_union_payload = .{ .summary = .@"@as({.payload.ty%summary}, {.payload.val%summary})", .payload = TypeValue }, | |
| 5515 | .enum_literal = .{ .summary = .@".@{.data%summary}", .data = NullTerminatedString }, | |
| 5516 | .enum_tag = .{ .summary = .@"@as({.payload.ty%summary}, @enumFromInt({.payload.int%summary}))", .payload = EnumTag }, | |
| 5517 | .float_f16 = .{ .summary = .@"@as(f16, {.data%value})", .data = f16 }, | |
| 5518 | .float_f32 = .{ .summary = .@"@as(f32, {.data%value})", .data = f32 }, | |
| 5519 | .float_f64 = .{ .summary = .@"@as(f64, {.payload%value})", .payload = f64 }, | |
| 5520 | .float_f80 = .{ .summary = .@"@as(f80, {.payload%value})", .payload = f80 }, | |
| 5521 | .float_f128 = .{ .summary = .@"@as(f128, {.payload%value})", .payload = f128 }, | |
| 5522 | .float_c_longdouble_f80 = .{ .summary = .@"@as(c_longdouble, {.payload%value})", .payload = f80 }, | |
| 5523 | .float_c_longdouble_f128 = .{ .summary = .@"@as(c_longdouble, {.payload%value})", .payload = f128 }, | |
| 5524 | .float_comptime_float = .{ .summary = .@"{.payload%value}", .payload = f128 }, | |
| 5525 | .variable = .{ .summary = .@"{.payload.owner_nav.fqn%summary#\"}", .payload = Variable }, | |
| 5526 | .@"extern" = .{ .summary = .@"{.payload.owner_nav.fqn%summary#\"}", .payload = Extern }, | |
| 5527 | .func_decl = .{ | |
| 5528 | .summary = .@"{.payload.owner_nav.fqn%summary#\"}", | |
| 5529 | .payload = FuncDecl, | |
| 5530 | .trailing = struct { inferred_error_set: ?Index }, | |
| 5531 | .config = .{ .@"trailing.inferred_error_set.?" = .@"payload.analysis.inferred_error_set" }, | |
| 5532 | }, | |
| 5533 | .func_instance = .{ | |
| 5534 | .summary = .@"{.payload.owner_nav.fqn%summary#\"}", | |
| 5535 | .payload = FuncInstance, | |
| 5536 | .trailing = struct { | |
| 5537 | inferred_error_set: ?Index, | |
| 5538 | param_values: []Index, | |
| 5539 | }, | |
| 5540 | .config = .{ | |
| 5541 | .@"trailing.inferred_error_set.?" = .@"payload.analysis.inferred_error_set", | |
| 5542 | .@"trailing.param_values.len" = .@"payload.ty.payload.params_len", | |
| 5543 | }, | |
| 5544 | }, | |
| 5545 | .func_coerced = .{ | |
| 5546 | .summary = .@"@as(*const {.payload.ty%summary}, @ptrCast(&{.payload.func%summary})).*", | |
| 5547 | .payload = FuncCoerced, | |
| 5548 | }, | |
| 5549 | .only_possible_value = .{ .summary = .@"@as({.data%summary}, undefined)", .data = Index }, | |
| 5550 | .union_value = .{ .summary = .@"@as({.payload.ty%summary}, {})", .payload = Union }, | |
| 5551 | .bytes = .{ .summary = .@"@as({.payload.ty%summary}, {.payload.bytes%summary}.*)", .payload = Bytes }, | |
| 5552 | .aggregate = .{ | |
| 5553 | .summary = .@"@as({.payload.ty%summary}, .{...})", | |
| 5554 | .payload = Aggregate, | |
| 5555 | .trailing = struct { elements: []Index }, | |
| 5556 | .config = .{ .@"trailing.elements.len" = .@"payload.ty.payload.fields_len" }, | |
| 5557 | }, | |
| 5558 | .repeated = .{ .summary = .@"@as({.payload.ty%summary}, @splat({.payload.elem_val%summary}))", .payload = Repeated }, | |
| 5559 | ||
| 5560 | .memoized_call = .{ | |
| 5561 | .summary = .@"@memoize({.payload.func%summary})", | |
| 5562 | .payload = MemoizedCall, | |
| 5563 | .trailing = struct { arg_values: []Index }, | |
| 5564 | .config = .{ .@"trailing.arg_values.len" = .@"payload.args_len" }, | |
| 5565 | }, | |
| 5359 | 5566 | }; |
| 5567 | fn Payload(comptime tag: Tag) type { | |
| 5568 | return @field(encodings, @tagName(tag)).payload; | |
| 5569 | } | |
| 5360 | 5570 | |
| 5361 | 5571 | pub const Variable = struct { |
| 5362 | 5572 | ty: Index, |
| ... | ... | @@ -6271,6 +6481,8 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void { |
| 6271 | 6481 | } |
| 6272 | 6482 | |
| 6273 | 6483 | pub fn deinit(ip: *InternPool, gpa: Allocator) void { |
| 6484 | if (!builtin.strip_debug_info) std.debug.assert(debug_state.intern_pool == null); | |
| 6485 | ||
| 6274 | 6486 | ip.file_deps.deinit(gpa); |
| 6275 | 6487 | ip.src_hash_deps.deinit(gpa); |
| 6276 | 6488 | ip.nav_val_deps.deinit(gpa); |
| ... | ... | @@ -6311,6 +6523,32 @@ pub fn deinit(ip: *InternPool, gpa: Allocator) void { |
| 6311 | 6523 | ip.* = undefined; |
| 6312 | 6524 | } |
| 6313 | 6525 | |
| 6526 | pub fn activate(ip: *const InternPool) void { | |
| 6527 | if (builtin.strip_debug_info) return; | |
| 6528 | _ = Index.Unwrapped.debug_state; | |
| 6529 | _ = String.debug_state; | |
| 6530 | _ = OptionalString.debug_state; | |
| 6531 | _ = NullTerminatedString.debug_state; | |
| 6532 | _ = OptionalNullTerminatedString.debug_state; | |
| 6533 | _ = Cau.Index.debug_state; | |
| 6534 | _ = Cau.Index.Optional.debug_state; | |
| 6535 | _ = Nav.Index.debug_state; | |
| 6536 | _ = Nav.Index.Optional.debug_state; | |
| 6537 | std.debug.assert(debug_state.intern_pool == null); | |
| 6538 | debug_state.intern_pool = ip; | |
| 6539 | } | |
| 6540 | ||
| 6541 | pub fn deactivate(ip: *const InternPool) void { | |
| 6542 | if (builtin.strip_debug_info) return; | |
| 6543 | std.debug.assert(debug_state.intern_pool == ip); | |
| 6544 | debug_state.intern_pool = null; | |
| 6545 | } | |
| 6546 | ||
| 6547 | /// For debugger access only. | |
| 6548 | const debug_state = struct { | |
| 6549 | threadlocal var intern_pool: ?*const InternPool = null; | |
| 6550 | }; | |
| 6551 | ||
| 6314 | 6552 | pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 6315 | 6553 | assert(index != .none); |
| 6316 | 6554 | const unwrapped_index = index.unwrap(ip); |
src/Type.zig+1-1| ... | ... | @@ -891,7 +891,7 @@ pub const ResolveStratLazy = enum { |
| 891 | 891 | }; |
| 892 | 892 | |
| 893 | 893 | /// The chosen strategy can be easily optimized away in release builds. |
| 894 | /// However, in debug builds, it helps to avoid acceidentally resolving types in backends. | |
| 894 | /// However, in debug builds, it helps to avoid accidentally resolving types in backends. | |
| 895 | 895 | pub const ResolveStrat = enum { |
| 896 | 896 | /// Assert that all necessary resolution is completed. |
| 897 | 897 | /// Backends should typically use this, since they must not perform type resolution. |
src/Zcu.zig+67-65| ... | ... | @@ -2169,90 +2169,92 @@ pub fn init(zcu: *Zcu, thread_count: usize) !void { |
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | pub fn deinit(zcu: *Zcu) void { |
| 2172 | const pt: Zcu.PerThread = .{ .tid = .main, .zcu = zcu }; | |
| 2173 | 2172 | const gpa = zcu.gpa; |
| 2173 | { | |
| 2174 | const pt: Zcu.PerThread = .activate(zcu, .main); | |
| 2175 | defer pt.deactivate(); | |
| 2174 | 2176 | |
| 2175 | if (zcu.llvm_object) |llvm_object| llvm_object.deinit(); | |
| 2176 | ||
| 2177 | for (zcu.import_table.keys()) |key| { | |
| 2178 | gpa.free(key); | |
| 2179 | } | |
| 2180 | for (zcu.import_table.values()) |file_index| { | |
| 2181 | pt.destroyFile(file_index); | |
| 2182 | } | |
| 2183 | zcu.import_table.deinit(gpa); | |
| 2177 | if (zcu.llvm_object) |llvm_object| llvm_object.deinit(); | |
| 2184 | 2178 | |
| 2185 | for (zcu.embed_table.keys(), zcu.embed_table.values()) |path, embed_file| { | |
| 2186 | gpa.free(path); | |
| 2187 | gpa.destroy(embed_file); | |
| 2188 | } | |
| 2189 | zcu.embed_table.deinit(gpa); | |
| 2179 | for (zcu.import_table.keys()) |key| { | |
| 2180 | gpa.free(key); | |
| 2181 | } | |
| 2182 | for (zcu.import_table.values()) |file_index| { | |
| 2183 | pt.destroyFile(file_index); | |
| 2184 | } | |
| 2185 | zcu.import_table.deinit(gpa); | |
| 2190 | 2186 | |
| 2191 | zcu.compile_log_text.deinit(gpa); | |
| 2187 | for (zcu.embed_table.keys(), zcu.embed_table.values()) |path, embed_file| { | |
| 2188 | gpa.free(path); | |
| 2189 | gpa.destroy(embed_file); | |
| 2190 | } | |
| 2191 | zcu.embed_table.deinit(gpa); | |
| 2192 | 2192 | |
| 2193 | zcu.local_zir_cache.handle.close(); | |
| 2194 | zcu.global_zir_cache.handle.close(); | |
| 2193 | zcu.compile_log_text.deinit(gpa); | |
| 2195 | 2194 | |
| 2196 | for (zcu.failed_analysis.values()) |value| { | |
| 2197 | value.destroy(gpa); | |
| 2198 | } | |
| 2199 | for (zcu.failed_codegen.values()) |value| { | |
| 2200 | value.destroy(gpa); | |
| 2201 | } | |
| 2202 | zcu.analysis_in_progress.deinit(gpa); | |
| 2203 | zcu.failed_analysis.deinit(gpa); | |
| 2204 | zcu.transitive_failed_analysis.deinit(gpa); | |
| 2205 | zcu.failed_codegen.deinit(gpa); | |
| 2195 | zcu.local_zir_cache.handle.close(); | |
| 2196 | zcu.global_zir_cache.handle.close(); | |
| 2206 | 2197 | |
| 2207 | for (zcu.failed_files.values()) |value| { | |
| 2208 | if (value) |msg| msg.destroy(gpa); | |
| 2209 | } | |
| 2210 | zcu.failed_files.deinit(gpa); | |
| 2198 | for (zcu.failed_analysis.values()) |value| { | |
| 2199 | value.destroy(gpa); | |
| 2200 | } | |
| 2201 | for (zcu.failed_codegen.values()) |value| { | |
| 2202 | value.destroy(gpa); | |
| 2203 | } | |
| 2204 | zcu.analysis_in_progress.deinit(gpa); | |
| 2205 | zcu.failed_analysis.deinit(gpa); | |
| 2206 | zcu.transitive_failed_analysis.deinit(gpa); | |
| 2207 | zcu.failed_codegen.deinit(gpa); | |
| 2211 | 2208 | |
| 2212 | for (zcu.failed_embed_files.values()) |msg| { | |
| 2213 | msg.destroy(gpa); | |
| 2214 | } | |
| 2215 | zcu.failed_embed_files.deinit(gpa); | |
| 2209 | for (zcu.failed_files.values()) |value| { | |
| 2210 | if (value) |msg| msg.destroy(gpa); | |
| 2211 | } | |
| 2212 | zcu.failed_files.deinit(gpa); | |
| 2216 | 2213 | |
| 2217 | for (zcu.failed_exports.values()) |value| { | |
| 2218 | value.destroy(gpa); | |
| 2219 | } | |
| 2220 | zcu.failed_exports.deinit(gpa); | |
| 2214 | for (zcu.failed_embed_files.values()) |msg| { | |
| 2215 | msg.destroy(gpa); | |
| 2216 | } | |
| 2217 | zcu.failed_embed_files.deinit(gpa); | |
| 2221 | 2218 | |
| 2222 | for (zcu.cimport_errors.values()) |*errs| { | |
| 2223 | errs.deinit(gpa); | |
| 2224 | } | |
| 2225 | zcu.cimport_errors.deinit(gpa); | |
| 2219 | for (zcu.failed_exports.values()) |value| { | |
| 2220 | value.destroy(gpa); | |
| 2221 | } | |
| 2222 | zcu.failed_exports.deinit(gpa); | |
| 2226 | 2223 | |
| 2227 | zcu.compile_log_sources.deinit(gpa); | |
| 2224 | for (zcu.cimport_errors.values()) |*errs| { | |
| 2225 | errs.deinit(gpa); | |
| 2226 | } | |
| 2227 | zcu.cimport_errors.deinit(gpa); | |
| 2228 | 2228 | |
| 2229 | zcu.all_exports.deinit(gpa); | |
| 2230 | zcu.free_exports.deinit(gpa); | |
| 2231 | zcu.single_exports.deinit(gpa); | |
| 2232 | zcu.multi_exports.deinit(gpa); | |
| 2229 | zcu.compile_log_sources.deinit(gpa); | |
| 2233 | 2230 | |
| 2234 | zcu.potentially_outdated.deinit(gpa); | |
| 2235 | zcu.outdated.deinit(gpa); | |
| 2236 | zcu.outdated_ready.deinit(gpa); | |
| 2237 | zcu.retryable_failures.deinit(gpa); | |
| 2231 | zcu.all_exports.deinit(gpa); | |
| 2232 | zcu.free_exports.deinit(gpa); | |
| 2233 | zcu.single_exports.deinit(gpa); | |
| 2234 | zcu.multi_exports.deinit(gpa); | |
| 2238 | 2235 | |
| 2239 | zcu.test_functions.deinit(gpa); | |
| 2236 | zcu.potentially_outdated.deinit(gpa); | |
| 2237 | zcu.outdated.deinit(gpa); | |
| 2238 | zcu.outdated_ready.deinit(gpa); | |
| 2239 | zcu.retryable_failures.deinit(gpa); | |
| 2240 | 2240 | |
| 2241 | for (zcu.global_assembly.values()) |s| { | |
| 2242 | gpa.free(s); | |
| 2243 | } | |
| 2244 | zcu.global_assembly.deinit(gpa); | |
| 2241 | zcu.test_functions.deinit(gpa); | |
| 2245 | 2242 | |
| 2246 | zcu.reference_table.deinit(gpa); | |
| 2247 | zcu.all_references.deinit(gpa); | |
| 2248 | zcu.free_references.deinit(gpa); | |
| 2243 | for (zcu.global_assembly.values()) |s| { | |
| 2244 | gpa.free(s); | |
| 2245 | } | |
| 2246 | zcu.global_assembly.deinit(gpa); | |
| 2249 | 2247 | |
| 2250 | zcu.type_reference_table.deinit(gpa); | |
| 2251 | zcu.all_type_references.deinit(gpa); | |
| 2252 | zcu.free_type_references.deinit(gpa); | |
| 2248 | zcu.reference_table.deinit(gpa); | |
| 2249 | zcu.all_references.deinit(gpa); | |
| 2250 | zcu.free_references.deinit(gpa); | |
| 2253 | 2251 | |
| 2254 | if (zcu.resolved_references) |*r| r.deinit(gpa); | |
| 2252 | zcu.type_reference_table.deinit(gpa); | |
| 2253 | zcu.all_type_references.deinit(gpa); | |
| 2254 | zcu.free_type_references.deinit(gpa); | |
| 2255 | 2255 | |
| 2256 | if (zcu.resolved_references) |*r| r.deinit(gpa); | |
| 2257 | } | |
| 2256 | 2258 | zcu.intern_pool.deinit(gpa); |
| 2257 | 2259 | } |
| 2258 | 2260 |
src/Zcu/PerThread.zig+9| ... | ... | @@ -35,6 +35,15 @@ tid: Id, |
| 35 | 35 | pub const IdBacking = u7; |
| 36 | 36 | pub const Id = if (InternPool.single_threaded) enum { main } else enum(IdBacking) { main, _ }; |
| 37 | 37 | |
| 38 | pub fn activate(zcu: *Zcu, tid: Id) Zcu.PerThread { | |
| 39 | zcu.intern_pool.activate(); | |
| 40 | return .{ .zcu = zcu, .tid = tid }; | |
| 41 | } | |
| 42 | ||
| 43 | pub fn deactivate(pt: Zcu.PerThread) void { | |
| 44 | pt.zcu.intern_pool.deactivate(); | |
| 45 | } | |
| 46 | ||
| 38 | 47 | fn deinitFile(pt: Zcu.PerThread, file_index: Zcu.File.Index) void { |
| 39 | 48 | const zcu = pt.zcu; |
| 40 | 49 | const gpa = zcu.gpa; |
src/link.zig+6-3| ... | ... | @@ -1537,20 +1537,23 @@ pub fn doTask(comp: *Compilation, tid: usize, task: Task) void { |
| 1537 | 1537 | }; |
| 1538 | 1538 | }, |
| 1539 | 1539 | .codegen_nav => |nav_index| { |
| 1540 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 1540 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 1541 | defer pt.deactivate(); | |
| 1541 | 1542 | pt.linkerUpdateNav(nav_index) catch |err| switch (err) { |
| 1542 | 1543 | error.OutOfMemory => diags.setAllocFailure(), |
| 1543 | 1544 | }; |
| 1544 | 1545 | }, |
| 1545 | 1546 | .codegen_func => |func| { |
| 1546 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 1547 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 1548 | defer pt.deactivate(); | |
| 1547 | 1549 | // This call takes ownership of `func.air`. |
| 1548 | 1550 | pt.linkerUpdateFunc(func.func, func.air) catch |err| switch (err) { |
| 1549 | 1551 | error.OutOfMemory => diags.setAllocFailure(), |
| 1550 | 1552 | }; |
| 1551 | 1553 | }, |
| 1552 | 1554 | .codegen_type => |ty| { |
| 1553 | const pt: Zcu.PerThread = .{ .zcu = comp.zcu.?, .tid = @enumFromInt(tid) }; | |
| 1555 | const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid)); | |
| 1556 | defer pt.deactivate(); | |
| 1554 | 1557 | pt.linkerUpdateContainerType(ty) catch |err| switch (err) { |
| 1555 | 1558 | error.OutOfMemory => diags.setAllocFailure(), |
| 1556 | 1559 | }; |
src/link/C.zig+2-1| ... | ... | @@ -419,7 +419,8 @@ pub fn flushModule(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: |
| 419 | 419 | const gpa = comp.gpa; |
| 420 | 420 | const zcu = self.base.comp.zcu.?; |
| 421 | 421 | const ip = &zcu.intern_pool; |
| 422 | const pt: Zcu.PerThread = .{ .zcu = zcu, .tid = tid }; | |
| 422 | const pt: Zcu.PerThread = .activate(zcu, tid); | |
| 423 | defer pt.deactivate(); | |
| 423 | 424 | |
| 424 | 425 | { |
| 425 | 426 | var i: usize = 0; |
src/link/Coff.zig+5-4| ... | ... | @@ -2218,10 +2218,11 @@ pub fn flushModule(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 2218 | 2218 | const sub_prog_node = prog_node.start("COFF Flush", 0); |
| 2219 | 2219 | defer sub_prog_node.end(); |
| 2220 | 2220 | |
| 2221 | const pt: Zcu.PerThread = .{ | |
| 2222 | .zcu = comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 2223 | .tid = tid, | |
| 2224 | }; | |
| 2221 | const pt: Zcu.PerThread = .activate( | |
| 2222 | comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 2223 | tid, | |
| 2224 | ); | |
| 2225 | defer pt.deactivate(); | |
| 2225 | 2226 | |
| 2226 | 2227 | if (coff.lazy_syms.getPtr(.anyerror_type)) |metadata| { |
| 2227 | 2228 | // Most lazy symbols can be updated on first use, but |
src/link/Dwarf.zig+27-66| ... | ... | @@ -2687,23 +2687,19 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2687 | 2687 | }, |
| 2688 | 2688 | }; |
| 2689 | 2689 | try wip_nav.abbrevCode(if (is_comptime) |
| 2690 | if (has_runtime_bits and has_comptime_state) | |
| 2691 | .struct_field_comptime_runtime_bits_comptime_state | |
| 2692 | else if (has_comptime_state) | |
| 2690 | if (has_comptime_state) | |
| 2693 | 2691 | .struct_field_comptime_comptime_state |
| 2694 | 2692 | else if (has_runtime_bits) |
| 2695 | 2693 | .struct_field_comptime_runtime_bits |
| 2696 | 2694 | else |
| 2697 | 2695 | .struct_field_comptime |
| 2698 | 2696 | else if (field_init != .none) |
| 2699 | if (has_runtime_bits and has_comptime_state) | |
| 2700 | .struct_field_default_runtime_bits_comptime_state | |
| 2701 | else if (has_comptime_state) | |
| 2697 | if (has_comptime_state) | |
| 2702 | 2698 | .struct_field_default_comptime_state |
| 2703 | 2699 | else if (has_runtime_bits) |
| 2704 | 2700 | .struct_field_default_runtime_bits |
| 2705 | 2701 | else |
| 2706 | .struct_field_default | |
| 2702 | .struct_field | |
| 2707 | 2703 | else |
| 2708 | 2704 | .struct_field); |
| 2709 | 2705 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| ... | ... | @@ -2717,8 +2713,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2717 | 2713 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 2718 | 2714 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 2719 | 2715 | } |
| 2720 | if (has_runtime_bits) try wip_nav.blockValue(nav_src_loc, .fromInterned(field_init)); | |
| 2721 | if (has_comptime_state) try wip_nav.refValue(.fromInterned(field_init)); | |
| 2716 | if (has_comptime_state) | |
| 2717 | try wip_nav.refValue(.fromInterned(field_init)) | |
| 2718 | else if (has_runtime_bits) | |
| 2719 | try wip_nav.blockValue(nav_src_loc, .fromInterned(field_init)); | |
| 2722 | 2720 | } |
| 2723 | 2721 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 2724 | 2722 | } |
| ... | ... | @@ -3363,9 +3361,7 @@ fn updateLazyType( |
| 3363 | 3361 | field_type.comptimeOnly(zcu) and try field_type.onePossibleValue(pt) == null, |
| 3364 | 3362 | }, |
| 3365 | 3363 | }; |
| 3366 | try wip_nav.abbrevCode(if (has_runtime_bits and has_comptime_state) | |
| 3367 | .struct_field_comptime_runtime_bits_comptime_state | |
| 3368 | else if (has_comptime_state) | |
| 3364 | try wip_nav.abbrevCode(if (has_comptime_state) | |
| 3369 | 3365 | .struct_field_comptime_comptime_state |
| 3370 | 3366 | else if (has_runtime_bits) |
| 3371 | 3367 | .struct_field_comptime_runtime_bits |
| ... | ... | @@ -3386,8 +3382,10 @@ fn updateLazyType( |
| 3386 | 3382 | try uleb128(diw, field_type.abiAlignment(zcu).toByteUnits().?); |
| 3387 | 3383 | field_byte_offset += field_type.abiSize(zcu); |
| 3388 | 3384 | } |
| 3389 | if (has_runtime_bits) try wip_nav.blockValue(src_loc, .fromInterned(comptime_value)); | |
| 3390 | if (has_comptime_state) try wip_nav.refValue(.fromInterned(comptime_value)); | |
| 3385 | if (has_comptime_state) | |
| 3386 | try wip_nav.refValue(.fromInterned(comptime_value)) | |
| 3387 | else if (has_runtime_bits) | |
| 3388 | try wip_nav.blockValue(src_loc, .fromInterned(comptime_value)); | |
| 3391 | 3389 | } |
| 3392 | 3390 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3393 | 3391 | }, |
| ... | ... | @@ -3956,23 +3954,19 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3956 | 3954 | }, |
| 3957 | 3955 | }; |
| 3958 | 3956 | try wip_nav.abbrevCode(if (is_comptime) |
| 3959 | if (has_runtime_bits and has_comptime_state) | |
| 3960 | .struct_field_comptime_runtime_bits_comptime_state | |
| 3961 | else if (has_comptime_state) | |
| 3957 | if (has_comptime_state) | |
| 3962 | 3958 | .struct_field_comptime_comptime_state |
| 3963 | 3959 | else if (has_runtime_bits) |
| 3964 | 3960 | .struct_field_comptime_runtime_bits |
| 3965 | 3961 | else |
| 3966 | 3962 | .struct_field_comptime |
| 3967 | 3963 | else if (field_init != .none) |
| 3968 | if (has_runtime_bits and has_comptime_state) | |
| 3969 | .struct_field_default_runtime_bits_comptime_state | |
| 3970 | else if (has_comptime_state) | |
| 3964 | if (has_comptime_state) | |
| 3971 | 3965 | .struct_field_default_comptime_state |
| 3972 | 3966 | else if (has_runtime_bits) |
| 3973 | 3967 | .struct_field_default_runtime_bits |
| 3974 | 3968 | else |
| 3975 | .struct_field_default | |
| 3969 | .struct_field | |
| 3976 | 3970 | else |
| 3977 | 3971 | .struct_field); |
| 3978 | 3972 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| ... | ... | @@ -3986,8 +3980,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3986 | 3980 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3987 | 3981 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 3988 | 3982 | } |
| 3989 | if (has_runtime_bits) try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init)); | |
| 3990 | if (has_comptime_state) try wip_nav.refValue(.fromInterned(field_init)); | |
| 3983 | if (has_comptime_state) | |
| 3984 | try wip_nav.refValue(.fromInterned(field_init)) | |
| 3985 | else if (has_runtime_bits) | |
| 3986 | try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init)); | |
| 3991 | 3987 | } |
| 3992 | 3988 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3993 | 3989 | } |
| ... | ... | @@ -4064,23 +4060,19 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 4064 | 4060 | }, |
| 4065 | 4061 | }; |
| 4066 | 4062 | try wip_nav.abbrevCode(if (is_comptime) |
| 4067 | if (has_runtime_bits and has_comptime_state) | |
| 4068 | .struct_field_comptime_runtime_bits_comptime_state | |
| 4069 | else if (has_comptime_state) | |
| 4063 | if (has_comptime_state) | |
| 4070 | 4064 | .struct_field_comptime_comptime_state |
| 4071 | 4065 | else if (has_runtime_bits) |
| 4072 | 4066 | .struct_field_comptime_runtime_bits |
| 4073 | 4067 | else |
| 4074 | 4068 | .struct_field_comptime |
| 4075 | 4069 | else if (field_init != .none) |
| 4076 | if (has_runtime_bits and has_comptime_state) | |
| 4077 | .struct_field_default_runtime_bits_comptime_state | |
| 4078 | else if (has_comptime_state) | |
| 4070 | if (has_comptime_state) | |
| 4079 | 4071 | .struct_field_default_comptime_state |
| 4080 | 4072 | else if (has_runtime_bits) |
| 4081 | 4073 | .struct_field_default_runtime_bits |
| 4082 | 4074 | else |
| 4083 | .struct_field_default | |
| 4075 | .struct_field | |
| 4084 | 4076 | else |
| 4085 | 4077 | .struct_field); |
| 4086 | 4078 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| ... | ... | @@ -4094,8 +4086,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 4094 | 4086 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 4095 | 4087 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 4096 | 4088 | } |
| 4097 | if (has_runtime_bits) try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init)); | |
| 4098 | if (has_comptime_state) try wip_nav.refValue(.fromInterned(field_init)); | |
| 4089 | if (has_comptime_state) | |
| 4090 | try wip_nav.refValue(.fromInterned(field_init)) | |
| 4091 | else if (has_runtime_bits) | |
| 4092 | try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init)); | |
| 4099 | 4093 | } |
| 4100 | 4094 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 4101 | 4095 | } |
| ... | ... | @@ -4680,14 +4674,11 @@ const AbbrevCode = enum { |
| 4680 | 4674 | big_enum_field, |
| 4681 | 4675 | generated_field, |
| 4682 | 4676 | struct_field, |
| 4683 | struct_field_default, | |
| 4684 | 4677 | struct_field_default_runtime_bits, |
| 4685 | 4678 | struct_field_default_comptime_state, |
| 4686 | struct_field_default_runtime_bits_comptime_state, | |
| 4687 | 4679 | struct_field_comptime, |
| 4688 | 4680 | struct_field_comptime_runtime_bits, |
| 4689 | 4681 | struct_field_comptime_comptime_state, |
| 4690 | struct_field_comptime_runtime_bits_comptime_state, | |
| 4691 | 4682 | packed_struct_field, |
| 4692 | 4683 | untagged_union_field, |
| 4693 | 4684 | tagged_union, |
| ... | ... | @@ -4980,15 +4971,6 @@ const AbbrevCode = enum { |
| 4980 | 4971 | .{ .alignment, .udata }, |
| 4981 | 4972 | }, |
| 4982 | 4973 | }, |
| 4983 | .struct_field_default = .{ | |
| 4984 | .tag = .member, | |
| 4985 | .attrs = &.{ | |
| 4986 | .{ .name, .strp }, | |
| 4987 | .{ .type, .ref_addr }, | |
| 4988 | .{ .data_member_location, .udata }, | |
| 4989 | .{ .alignment, .udata }, | |
| 4990 | }, | |
| 4991 | }, | |
| 4992 | 4974 | .struct_field_default_runtime_bits = .{ |
| 4993 | 4975 | .tag = .member, |
| 4994 | 4976 | .attrs = &.{ |
| ... | ... | @@ -5006,18 +4988,7 @@ const AbbrevCode = enum { |
| 5006 | 4988 | .{ .type, .ref_addr }, |
| 5007 | 4989 | .{ .data_member_location, .udata }, |
| 5008 | 4990 | .{ .alignment, .udata }, |
| 5009 | .{ .ZIG_comptime_default_value, .ref_addr }, | |
| 5010 | }, | |
| 5011 | }, | |
| 5012 | .struct_field_default_runtime_bits_comptime_state = .{ | |
| 5013 | .tag = .member, | |
| 5014 | .attrs = &.{ | |
| 5015 | .{ .name, .strp }, | |
| 5016 | .{ .type, .ref_addr }, | |
| 5017 | .{ .data_member_location, .udata }, | |
| 5018 | .{ .alignment, .udata }, | |
| 5019 | .{ .default_value, .block }, | |
| 5020 | .{ .ZIG_comptime_default_value, .ref_addr }, | |
| 4991 | .{ .ZIG_comptime_value, .ref_addr }, | |
| 5021 | 4992 | }, |
| 5022 | 4993 | }, |
| 5023 | 4994 | .struct_field_comptime = .{ |
| ... | ... | @@ -5046,16 +5017,6 @@ const AbbrevCode = enum { |
| 5046 | 5017 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5047 | 5018 | }, |
| 5048 | 5019 | }, |
| 5049 | .struct_field_comptime_runtime_bits_comptime_state = .{ | |
| 5050 | .tag = .member, | |
| 5051 | .attrs = &.{ | |
| 5052 | .{ .const_expr, .flag_present }, | |
| 5053 | .{ .name, .strp }, | |
| 5054 | .{ .type, .ref_addr }, | |
| 5055 | .{ .const_value, .block }, | |
| 5056 | .{ .ZIG_comptime_value, .ref_addr }, | |
| 5057 | }, | |
| 5058 | }, | |
| 5059 | 5020 | .packed_struct_field = .{ |
| 5060 | 5021 | .tag = .member, |
| 5061 | 5022 | .attrs = &.{ |
src/link/Elf/ZigObject.zig+6-3| ... | ... | @@ -267,7 +267,8 @@ pub fn deinit(self: *ZigObject, allocator: Allocator) void { |
| 267 | 267 | pub fn flush(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !void { |
| 268 | 268 | // Handle any lazy symbols that were emitted by incremental compilation. |
| 269 | 269 | if (self.lazy_syms.getPtr(.anyerror_type)) |metadata| { |
| 270 | const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.zcu.?, .tid = tid }; | |
| 270 | const pt: Zcu.PerThread = .activate(elf_file.base.comp.zcu.?, tid); | |
| 271 | defer pt.deactivate(); | |
| 271 | 272 | |
| 272 | 273 | // Most lazy symbols can be updated on first use, but |
| 273 | 274 | // anyerror needs to wait for everything to be flushed. |
| ... | ... | @@ -296,7 +297,8 @@ pub fn flush(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !void { |
| 296 | 297 | } |
| 297 | 298 | |
| 298 | 299 | if (build_options.enable_logging) { |
| 299 | const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.zcu.?, .tid = tid }; | |
| 300 | const pt: Zcu.PerThread = .activate(elf_file.base.comp.zcu.?, tid); | |
| 301 | defer pt.deactivate(); | |
| 300 | 302 | for (self.navs.keys(), self.navs.values()) |nav_index, meta| { |
| 301 | 303 | checkNavAllocated(pt, nav_index, meta); |
| 302 | 304 | } |
| ... | ... | @@ -306,7 +308,8 @@ pub fn flush(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !void { |
| 306 | 308 | } |
| 307 | 309 | |
| 308 | 310 | if (self.dwarf) |*dwarf| { |
| 309 | const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.zcu.?, .tid = tid }; | |
| 311 | const pt: Zcu.PerThread = .activate(elf_file.base.comp.zcu.?, tid); | |
| 312 | defer pt.deactivate(); | |
| 310 | 313 | try dwarf.flushModule(pt); |
| 311 | 314 | |
| 312 | 315 | const gpa = elf_file.base.comp.gpa; |
src/link/MachO/ZigObject.zig+4-2| ... | ... | @@ -549,7 +549,8 @@ pub fn getInputSection(self: ZigObject, atom: Atom, macho_file: *MachO) macho.se |
| 549 | 549 | pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) !void { |
| 550 | 550 | // Handle any lazy symbols that were emitted by incremental compilation. |
| 551 | 551 | if (self.lazy_syms.getPtr(.anyerror_type)) |metadata| { |
| 552 | const pt: Zcu.PerThread = .{ .zcu = macho_file.base.comp.zcu.?, .tid = tid }; | |
| 552 | const pt: Zcu.PerThread = .activate(macho_file.base.comp.zcu.?, tid); | |
| 553 | defer pt.deactivate(); | |
| 553 | 554 | |
| 554 | 555 | // Most lazy symbols can be updated on first use, but |
| 555 | 556 | // anyerror needs to wait for everything to be flushed. |
| ... | ... | @@ -578,7 +579,8 @@ pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) |
| 578 | 579 | } |
| 579 | 580 | |
| 580 | 581 | if (self.dwarf) |*dwarf| { |
| 581 | const pt: Zcu.PerThread = .{ .zcu = macho_file.base.comp.zcu.?, .tid = tid }; | |
| 582 | const pt: Zcu.PerThread = .activate(macho_file.base.comp.zcu.?, tid); | |
| 583 | defer pt.deactivate(); | |
| 582 | 584 | try dwarf.flushModule(pt); |
| 583 | 585 | |
| 584 | 586 | self.debug_abbrev_dirty = false; |
src/link/Plan9.zig+5-4| ... | ... | @@ -604,10 +604,11 @@ pub fn flushModule(self: *Plan9, arena: Allocator, tid: Zcu.PerThread.Id, prog_n |
| 604 | 604 | |
| 605 | 605 | defer assert(self.hdr.entry != 0x0); |
| 606 | 606 | |
| 607 | const pt: Zcu.PerThread = .{ | |
| 608 | .zcu = self.base.comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 609 | .tid = tid, | |
| 610 | }; | |
| 607 | const pt: Zcu.PerThread = .activate( | |
| 608 | self.base.comp.zcu orelse return error.LinkingWithoutZigSourceUnimplemented, | |
| 609 | tid, | |
| 610 | ); | |
| 611 | defer pt.deactivate(); | |
| 611 | 612 | |
| 612 | 613 | // finish up the lazy syms |
| 613 | 614 | if (self.lazy_syms.getPtr(.none)) |metadata| { |
src/link/Wasm/ZigObject.zig+2-1| ... | ... | @@ -589,7 +589,8 @@ fn populateErrorNameTable(zig_object: *ZigObject, wasm: *Wasm, tid: Zcu.PerThrea |
| 589 | 589 | |
| 590 | 590 | // Addend for each relocation to the table |
| 591 | 591 | var addend: u32 = 0; |
| 592 | const pt: Zcu.PerThread = .{ .zcu = wasm.base.comp.zcu.?, .tid = tid }; | |
| 592 | const pt: Zcu.PerThread = .activate(wasm.base.comp.zcu.?, tid); | |
| 593 | defer pt.deactivate(); | |
| 593 | 594 | const slice_ty = Type.slice_const_u8_sentinel_0; |
| 594 | 595 | const atom = wasm.getAtomPtr(atom_index); |
| 595 | 596 | { |
tools/lldb_pretty_printers.py+218-9| ... | ... | @@ -13,21 +13,32 @@ page_size = 1 << 12 |
| 13 | 13 | |
| 14 | 14 | def log2_int(i): return i.bit_length() - 1 |
| 15 | 15 | |
| 16 | def create_struct(name, struct_type, **inits): | |
| 17 | struct_bytes = bytearray(struct_type.size) | |
| 18 | struct_data = lldb.SBData() | |
| 16 | def create_struct(parent, name, struct_type, inits): | |
| 17 | struct_bytes, struct_data = bytearray(struct_type.size), lldb.SBData() | |
| 19 | 18 | for field in struct_type.fields: |
| 20 | 19 | field_size = field.type.size |
| 21 | field_bytes = inits[field.name].data.uint8[:field_size] | |
| 20 | field_init = inits[field.name] | |
| 21 | if isinstance(field_init, int): | |
| 22 | match struct_data.byte_order: | |
| 23 | case lldb.eByteOrderLittle: | |
| 24 | byte_order = 'little' | |
| 25 | case lldb.eByteOrderBig: | |
| 26 | byte_order = 'big' | |
| 27 | field_bytes = field_init.to_bytes(field_size, byte_order, signed=field.type.GetTypeFlags() & lldb.eTypeIsSigned != 0) | |
| 28 | elif isinstance(field_init_type, lldb.SBValue): | |
| 29 | field_bytes = field_init.data.uint8 | |
| 30 | else: return | |
| 22 | 31 | match struct_data.byte_order: |
| 23 | 32 | case lldb.eByteOrderLittle: |
| 33 | field_bytes = field_bytes[:field_size] | |
| 24 | 34 | field_start = field.byte_offset |
| 25 | 35 | struct_bytes[field_start:field_start + len(field_bytes)] = field_bytes |
| 26 | 36 | case lldb.eByteOrderBig: |
| 37 | field_bytes = field_bytes[-field_size:] | |
| 27 | 38 | field_end = field.byte_offset + field_size |
| 28 | 39 | struct_bytes[field_end - len(field_bytes):field_end] = field_bytes |
| 29 | 40 | struct_data.SetData(lldb.SBError(), struct_bytes, struct_data.byte_order, struct_data.GetAddressByteSize()) |
| 30 | return next(iter(inits.values())).CreateValueFromData(name, struct_data, struct_type) | |
| 41 | return parent.CreateValueFromData(name, struct_data, struct_type) | |
| 31 | 42 | |
| 32 | 43 | # Define Zig Language |
| 33 | 44 | |
| ... | ... | @@ -292,6 +303,8 @@ class std_MultiArrayList_Slice_SynthProvider: |
| 292 | 303 | return self.ptrs.CreateValueFromData('[%d]' % index, data, self.entry_type) |
| 293 | 304 | except: return None |
| 294 | 305 | |
| 306 | def MultiArrayList_Entry(type): return '^multi_array_list\\.MultiArrayList\\(%s\\)\\.Entry__struct_[1-9][0-9]*$' % type | |
| 307 | ||
| 295 | 308 | class std_HashMapUnmanaged_SynthProvider: |
| 296 | 309 | def __init__(self, value, _=None): self.value = value |
| 297 | 310 | def update(self): |
| ... | ... | @@ -702,7 +715,7 @@ class root_InternPool_Local_List_SynthProvider: |
| 702 | 715 | def __init__(self, value, _=None): self.value = value |
| 703 | 716 | def update(self): |
| 704 | 717 | capacity = self.value.EvaluateExpression('@as(*@This().Header, @alignCast(@ptrCast(@this().bytes - @This().bytes_offset))).capacity') |
| 705 | self.view = create_struct('view', self.value.EvaluateExpression('@This().View').GetValueAsType(), bytes=self.value.GetChildMemberWithName('bytes'), len=capacity, capacity=capacity).GetNonSyntheticValue() | |
| 718 | self.view = create_struct(self.value, '.view', self.value.type.FindDirectNestedType('View'), { 'bytes': self.value.GetChildMemberWithName('bytes'), 'len': capacity, 'capacity': capacity }).GetNonSyntheticValue() | |
| 706 | 719 | def has_children(self): return True |
| 707 | 720 | def num_children(self): return 1 |
| 708 | 721 | def get_child_index(self, name): |
| ... | ... | @@ -712,6 +725,199 @@ class root_InternPool_Local_List_SynthProvider: |
| 712 | 725 | try: return (self.view,)[index] |
| 713 | 726 | except: pass |
| 714 | 727 | |
| 728 | expr_path_re = re.compile(r'\{([^}]+)%([^%#}]+)(?:#([^%#}]+))?\}') | |
| 729 | def root_InternPool_Index_SummaryProvider(value, _=None): | |
| 730 | unwrapped = value.GetChildMemberWithName('unwrapped') | |
| 731 | if not unwrapped: return '' # .none | |
| 732 | tag = unwrapped.GetChildMemberWithName('tag') | |
| 733 | tag_value = tag.value | |
| 734 | summary = tag.CreateValueFromType(tag.type).GetChildMemberWithName('encodings').GetChildMemberWithName(tag_value.removeprefix('.')).GetChildMemberWithName('summary') | |
| 735 | if not summary: return tag_value | |
| 736 | return re.sub( | |
| 737 | expr_path_re, | |
| 738 | lambda matchobj: getattr(unwrapped.GetValueForExpressionPath(matchobj[1]), matchobj[2]).strip(matchobj[3] or ''), | |
| 739 | summary.summary.removeprefix('.').removeprefix('@"').removesuffix('"').replace(r'\"', '"'), | |
| 740 | ) | |
| 741 | ||
| 742 | class root_InternPool_Index_SynthProvider: | |
| 743 | def __init__(self, value, _=None): self.value = value | |
| 744 | def update(self): | |
| 745 | self.unwrapped = None | |
| 746 | wrapped = self.value.unsigned | |
| 747 | if wrapped == (1 << 32) - 1: return | |
| 748 | unwrapped_type = self.value.type.FindDirectNestedType('Unwrapped') | |
| 749 | ip = self.value.CreateValueFromType(unwrapped_type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?') | |
| 750 | tid_shift_30 = ip.GetChildMemberWithName('tid_shift_30').unsigned | |
| 751 | self.unwrapped = create_struct(self.value, '.unwrapped', unwrapped_type, { 'tid': wrapped >> tid_shift_30, 'index': wrapped & (1 << tid_shift_30) - 1 }) | |
| 752 | def has_children(self): return True | |
| 753 | def num_children(self): return 0 | |
| 754 | def get_child_index(self, name): | |
| 755 | try: return ('unwrapped',).index(name) | |
| 756 | except: pass | |
| 757 | def get_child_at_index(self, index): | |
| 758 | try: return (self.unwrapped,)[index] | |
| 759 | except: pass | |
| 760 | ||
| 761 | class root_InternPool_Index_Unwrapped_SynthProvider: | |
| 762 | def __init__(self, value, _=None): self.value = value | |
| 763 | def update(self): | |
| 764 | self.tag, self.index, self.data, self.payload, self.trailing = None, None, None, None, None | |
| 765 | index = self.value.GetChildMemberWithName('index') | |
| 766 | ip = self.value.CreateValueFromType(self.value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?') | |
| 767 | shared = ip.GetChildMemberWithName('locals').GetSyntheticValue().child[self.value.GetChildMemberWithName('tid').unsigned].GetChildMemberWithName('shared') | |
| 768 | item = shared.GetChildMemberWithName('items').GetChildMemberWithName('view').child[index.unsigned] | |
| 769 | self.tag, item_data = item.GetChildMemberWithName('tag'), item.GetChildMemberWithName('data') | |
| 770 | encoding = self.tag.CreateValueFromType(self.tag.type).GetChildMemberWithName('encodings').GetChildMemberWithName(self.tag.value.removeprefix('.')) | |
| 771 | encoding_index, encoding_data, encoding_payload, encoding_trailing, encoding_config = encoding.GetChildMemberWithName('index'), encoding.GetChildMemberWithName('data'), encoding.GetChildMemberWithName('payload'), encoding.GetChildMemberWithName('trailing'), encoding.GetChildMemberWithName('config') | |
| 772 | if encoding_index: | |
| 773 | index_type = encoding_index.GetValueAsType() | |
| 774 | index_bytes, index_data = index.data.uint8, lldb.SBData() | |
| 775 | match index_data.byte_order: | |
| 776 | case lldb.eByteOrderLittle: | |
| 777 | index_bytes = bytes(index_bytes[:index_type.size]) | |
| 778 | case lldb.eByteOrderBig: | |
| 779 | index_bytes = bytes(index_bytes[-index_type.size:]) | |
| 780 | index_data.SetData(lldb.SBError(), index_bytes, index_data.byte_order, index_data.GetAddressByteSize()) | |
| 781 | self.index = self.value.CreateValueFromData('.index', index_data, index_type) | |
| 782 | elif encoding_data: | |
| 783 | data_type = encoding_data.GetValueAsType() | |
| 784 | data_bytes, data_data = item_data.data.uint8, lldb.SBData() | |
| 785 | match data_data.byte_order: | |
| 786 | case lldb.eByteOrderLittle: | |
| 787 | data_bytes = bytes(data_bytes[:data_type.size]) | |
| 788 | case lldb.eByteOrderBig: | |
| 789 | data_bytes = bytes(data_bytes[-data_type.size:]) | |
| 790 | data_data.SetData(lldb.SBError(), data_bytes, data_data.byte_order, data_data.GetAddressByteSize()) | |
| 791 | self.data = self.value.CreateValueFromData('.data', data_data, data_type) | |
| 792 | elif encoding_payload: | |
| 793 | extra = shared.GetChildMemberWithName('extra').GetChildMemberWithName('view').GetChildMemberWithName('0') | |
| 794 | extra_index = item_data.unsigned | |
| 795 | payload_type = encoding_payload.GetValueAsType() | |
| 796 | payload_fields = dict() | |
| 797 | for payload_field in payload_type.fields: | |
| 798 | payload_fields[payload_field.name] = extra.child[extra_index] | |
| 799 | extra_index += 1 | |
| 800 | self.payload = create_struct(self.value, '.payload', payload_type, payload_fields) | |
| 801 | if encoding_trailing and encoding_config: | |
| 802 | trailing_type = encoding_trailing.GetValueAsType() | |
| 803 | trailing_bytes, trailing_data = bytearray(trailing_type.size), lldb.SBData() | |
| 804 | def eval_config(config_name): | |
| 805 | expr = encoding_config.GetChildMemberWithName(config_name).summary.removeprefix('.').removeprefix('@"').removesuffix('"').replace(r'\"', '"') | |
| 806 | if 'payload.' in expr: | |
| 807 | return self.payload.EvaluateExpression(expr.replace('payload.', '@this().')) | |
| 808 | elif expr.startswith('trailing.'): | |
| 809 | field_type, field_byte_offset = trailing_type, 0 | |
| 810 | expr_parts = expr.split('.') | |
| 811 | for expr_part in expr_parts[1:]: | |
| 812 | field = next(filter(lambda field: field.name == expr_part, field_type.fields)) | |
| 813 | field_type = field.type | |
| 814 | field_byte_offset += field.byte_offset | |
| 815 | field_data = lldb.SBData() | |
| 816 | field_bytes = trailing_bytes[field_byte_offset:field_byte_offset + field_type.size] | |
| 817 | field_data.SetData(lldb.SBError(), field_bytes, field_data.byte_order, field_data.GetAddressByteSize()) | |
| 818 | return self.value.CreateValueFromData('.%s' % expr_parts[-1], field_data, field_type) | |
| 819 | else: | |
| 820 | return self.value.frame.EvaluateExpression(expr) | |
| 821 | for trailing_field in trailing_type.fields: | |
| 822 | trailing_field_type = trailing_field.type | |
| 823 | trailing_field_name = 'trailing.%s' % trailing_field.name | |
| 824 | trailing_field_byte_offset = trailing_field.byte_offset | |
| 825 | while True: | |
| 826 | match [trailing_field_type_field.name for trailing_field_type_field in trailing_field_type.fields]: | |
| 827 | case ['has_value', '?']: | |
| 828 | has_value_field, child_field = trailing_field_type.fields | |
| 829 | trailing_field_name = '%s.%s' % (trailing_field_name, child_field.name) | |
| 830 | match eval_config(trailing_field_name).value: | |
| 831 | case 'true': | |
| 832 | if has_value_field.type.name == 'bool': | |
| 833 | trailing_bytes[trailing_field_byte_offset + has_value_field.byte_offset] = True | |
| 834 | trailing_field_type = child_field.type | |
| 835 | trailing_field_byte_offset += child_field.byte_offset | |
| 836 | case 'false': | |
| 837 | break | |
| 838 | case ['ptr', 'len']: | |
| 839 | ptr_field, len_field = trailing_field_type.fields | |
| 840 | ptr_field_byte_offset, len_field_byte_offset = trailing_field_byte_offset + ptr_field.byte_offset, trailing_field_byte_offset + len_field.byte_offset | |
| 841 | trailing_bytes[ptr_field_byte_offset:ptr_field_byte_offset + ptr_field.type.size] = extra.child[extra_index].address_of.data.uint8 | |
| 842 | len_field_value = eval_config('%s.len' % trailing_field_name) | |
| 843 | len_field_size = len_field.type.size | |
| 844 | match trailing_data.byte_order: | |
| 845 | case lldb.eByteOrderLittle: | |
| 846 | len_field_bytes = len_field_value.data.uint8[:len_field_size] | |
| 847 | trailing_bytes[len_field_byte_offset:len_field_byte_offset + len(len_field_bytes)] = len_field_bytes | |
| 848 | case lldb.eByteOrderBig: | |
| 849 | len_field_bytes = len_field_value.data.uint8[-len_field_size:] | |
| 850 | len_field_end = len_field_byte_offset + len_field_size | |
| 851 | trailing_bytes[len_field_end - len(len_field_bytes):len_field_end] = len_field_bytes | |
| 852 | extra_index += (ptr_field.type.GetPointeeType().size * len_field_value.unsigned + 3) // 4 | |
| 853 | break | |
| 854 | case _: | |
| 855 | for offset in range(0, trailing_field_type.size, 4): | |
| 856 | trailing_bytes[trailing_field_byte_offset + offset:trailing_field_byte_offset + offset + 4] = extra.child[extra_index].data.uint8 | |
| 857 | extra_index += 1 | |
| 858 | break | |
| 859 | trailing_data.SetData(lldb.SBError(), trailing_bytes, trailing_data.byte_order, trailing_data.GetAddressByteSize()) | |
| 860 | self.trailing = self.value.CreateValueFromData('.trailing', trailing_data, trailing_type) | |
| 861 | def has_children(self): return True | |
| 862 | def num_children(self): return 1 + ((self.index or self.data or self.payload) is not None) + (self.trailing is not None) | |
| 863 | def get_child_index(self, name): | |
| 864 | try: return ('tag', 'index' if self.index is not None else 'data' if self.data is not None else 'payload', 'trailing').index(name) | |
| 865 | except: pass | |
| 866 | def get_child_at_index(self, index): | |
| 867 | try: return (self.tag, self.index or self.data or self.payload, self.trailing)[index] | |
| 868 | except: pass | |
| 869 | ||
| 870 | def root_InternPool_String_SummaryProvider(value, _=None): | |
| 871 | wrapped = value.unsigned | |
| 872 | ip = value.CreateValueFromType(value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?') | |
| 873 | tid_shift_32 = ip.GetChildMemberWithName('tid_shift_32').unsigned | |
| 874 | locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue() | |
| 875 | local_value = locals_value.child[wrapped >> tid_shift_32] | |
| 876 | if local_value is None: | |
| 877 | wrapped = 0 | |
| 878 | local_value = locals_value.child[0] | |
| 879 | string = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('strings').GetChildMemberWithName('view').GetChildMemberWithName('0').child[wrapped & (1 << tid_shift_32) - 1].address_of | |
| 880 | string.format = lldb.eFormatCString | |
| 881 | return string.value | |
| 882 | ||
| 883 | class root_InternPool_Cau_Index_SynthProvider: | |
| 884 | def __init__(self, value, _=None): self.value = value | |
| 885 | def update(self): | |
| 886 | self.cau = None | |
| 887 | wrapped = self.value.unsigned | |
| 888 | if wrapped == (1 << 32) - 1: return | |
| 889 | ip = self.value.CreateValueFromType(self.value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?') | |
| 890 | tid_shift_31 = ip.GetChildMemberWithName('tid_shift_31').unsigned | |
| 891 | locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue() | |
| 892 | local_value = locals_value.child[wrapped >> tid_shift_31] | |
| 893 | if local_value is None: | |
| 894 | wrapped = 0 | |
| 895 | local_value = locals_value.child[0] | |
| 896 | self.cau = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('caus').GetChildMemberWithName('view').GetChildMemberWithName('0').child[wrapped & (1 << tid_shift_31) - 1] | |
| 897 | def has_children(self): return self.cau.GetNumChildren(1) > 0 | |
| 898 | def num_children(self): return self.cau.GetNumChildren() | |
| 899 | def get_child_index(self, name): return self.cau.GetIndexOfChildWithName(name) | |
| 900 | def get_child_at_index(self, index): return self.cau.GetChildAtIndex(index) | |
| 901 | ||
| 902 | class root_InternPool_Nav_Index_SynthProvider: | |
| 903 | def __init__(self, value, _=None): self.value = value | |
| 904 | def update(self): | |
| 905 | self.nav = None | |
| 906 | wrapped = self.value.unsigned | |
| 907 | if wrapped == (1 << 32) - 1: return | |
| 908 | ip = self.value.CreateValueFromType(self.value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?') | |
| 909 | tid_shift_32 = ip.GetChildMemberWithName('tid_shift_32').unsigned | |
| 910 | locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue() | |
| 911 | local_value = locals_value.child[wrapped >> tid_shift_32] | |
| 912 | if local_value is None: | |
| 913 | wrapped = 0 | |
| 914 | local_value = locals_value.child[0] | |
| 915 | self.nav = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('navs').GetChildMemberWithName('view').child[wrapped & (1 << tid_shift_32) - 1] | |
| 916 | def has_children(self): return self.nav.GetNumChildren(1) > 0 | |
| 917 | def num_children(self): return self.nav.GetNumChildren() | |
| 918 | def get_child_index(self, name): return self.nav.GetIndexOfChildWithName(name) | |
| 919 | def get_child_at_index(self, index): return self.nav.GetChildAtIndex(index) | |
| 920 | ||
| 715 | 921 | # Initialize |
| 716 | 922 | |
| 717 | 923 | def add(debugger, *, category, regex=False, type, identifier=None, synth=False, inline_children=False, expand=False, summary=False): |
| ... | ... | @@ -719,8 +925,6 @@ def add(debugger, *, category, regex=False, type, identifier=None, synth=False, |
| 719 | 925 | if summary: debugger.HandleCommand('type summary add --category %s%s%s "%s"' % (category, ' --inline-children' if inline_children else ''.join((' --expand' if expand else '', ' --python-function %s_SummaryProvider' % prefix if summary == True else ' --summary-string "%s"' % summary)), ' --regex' if regex else '', type)) |
| 720 | 926 | if synth: debugger.HandleCommand('type synthetic add --category %s%s --python-class %s_SynthProvider "%s"' % (category, ' --regex' if regex else '', prefix, type)) |
| 721 | 927 | |
| 722 | def MultiArrayList_Entry(type): return '^multi_array_list\\.MultiArrayList\\(%s\\)\\.Entry__struct_[1-9][0-9]*$' % type | |
| 723 | ||
| 724 | 928 | def __lldb_init_module(debugger, _=None): |
| 725 | 929 | # Initialize Zig Categories |
| 726 | 930 | debugger.HandleCommand('type category define --language c99 zig.lang zig.std') |
| ... | ... | @@ -765,4 +969,9 @@ def __lldb_init_module(debugger, _=None): |
| 765 | 969 | add(debugger, category='zig.stage2', type='arch.x86_64.CodeGen.MCValue', identifier='zig_TaggedUnion', synth=True, inline_children=True, summary=True) |
| 766 | 970 | |
| 767 | 971 | # Initialize Zig Stage2 Compiler (compiled with the self-hosted backend) |
| 768 | add(debugger, category='zig', regex=True, type='^root\\.InternPool\\.Local\\.List\\(.*\\)$', identifier='root_InternPool_Local_List', synth=True, expand=True, summary='capacity=${var%#}') | |
| 972 | add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.Local\.List\(.*\)$', identifier='root_InternPool_Local_List', synth=True, expand=True, summary='capacity=${var%#}') | |
| 973 | add(debugger, category='zig', type='root.InternPool.Index', synth=True, summary=True) | |
| 974 | add(debugger, category='zig', type='root.InternPool.Index.Unwrapped', synth=True) | |
| 975 | add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.(Optional)?(NullTerminated)?String$', identifier='root_InternPool_String', summary=True) | |
| 976 | add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.Cau\.Index(\.Optional)?$', identifier='root_InternPool_Cau_Index', synth=True) | |
| 977 | add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.Nav\.Index(\.Optional)?$', identifier='root_InternPool_Nav_Index', synth=True) |