| author | |
| committer | |
| log | 98165680582b4d592adb0a057ae2e00d74922e61 |
| tree | d33abfab2654d270b5dad3655fa426c253c61d2c |
| parent | 3f1dead2fc5922b588fbfb108f421ca957d6934a |
| signature |
12 files changed, 302 insertions(+), 537 deletions(-)
build.zig+25-26| ... | ... | @@ -181,10 +181,10 @@ pub fn build(b: *std.Build) !void { |
| 181 | 181 | return; |
| 182 | 182 | |
| 183 | 183 | const entitlements = b.option([]const u8, "entitlements", "Path to entitlements file for hot-code swapping without sudo on macOS"); |
| 184 | const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); | |
| 185 | const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null); | |
| 186 | const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null); | |
| 187 | const tracy_callstack_depth: u32 = b.option(u32, "tracy-callstack-depth", "Declare callstack depth for Tracy data. Does nothing if -Dtracy_callstack is not provided") orelse 10; | |
| 184 | const tracy = b.option(std.Build.LazyPath, "tracy", "Enable Tracy integration. Supply path to Tracy source"); | |
| 185 | const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided. Has a significant performance impact in some cases. Default: false") orelse false; | |
| 186 | const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided. Default: true") orelse (tracy != null); | |
| 187 | const tracy_callstack_depth: u32 = b.option(u32, "tracy-callstack-depth", "Declare callstack depth for Tracy data. Does nothing if -Dtracy-callstack is not provided") orelse 6; | |
| 188 | 188 | const debug_gpa = b.option(bool, "debug-allocator", "Force the compiler to use SafeAllocator") orelse false; |
| 189 | 189 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c); |
| 190 | 190 | const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false; |
| ... | ... | @@ -373,32 +373,31 @@ pub fn build(b: *std.Build) !void { |
| 373 | 373 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); |
| 374 | 374 | exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth); |
| 375 | 375 | exe_options.addOption(bool, "value_tracing", value_tracing); |
| 376 | if (tracy) |tracy_path| { | |
| 377 | const client_cpp = b.pathJoin( | |
| 378 | &[_][]const u8{ tracy_path, "public", "TracyClient.cpp" }, | |
| 379 | ); | |
| 380 | ||
| 381 | const tracy_c_flags: []const []const u8 = &.{ | |
| 382 | "-DTRACY_ENABLE=1", | |
| 383 | "-fno-sanitize=undefined", | |
| 384 | "-DTRACY_FIBERS", | |
| 385 | }; | |
| 386 | ||
| 387 | exe.root_module.addIncludePath(.{ .cwd_relative = tracy_path }); | |
| 388 | exe.root_module.addCSourceFile(.{ | |
| 389 | .file = .{ .cwd_relative = client_cpp }, | |
| 390 | .flags = tracy_c_flags[0..switch (io_mode) { | |
| 391 | .threaded => 2, | |
| 392 | .evented => 3, | |
| 393 | }], | |
| 376 | if (tracy) |tracy_dir| { | |
| 377 | const tracy_mod = b.createModule(.{ | |
| 378 | .target = target, | |
| 379 | // Always build Tracy in ReleaseFast so that it doesn't make Debug compiler builds unusable. | |
| 380 | .optimize = .ReleaseFast, | |
| 381 | .root_source_file = null, | |
| 382 | .link_libc = true, | |
| 383 | .link_libcpp = true, | |
| 394 | 384 | }); |
| 395 | exe.root_module.link_libc = true; | |
| 396 | exe.root_module.link_libcpp = true; | |
| 385 | ||
| 386 | tracy_mod.addCMacro("TRACY_ENABLE", "1"); | |
| 387 | ||
| 388 | if (!tracy_callstack) { | |
| 389 | tracy_mod.addCMacro("TRACY_NO_CALLSTACK", "1"); | |
| 390 | } | |
| 391 | ||
| 392 | tracy_mod.addIncludePath(tracy_dir); | |
| 393 | tracy_mod.addCSourceFile(.{ .file = tracy_dir.path(b, "public/TracyClient.cpp") }); | |
| 397 | 394 | |
| 398 | 395 | if (target.result.os.tag == .windows) { |
| 399 | exe.root_module.linkSystemLibrary("dbghelp", .{}); | |
| 400 | exe.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 396 | tracy_mod.linkSystemLibrary("dbghelp", .{}); | |
| 397 | tracy_mod.linkSystemLibrary("ws2_32", .{}); | |
| 401 | 398 | } |
| 399 | ||
| 400 | exe.root_module.addImport("tracy", tracy_mod); | |
| 402 | 401 | } |
| 403 | 402 | |
| 404 | 403 | const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{}; |
src/Air/Liveness.zig+2-2| ... | ... | @@ -13,7 +13,7 @@ const Log2Int = std.math.Log2Int; |
| 13 | 13 | const Writer = std.Io.Writer; |
| 14 | 14 | |
| 15 | 15 | const Liveness = @This(); |
| 16 | const trace = @import("../tracy.zig").trace; | |
| 16 | const traceNamed = @import("../tracy.zig").traceNamed; | |
| 17 | 17 | const Air = @import("../Air.zig"); |
| 18 | 18 | const InternPool = @import("../InternPool.zig"); |
| 19 | 19 | const Zcu = @import("../Zcu.zig"); |
| ... | ... | @@ -140,7 +140,7 @@ fn LivenessPassData(comptime pass: LivenessPass) type { |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Liveness { |
| 143 | const tracy = trace(@src()); | |
| 143 | const tracy = traceNamed(@src(), "analyze_liveness"); | |
| 144 | 144 | defer tracy.end(); |
| 145 | 145 | |
| 146 | 146 | const gpa = zcu.gpa; |
src/Compilation.zig+2-2| ... | ... | @@ -2870,8 +2870,8 @@ pub const UpdateError = error{ |
| 2870 | 2870 | |
| 2871 | 2871 | /// Detect changes to source files, perform semantic analysis, and update the output files. |
| 2872 | 2872 | pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateError!void { |
| 2873 | const tracy_trace = trace(@src()); | |
| 2874 | defer tracy_trace.end(); | |
| 2873 | const tracy_frame = tracy.namedFrame(comp.root_name); | |
| 2874 | defer tracy_frame.end(); | |
| 2875 | 2875 | |
| 2876 | 2876 | const gpa = comp.gpa; |
| 2877 | 2877 | const io = comp.io; |
src/Sema.zig-287| ... | ... | @@ -19,7 +19,6 @@ const Type = @import("Type.zig"); |
| 19 | 19 | const Air = @import("Air.zig"); |
| 20 | 20 | const Zir = std.zig.Zir; |
| 21 | 21 | const Zcu = @import("Zcu.zig"); |
| 22 | const trace = @import("tracy.zig").trace; | |
| 23 | 22 | const Namespace = Zcu.Namespace; |
| 24 | 23 | const CompileError = Zcu.CompileError; |
| 25 | 24 | const SemaError = Zcu.SemaError; |
| ... | ... | @@ -1127,8 +1126,6 @@ fn analyzeBodyInner( |
| 1127 | 1126 | block: *Block, |
| 1128 | 1127 | body: []const Zir.Inst.Index, |
| 1129 | 1128 | ) CompileError!void { |
| 1130 | // No tracy calls here, to avoid interfering with the tail call mechanism. | |
| 1131 | ||
| 1132 | 1129 | try sema.inst_map.ensureSpaceForInstructions(sema.gpa, body); |
| 1133 | 1130 | |
| 1134 | 1131 | const pt = sema.pt; |
| ... | ... | @@ -3002,9 +2999,6 @@ fn zirErrorSetDecl( |
| 3002 | 2999 | sema: *Sema, |
| 3003 | 3000 | inst: Zir.Inst.Index, |
| 3004 | 3001 | ) CompileError!Air.Inst.Ref { |
| 3005 | const tracy = trace(@src()); | |
| 3006 | defer tracy.end(); | |
| 3007 | ||
| 3008 | 3002 | const pt = sema.pt; |
| 3009 | 3003 | const zcu = pt.zcu; |
| 3010 | 3004 | const comp = zcu.comp; |
| ... | ... | @@ -3032,9 +3026,6 @@ fn zirErrorSetDecl( |
| 3032 | 3026 | } |
| 3033 | 3027 | |
| 3034 | 3028 | fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3035 | const tracy = trace(@src()); | |
| 3036 | defer tracy.end(); | |
| 3037 | ||
| 3038 | 3029 | const pt = sema.pt; |
| 3039 | 3030 | const zcu = pt.zcu; |
| 3040 | 3031 | |
| ... | ... | @@ -3061,18 +3052,12 @@ fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 3061 | 3052 | } |
| 3062 | 3053 | |
| 3063 | 3054 | fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3064 | const tracy = trace(@src()); | |
| 3065 | defer tracy.end(); | |
| 3066 | ||
| 3067 | 3055 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| 3068 | 3056 | const operand = sema.resolveInst(inst_data.operand); |
| 3069 | 3057 | return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand, .none); |
| 3070 | 3058 | } |
| 3071 | 3059 | |
| 3072 | 3060 | fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3073 | const tracy = trace(@src()); | |
| 3074 | defer tracy.end(); | |
| 3075 | ||
| 3076 | 3061 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 3077 | 3062 | const operand = sema.resolveInst(inst_data.operand); |
| 3078 | 3063 | const src = block.nodeOffset(inst_data.src_node); |
| ... | ... | @@ -3114,9 +3099,6 @@ fn ensureResultUsed( |
| 3114 | 3099 | } |
| 3115 | 3100 | |
| 3116 | 3101 | fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3117 | const tracy = trace(@src()); | |
| 3118 | defer tracy.end(); | |
| 3119 | ||
| 3120 | 3102 | const pt = sema.pt; |
| 3121 | 3103 | const zcu = pt.zcu; |
| 3122 | 3104 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -3139,9 +3121,6 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3139 | 3121 | } |
| 3140 | 3122 | |
| 3141 | 3123 | fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3142 | const tracy = trace(@src()); | |
| 3143 | defer tracy.end(); | |
| 3144 | ||
| 3145 | 3124 | const pt = sema.pt; |
| 3146 | 3125 | const zcu = pt.zcu; |
| 3147 | 3126 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -3166,9 +3145,6 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index |
| 3166 | 3145 | } |
| 3167 | 3146 | |
| 3168 | 3147 | fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3169 | const tracy = trace(@src()); | |
| 3170 | defer tracy.end(); | |
| 3171 | ||
| 3172 | 3148 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 3173 | 3149 | const src = block.nodeOffset(inst_data.src_node); |
| 3174 | 3150 | const object = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -3302,9 +3278,6 @@ fn zirAllocExtended( |
| 3302 | 3278 | } |
| 3303 | 3279 | |
| 3304 | 3280 | fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3305 | const tracy = trace(@src()); | |
| 3306 | defer tracy.end(); | |
| 3307 | ||
| 3308 | 3281 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 3309 | 3282 | const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node }); |
| 3310 | 3283 | const var_src = block.nodeOffset(inst_data.src_node); |
| ... | ... | @@ -3732,9 +3705,6 @@ fn zirAllocInferredComptime( |
| 3732 | 3705 | } |
| 3733 | 3706 | |
| 3734 | 3707 | fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3735 | const tracy = trace(@src()); | |
| 3736 | defer tracy.end(); | |
| 3737 | ||
| 3738 | 3708 | const pt = sema.pt; |
| 3739 | 3709 | const zcu = pt.zcu; |
| 3740 | 3710 | |
| ... | ... | @@ -3764,9 +3734,6 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 3764 | 3734 | } |
| 3765 | 3735 | |
| 3766 | 3736 | fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3767 | const tracy = trace(@src()); | |
| 3768 | defer tracy.end(); | |
| 3769 | ||
| 3770 | 3737 | const pt = sema.pt; |
| 3771 | 3738 | const zcu = pt.zcu; |
| 3772 | 3739 | |
| ... | ... | @@ -3797,9 +3764,6 @@ fn zirAllocInferred( |
| 3797 | 3764 | block: *Block, |
| 3798 | 3765 | is_const: bool, |
| 3799 | 3766 | ) CompileError!Air.Inst.Ref { |
| 3800 | const tracy = trace(@src()); | |
| 3801 | defer tracy.end(); | |
| 3802 | ||
| 3803 | 3767 | const gpa = sema.gpa; |
| 3804 | 3768 | |
| 3805 | 3769 | if (block.isComptime()) { |
| ... | ... | @@ -3830,9 +3794,6 @@ fn zirAllocInferred( |
| 3830 | 3794 | } |
| 3831 | 3795 | |
| 3832 | 3796 | fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3833 | const tracy = trace(@src()); | |
| 3834 | defer tracy.end(); | |
| 3835 | ||
| 3836 | 3797 | const pt = sema.pt; |
| 3837 | 3798 | const zcu = pt.zcu; |
| 3838 | 3799 | const gpa = sema.gpa; |
| ... | ... | @@ -4391,9 +4352,6 @@ fn zirValidatePtrStructInit( |
| 4391 | 4352 | block: *Block, |
| 4392 | 4353 | inst: Zir.Inst.Index, |
| 4393 | 4354 | ) CompileError!void { |
| 4394 | const tracy = trace(@src()); | |
| 4395 | defer tracy.end(); | |
| 4396 | ||
| 4397 | 4355 | const pt = sema.pt; |
| 4398 | 4356 | const zcu = pt.zcu; |
| 4399 | 4357 | const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -4776,9 +4734,6 @@ pub fn addDeclaredHereNote(sema: *Sema, parent: *Zcu.ErrorMsg, decl_ty: Type) !v |
| 4776 | 4734 | } |
| 4777 | 4735 | |
| 4778 | 4736 | fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4779 | const tracy = trace(@src()); | |
| 4780 | defer tracy.end(); | |
| 4781 | ||
| 4782 | 4737 | const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 4783 | 4738 | const src = block.nodeOffset(pl_node.src_node); |
| 4784 | 4739 | const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data; |
| ... | ... | @@ -4870,9 +4825,6 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 4870 | 4825 | } |
| 4871 | 4826 | |
| 4872 | 4827 | fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4873 | const tracy = trace(@src()); | |
| 4874 | defer tracy.end(); | |
| 4875 | ||
| 4876 | 4828 | const zir_tags = sema.code.instructions.items(.tag); |
| 4877 | 4829 | const zir_datas = sema.code.instructions.items(.data); |
| 4878 | 4830 | const inst_data = zir_datas[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -4935,8 +4887,6 @@ fn uavRef(sema: *Sema, val: Value) CompileError!Air.Inst.Ref { |
| 4935 | 4887 | |
| 4936 | 4888 | fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4937 | 4889 | _ = block; |
| 4938 | const tracy = trace(@src()); | |
| 4939 | defer tracy.end(); | |
| 4940 | 4890 | |
| 4941 | 4891 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].int; |
| 4942 | 4892 | return sema.pt.intRef(.comptime_int, int); |
| ... | ... | @@ -4944,8 +4894,6 @@ fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 4944 | 4894 | |
| 4945 | 4895 | fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4946 | 4896 | _ = block; |
| 4947 | const tracy = trace(@src()); | |
| 4948 | defer tracy.end(); | |
| 4949 | 4897 | |
| 4950 | 4898 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].str; |
| 4951 | 4899 | const byte_count = int.len * @sizeOf(std.math.big.Limb); |
| ... | ... | @@ -4981,9 +4929,6 @@ fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 4981 | 4929 | } |
| 4982 | 4930 | |
| 4983 | 4931 | fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4984 | const tracy = trace(@src()); | |
| 4985 | defer tracy.end(); | |
| 4986 | ||
| 4987 | 4932 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 4988 | 4933 | const src = block.nodeOffset(inst_data.src_node); |
| 4989 | 4934 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| ... | ... | @@ -5111,9 +5056,6 @@ fn zirTrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5111 | 5056 | } |
| 5112 | 5057 | |
| 5113 | 5058 | fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5114 | const tracy = trace(@src()); | |
| 5115 | defer tracy.end(); | |
| 5116 | ||
| 5117 | 5059 | const pt = sema.pt; |
| 5118 | 5060 | const zcu = pt.zcu; |
| 5119 | 5061 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -5202,9 +5144,6 @@ fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) Comp |
| 5202 | 5144 | } |
| 5203 | 5145 | |
| 5204 | 5146 | fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5205 | const tracy = trace(@src()); | |
| 5206 | defer tracy.end(); | |
| 5207 | ||
| 5208 | 5147 | const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 5209 | 5148 | const src = parent_block.nodeOffset(pl_node.src_node); |
| 5210 | 5149 | const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index); |
| ... | ... | @@ -5326,9 +5265,6 @@ fn resolveAnalyzedBlock( |
| 5326 | 5265 | merges: *Block.Merges, |
| 5327 | 5266 | need_debug_scope: bool, |
| 5328 | 5267 | ) CompileError!Air.Inst.Ref { |
| 5329 | const tracy = trace(@src()); | |
| 5330 | defer tracy.end(); | |
| 5331 | ||
| 5332 | 5268 | const gpa = sema.gpa; |
| 5333 | 5269 | const pt = sema.pt; |
| 5334 | 5270 | const zcu = pt.zcu; |
| ... | ... | @@ -5540,9 +5476,6 @@ fn resolveAnalyzedBlock( |
| 5540 | 5476 | } |
| 5541 | 5477 | |
| 5542 | 5478 | fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5543 | const tracy = trace(@src()); | |
| 5544 | defer tracy.end(); | |
| 5545 | ||
| 5546 | 5479 | const pt = sema.pt; |
| 5547 | 5480 | const zcu = pt.zcu; |
| 5548 | 5481 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -5713,9 +5646,6 @@ fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 5713 | 5646 | } |
| 5714 | 5647 | |
| 5715 | 5648 | fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5716 | const tracy = trace(@src()); | |
| 5717 | defer tracy.end(); | |
| 5718 | ||
| 5719 | 5649 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; |
| 5720 | 5650 | const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; |
| 5721 | 5651 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -5746,9 +5676,6 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError |
| 5746 | 5676 | } |
| 5747 | 5677 | |
| 5748 | 5678 | fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5749 | const tracy = trace(@src()); | |
| 5750 | defer tracy.end(); | |
| 5751 | ||
| 5752 | 5679 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; |
| 5753 | 5680 | const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; |
| 5754 | 5681 | const operand_src = start_block.nodeOffset(extra.operand_src_node.unwrap().?); |
| ... | ... | @@ -6139,9 +6066,6 @@ fn zirCall( |
| 6139 | 6066 | inst: Zir.Inst.Index, |
| 6140 | 6067 | comptime kind: enum { direct, field }, |
| 6141 | 6068 | ) CompileError!Air.Inst.Ref { |
| 6142 | const tracy = trace(@src()); | |
| 6143 | defer tracy.end(); | |
| 6144 | ||
| 6145 | 6069 | const pt = sema.pt; |
| 6146 | 6070 | const zcu = pt.zcu; |
| 6147 | 6071 | const comp = zcu.comp; |
| ... | ... | @@ -7376,9 +7300,6 @@ fn zirIntType(sema: *Sema, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7376 | 7300 | } |
| 7377 | 7301 | |
| 7378 | 7302 | fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7379 | const tracy = trace(@src()); | |
| 7380 | defer tracy.end(); | |
| 7381 | ||
| 7382 | 7303 | const pt = sema.pt; |
| 7383 | 7304 | const zcu = pt.zcu; |
| 7384 | 7305 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -7469,9 +7390,6 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 7469 | 7390 | } |
| 7470 | 7391 | |
| 7471 | 7392 | fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7472 | const tracy = trace(@src()); | |
| 7473 | defer tracy.end(); | |
| 7474 | ||
| 7475 | 7393 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 7476 | 7394 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7477 | 7395 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); |
| ... | ... | @@ -7488,9 +7406,6 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 7488 | 7406 | } |
| 7489 | 7407 | |
| 7490 | 7408 | fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7491 | const tracy = trace(@src()); | |
| 7492 | defer tracy.end(); | |
| 7493 | ||
| 7494 | 7409 | const pt = sema.pt; |
| 7495 | 7410 | const zcu = pt.zcu; |
| 7496 | 7411 | const comp = zcu.comp; |
| ... | ... | @@ -7534,9 +7449,6 @@ fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: |
| 7534 | 7449 | } |
| 7535 | 7450 | |
| 7536 | 7451 | fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7537 | const tracy = trace(@src()); | |
| 7538 | defer tracy.end(); | |
| 7539 | ||
| 7540 | 7452 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 7541 | 7453 | if (true) { |
| 7542 | 7454 | return sema.failWithUseOfAsync(block, block.nodeOffset(inst_data.src_node)); |
| ... | ... | @@ -7550,9 +7462,6 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 7550 | 7462 | } |
| 7551 | 7463 | |
| 7552 | 7464 | fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7553 | const tracy = trace(@src()); | |
| 7554 | defer tracy.end(); | |
| 7555 | ||
| 7556 | 7465 | const pt = sema.pt; |
| 7557 | 7466 | const zcu = pt.zcu; |
| 7558 | 7467 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -7613,9 +7522,6 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 7613 | 7522 | } |
| 7614 | 7523 | |
| 7615 | 7524 | fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 7616 | const tracy = trace(@src()); | |
| 7617 | defer tracy.end(); | |
| 7618 | ||
| 7619 | 7525 | const pt = sema.pt; |
| 7620 | 7526 | const zcu = pt.zcu; |
| 7621 | 7527 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -7655,9 +7561,6 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 7655 | 7561 | } |
| 7656 | 7562 | |
| 7657 | 7563 | fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 7658 | const tracy = trace(@src()); | |
| 7659 | defer tracy.end(); | |
| 7660 | ||
| 7661 | 7564 | const pt = sema.pt; |
| 7662 | 7565 | const zcu = pt.zcu; |
| 7663 | 7566 | const io = zcu.comp.io; |
| ... | ... | @@ -7702,9 +7605,6 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 7702 | 7605 | } |
| 7703 | 7606 | |
| 7704 | 7607 | fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7705 | const tracy = trace(@src()); | |
| 7706 | defer tracy.end(); | |
| 7707 | ||
| 7708 | 7608 | const pt = sema.pt; |
| 7709 | 7609 | const zcu = pt.zcu; |
| 7710 | 7610 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -7759,8 +7659,6 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 7759 | 7659 | |
| 7760 | 7660 | fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7761 | 7661 | _ = block; |
| 7762 | const tracy = trace(@src()); | |
| 7763 | defer tracy.end(); | |
| 7764 | 7662 | |
| 7765 | 7663 | const pt = sema.pt; |
| 7766 | 7664 | const zcu = pt.zcu; |
| ... | ... | @@ -7776,9 +7674,6 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7776 | 7674 | } |
| 7777 | 7675 | |
| 7778 | 7676 | fn zirDeclLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index, do_coerce: bool) CompileError!Air.Inst.Ref { |
| 7779 | const tracy = trace(@src()); | |
| 7780 | defer tracy.end(); | |
| 7781 | ||
| 7782 | 7677 | const pt = sema.pt; |
| 7783 | 7678 | const zcu = pt.zcu; |
| 7784 | 7679 | const comp = zcu.comp; |
| ... | ... | @@ -7960,9 +7855,6 @@ fn zirOptionalPayloadPtr( |
| 7960 | 7855 | inst: Zir.Inst.Index, |
| 7961 | 7856 | safety_check: bool, |
| 7962 | 7857 | ) CompileError!Air.Inst.Ref { |
| 7963 | const tracy = trace(@src()); | |
| 7964 | defer tracy.end(); | |
| 7965 | ||
| 7966 | 7858 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 7967 | 7859 | const optional_ptr = sema.resolveInst(inst_data.operand); |
| 7968 | 7860 | const src = block.nodeOffset(inst_data.src_node); |
| ... | ... | @@ -8051,9 +7943,6 @@ fn zirOptionalPayload( |
| 8051 | 7943 | inst: Zir.Inst.Index, |
| 8052 | 7944 | safety_check: bool, |
| 8053 | 7945 | ) CompileError!Air.Inst.Ref { |
| 8054 | const tracy = trace(@src()); | |
| 8055 | defer tracy.end(); | |
| 8056 | ||
| 8057 | 7946 | const pt = sema.pt; |
| 8058 | 7947 | const zcu = pt.zcu; |
| 8059 | 7948 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -8105,9 +7994,6 @@ fn zirErrUnionPayload( |
| 8105 | 7994 | block: *Block, |
| 8106 | 7995 | inst: Zir.Inst.Index, |
| 8107 | 7996 | ) CompileError!Air.Inst.Ref { |
| 8108 | const tracy = trace(@src()); | |
| 8109 | defer tracy.end(); | |
| 8110 | ||
| 8111 | 7997 | const pt = sema.pt; |
| 8112 | 7998 | const zcu = pt.zcu; |
| 8113 | 7999 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -8164,9 +8050,6 @@ fn zirErrUnionPayloadPtr( |
| 8164 | 8050 | block: *Block, |
| 8165 | 8051 | inst: Zir.Inst.Index, |
| 8166 | 8052 | ) CompileError!Air.Inst.Ref { |
| 8167 | const tracy = trace(@src()); | |
| 8168 | defer tracy.end(); | |
| 8169 | ||
| 8170 | 8053 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8171 | 8054 | const operand = sema.resolveInst(inst_data.operand); |
| 8172 | 8055 | const src = block.nodeOffset(inst_data.src_node); |
| ... | ... | @@ -8256,9 +8139,6 @@ fn analyzeErrUnionPayloadPtr( |
| 8256 | 8139 | |
| 8257 | 8140 | /// Value in, value out |
| 8258 | 8141 | fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8259 | const tracy = trace(@src()); | |
| 8260 | defer tracy.end(); | |
| 8261 | ||
| 8262 | 8142 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8263 | 8143 | const src = block.nodeOffset(inst_data.src_node); |
| 8264 | 8144 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -8292,9 +8172,6 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air |
| 8292 | 8172 | |
| 8293 | 8173 | /// Pointer in, value out |
| 8294 | 8174 | fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8295 | const tracy = trace(@src()); | |
| 8296 | defer tracy.end(); | |
| 8297 | ||
| 8298 | 8175 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8299 | 8176 | const src = block.nodeOffset(inst_data.src_node); |
| 8300 | 8177 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -9088,9 +8965,6 @@ fn zirParamAnytype( |
| 9088 | 8965 | } |
| 9089 | 8966 | |
| 9090 | 8967 | fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9091 | const tracy = trace(@src()); | |
| 9092 | defer tracy.end(); | |
| 9093 | ||
| 9094 | 8968 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9095 | 8969 | const src = block.nodeOffset(inst_data.src_node); |
| 9096 | 8970 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; |
| ... | ... | @@ -9098,9 +8972,6 @@ fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 9098 | 8972 | } |
| 9099 | 8973 | |
| 9100 | 8974 | fn zirAsShiftOperand(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9101 | const tracy = trace(@src()); | |
| 9102 | defer tracy.end(); | |
| 9103 | ||
| 9104 | 8975 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9105 | 8976 | const src = block.nodeOffset(inst_data.src_node); |
| 9106 | 8977 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; |
| ... | ... | @@ -9136,9 +9007,6 @@ fn analyzeAs( |
| 9136 | 9007 | } |
| 9137 | 9008 | |
| 9138 | 9009 | fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9139 | const tracy = trace(@src()); | |
| 9140 | defer tracy.end(); | |
| 9141 | ||
| 9142 | 9010 | const pt = sema.pt; |
| 9143 | 9011 | const zcu = pt.zcu; |
| 9144 | 9012 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -9193,9 +9061,6 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9193 | 9061 | } |
| 9194 | 9062 | |
| 9195 | 9063 | fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9196 | const tracy = trace(@src()); | |
| 9197 | defer tracy.end(); | |
| 9198 | ||
| 9199 | 9064 | const pt = sema.pt; |
| 9200 | 9065 | const zcu = pt.zcu; |
| 9201 | 9066 | const comp = zcu.comp; |
| ... | ... | @@ -9218,9 +9083,6 @@ fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 9218 | 9083 | } |
| 9219 | 9084 | |
| 9220 | 9085 | fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9221 | const tracy = trace(@src()); | |
| 9222 | defer tracy.end(); | |
| 9223 | ||
| 9224 | 9086 | const pt = sema.pt; |
| 9225 | 9087 | const zcu = pt.zcu; |
| 9226 | 9088 | const comp = zcu.comp; |
| ... | ... | @@ -9243,9 +9105,6 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9243 | 9105 | } |
| 9244 | 9106 | |
| 9245 | 9107 | fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9246 | const tracy = trace(@src()); | |
| 9247 | defer tracy.end(); | |
| 9248 | ||
| 9249 | 9108 | const pt = sema.pt; |
| 9250 | 9109 | const zcu = pt.zcu; |
| 9251 | 9110 | const comp = zcu.comp; |
| ... | ... | @@ -9276,9 +9135,6 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 9276 | 9135 | } |
| 9277 | 9136 | |
| 9278 | 9137 | fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9279 | const tracy = trace(@src()); | |
| 9280 | defer tracy.end(); | |
| 9281 | ||
| 9282 | 9138 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9283 | 9139 | const src = block.nodeOffset(inst_data.src_node); |
| 9284 | 9140 | const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| ... | ... | @@ -9289,9 +9145,6 @@ fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 9289 | 9145 | } |
| 9290 | 9146 | |
| 9291 | 9147 | fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9292 | const tracy = trace(@src()); | |
| 9293 | defer tracy.end(); | |
| 9294 | ||
| 9295 | 9148 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9296 | 9149 | const src = block.nodeOffset(inst_data.src_node); |
| 9297 | 9150 | const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| ... | ... | @@ -9302,9 +9155,6 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 9302 | 9155 | } |
| 9303 | 9156 | |
| 9304 | 9157 | fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9305 | const tracy = trace(@src()); | |
| 9306 | defer tracy.end(); | |
| 9307 | ||
| 9308 | 9158 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9309 | 9159 | const src = block.nodeOffset(inst_data.src_node); |
| 9310 | 9160 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| ... | ... | @@ -9375,9 +9225,6 @@ fn intCast( |
| 9375 | 9225 | } |
| 9376 | 9226 | |
| 9377 | 9227 | fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9378 | const tracy = trace(@src()); | |
| 9379 | defer tracy.end(); | |
| 9380 | ||
| 9381 | 9228 | const pt = sema.pt; |
| 9382 | 9229 | const zcu = pt.zcu; |
| 9383 | 9230 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -9541,9 +9388,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9541 | 9388 | } |
| 9542 | 9389 | |
| 9543 | 9390 | fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9544 | const tracy = trace(@src()); | |
| 9545 | defer tracy.end(); | |
| 9546 | ||
| 9547 | 9391 | const pt = sema.pt; |
| 9548 | 9392 | const zcu = pt.zcu; |
| 9549 | 9393 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -9609,9 +9453,6 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 9609 | 9453 | } |
| 9610 | 9454 | |
| 9611 | 9455 | fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9612 | const tracy = trace(@src()); | |
| 9613 | defer tracy.end(); | |
| 9614 | ||
| 9615 | 9456 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9616 | 9457 | const src = block.nodeOffset(inst_data.src_node); |
| 9617 | 9458 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| ... | ... | @@ -9621,9 +9462,6 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9621 | 9462 | } |
| 9622 | 9463 | |
| 9623 | 9464 | fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9624 | const tracy = trace(@src()); | |
| 9625 | defer tracy.end(); | |
| 9626 | ||
| 9627 | 9465 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9628 | 9466 | const src = block.nodeOffset(inst_data.src_node); |
| 9629 | 9467 | const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node }); |
| ... | ... | @@ -9643,9 +9481,6 @@ fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9643 | 9481 | } |
| 9644 | 9482 | |
| 9645 | 9483 | fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9646 | const tracy = trace(@src()); | |
| 9647 | defer tracy.end(); | |
| 9648 | ||
| 9649 | 9484 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; |
| 9650 | 9485 | const array = sema.resolveInst(inst_data.operand); |
| 9651 | 9486 | const elem_index = try sema.pt.intRef(.usize, inst_data.idx); |
| ... | ... | @@ -9653,9 +9488,6 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9653 | 9488 | } |
| 9654 | 9489 | |
| 9655 | 9490 | fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9656 | const tracy = trace(@src()); | |
| 9657 | defer tracy.end(); | |
| 9658 | ||
| 9659 | 9491 | const pt = sema.pt; |
| 9660 | 9492 | const zcu = pt.zcu; |
| 9661 | 9493 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -9684,9 +9516,6 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9684 | 9516 | } |
| 9685 | 9517 | |
| 9686 | 9518 | fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9687 | const tracy = trace(@src()); | |
| 9688 | defer tracy.end(); | |
| 9689 | ||
| 9690 | 9519 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9691 | 9520 | const src = block.nodeOffset(inst_data.src_node); |
| 9692 | 9521 | const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node }); |
| ... | ... | @@ -9698,9 +9527,6 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9698 | 9527 | } |
| 9699 | 9528 | |
| 9700 | 9529 | fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9701 | const tracy = trace(@src()); | |
| 9702 | defer tracy.end(); | |
| 9703 | ||
| 9704 | 9530 | const pt = sema.pt; |
| 9705 | 9531 | const zcu = pt.zcu; |
| 9706 | 9532 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -9719,9 +9545,6 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 9719 | 9545 | } |
| 9720 | 9546 | |
| 9721 | 9547 | fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9722 | const tracy = trace(@src()); | |
| 9723 | defer tracy.end(); | |
| 9724 | ||
| 9725 | 9548 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9726 | 9549 | const src = block.nodeOffset(inst_data.src_node); |
| 9727 | 9550 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| ... | ... | @@ -9735,9 +9558,6 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9735 | 9558 | } |
| 9736 | 9559 | |
| 9737 | 9560 | fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9738 | const tracy = trace(@src()); | |
| 9739 | defer tracy.end(); | |
| 9740 | ||
| 9741 | 9561 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9742 | 9562 | const src = block.nodeOffset(inst_data.src_node); |
| 9743 | 9563 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| ... | ... | @@ -9752,9 +9572,6 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9752 | 9572 | } |
| 9753 | 9573 | |
| 9754 | 9574 | fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9755 | const tracy = trace(@src()); | |
| 9756 | defer tracy.end(); | |
| 9757 | ||
| 9758 | 9575 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9759 | 9576 | const src = block.nodeOffset(inst_data.src_node); |
| 9760 | 9577 | const sentinel_src = block.src(.{ .node_offset_slice_sentinel = inst_data.src_node }); |
| ... | ... | @@ -9771,9 +9588,6 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 9771 | 9588 | } |
| 9772 | 9589 | |
| 9773 | 9590 | fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9774 | const tracy = trace(@src()); | |
| 9775 | defer tracy.end(); | |
| 9776 | ||
| 9777 | 9591 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9778 | 9592 | const src = block.nodeOffset(inst_data.src_node); |
| 9779 | 9593 | const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data; |
| ... | ... | @@ -9793,9 +9607,6 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9793 | 9607 | } |
| 9794 | 9608 | |
| 9795 | 9609 | fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9796 | const tracy = trace(@src()); | |
| 9797 | defer tracy.end(); | |
| 9798 | ||
| 9799 | 9610 | const pt = sema.pt; |
| 9800 | 9611 | const zcu = pt.zcu; |
| 9801 | 9612 | |
| ... | ... | @@ -9833,9 +9644,6 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 9833 | 9644 | } |
| 9834 | 9645 | |
| 9835 | 9646 | fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9836 | const tracy = trace(@src()); | |
| 9837 | defer tracy.end(); | |
| 9838 | ||
| 9839 | 9647 | const pt = sema.pt; |
| 9840 | 9648 | const zcu = pt.zcu; |
| 9841 | 9649 | const gpa = sema.gpa; |
| ... | ... | @@ -9999,8 +9807,6 @@ fn zirSwitchBlock( |
| 9999 | 9807 | inst: Zir.Inst.Index, |
| 10000 | 9808 | operand_is_ref: bool, |
| 10001 | 9809 | ) CompileError!Air.Inst.Ref { |
| 10002 | const tracy = trace(@src()); | |
| 10003 | defer tracy.end(); | |
| 10004 | 9810 | const zir_switch = sema.code.getSwitchBlock(inst); |
| 10005 | 9811 | |
| 10006 | 9812 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| ... | ... | @@ -12847,9 +12653,6 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 12847 | 12653 | } |
| 12848 | 12654 | |
| 12849 | 12655 | fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 12850 | const tracy = trace(@src()); | |
| 12851 | defer tracy.end(); | |
| 12852 | ||
| 12853 | 12656 | const pt = sema.pt; |
| 12854 | 12657 | const zcu = pt.zcu; |
| 12855 | 12658 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; |
| ... | ... | @@ -12898,9 +12701,6 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12898 | 12701 | } |
| 12899 | 12702 | |
| 12900 | 12703 | fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 12901 | const tracy = trace(@src()); | |
| 12902 | defer tracy.end(); | |
| 12903 | ||
| 12904 | 12704 | const pt = sema.pt; |
| 12905 | 12705 | const zcu = pt.zcu; |
| 12906 | 12706 | |
| ... | ... | @@ -12935,9 +12735,6 @@ fn zirShl( |
| 12935 | 12735 | inst: Zir.Inst.Index, |
| 12936 | 12736 | air_tag: Air.Inst.Tag, |
| 12937 | 12737 | ) CompileError!Air.Inst.Ref { |
| 12938 | const tracy = trace(@src()); | |
| 12939 | defer tracy.end(); | |
| 12940 | ||
| 12941 | 12738 | const pt = sema.pt; |
| 12942 | 12739 | const zcu = pt.zcu; |
| 12943 | 12740 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -13125,9 +12922,6 @@ fn zirShr( |
| 13125 | 12922 | inst: Zir.Inst.Index, |
| 13126 | 12923 | air_tag: Air.Inst.Tag, |
| 13127 | 12924 | ) CompileError!Air.Inst.Ref { |
| 13128 | const tracy = trace(@src()); | |
| 13129 | defer tracy.end(); | |
| 13130 | ||
| 13131 | 12925 | const pt = sema.pt; |
| 13132 | 12926 | const zcu = pt.zcu; |
| 13133 | 12927 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -13255,9 +13049,6 @@ fn zirBitwise( |
| 13255 | 13049 | inst: Zir.Inst.Index, |
| 13256 | 13050 | air_tag: Air.Inst.Tag, |
| 13257 | 13051 | ) CompileError!Air.Inst.Ref { |
| 13258 | const tracy = trace(@src()); | |
| 13259 | defer tracy.end(); | |
| 13260 | ||
| 13261 | 13052 | const pt = sema.pt; |
| 13262 | 13053 | const zcu = pt.zcu; |
| 13263 | 13054 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -13438,9 +13229,6 @@ fn analyzeTupleCat( |
| 13438 | 13229 | } |
| 13439 | 13230 | |
| 13440 | 13231 | fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 13441 | const tracy = trace(@src()); | |
| 13442 | defer tracy.end(); | |
| 13443 | ||
| 13444 | 13232 | const pt = sema.pt; |
| 13445 | 13233 | const zcu = pt.zcu; |
| 13446 | 13234 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -13933,9 +13721,6 @@ fn zirArithmetic( |
| 13933 | 13721 | zir_tag: Zir.Inst.Tag, |
| 13934 | 13722 | safety: bool, |
| 13935 | 13723 | ) CompileError!Air.Inst.Ref { |
| 13936 | const tracy = trace(@src()); | |
| 13937 | defer tracy.end(); | |
| 13938 | ||
| 13939 | 13724 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 13940 | 13725 | const src = block.src(.{ .node_offset_bin_op = inst_data.src_node }); |
| 13941 | 13726 | const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node }); |
| ... | ... | @@ -14663,9 +14448,6 @@ fn zirOverflowArithmetic( |
| 14663 | 14448 | extended: Zir.Inst.Extended.InstData, |
| 14664 | 14449 | zir_tag: Zir.Inst.Extended, |
| 14665 | 14450 | ) CompileError!Air.Inst.Ref { |
| 14666 | const tracy = trace(@src()); | |
| 14667 | defer tracy.end(); | |
| 14668 | ||
| 14669 | 14451 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 14670 | 14452 | const src = block.nodeOffset(extra.node); |
| 14671 | 14453 | |
| ... | ... | @@ -15183,9 +14965,6 @@ fn analyzePtrArithmetic( |
| 15183 | 14965 | } |
| 15184 | 14966 | |
| 15185 | 14967 | fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 15186 | const tracy = trace(@src()); | |
| 15187 | defer tracy.end(); | |
| 15188 | ||
| 15189 | 14968 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 15190 | 14969 | const src = block.nodeOffset(inst_data.src_node); |
| 15191 | 14970 | const ptr_src = src; // TODO better source location |
| ... | ... | @@ -15199,9 +14978,6 @@ fn zirAsm( |
| 15199 | 14978 | extended: Zir.Inst.Extended.InstData, |
| 15200 | 14979 | tmpl_is_expr: bool, |
| 15201 | 14980 | ) CompileError!Air.Inst.Ref { |
| 15202 | const tracy = trace(@src()); | |
| 15203 | defer tracy.end(); | |
| 15204 | ||
| 15205 | 14981 | const pt = sema.pt; |
| 15206 | 14982 | const zcu = pt.zcu; |
| 15207 | 14983 | const comp = zcu.comp; |
| ... | ... | @@ -15393,9 +15169,6 @@ fn zirCmpEq( |
| 15393 | 15169 | op: std.math.CompareOperator, |
| 15394 | 15170 | air_tag: Air.Inst.Tag, |
| 15395 | 15171 | ) CompileError!Air.Inst.Ref { |
| 15396 | const tracy = trace(@src()); | |
| 15397 | defer tracy.end(); | |
| 15398 | ||
| 15399 | 15172 | const pt = sema.pt; |
| 15400 | 15173 | const zcu = pt.zcu; |
| 15401 | 15174 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -15509,9 +15282,6 @@ fn zirCmp( |
| 15509 | 15282 | inst: Zir.Inst.Index, |
| 15510 | 15283 | op: std.math.CompareOperator, |
| 15511 | 15284 | ) CompileError!Air.Inst.Ref { |
| 15512 | const tracy = trace(@src()); | |
| 15513 | defer tracy.end(); | |
| 15514 | ||
| 15515 | 15285 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 15516 | 15286 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 15517 | 15287 | const src: LazySrcLoc = block.nodeOffset(inst_data.src_node); |
| ... | ... | @@ -15852,9 +15622,6 @@ fn zirBuiltinSrc( |
| 15852 | 15622 | block: *Block, |
| 15853 | 15623 | extended: Zir.Inst.Extended.InstData, |
| 15854 | 15624 | ) CompileError!Air.Inst.Ref { |
| 15855 | const tracy = trace(@src()); | |
| 15856 | defer tracy.end(); | |
| 15857 | ||
| 15858 | 15625 | const pt = sema.pt; |
| 15859 | 15626 | const zcu = pt.zcu; |
| 15860 | 15627 | const comp = zcu.comp; |
| ... | ... | @@ -17181,9 +16948,6 @@ fn zirTypeofPeer( |
| 17181 | 16948 | extended: Zir.Inst.Extended.InstData, |
| 17182 | 16949 | inst: Zir.Inst.Index, |
| 17183 | 16950 | ) CompileError!Air.Inst.Ref { |
| 17184 | const tracy = trace(@src()); | |
| 17185 | defer tracy.end(); | |
| 17186 | ||
| 17187 | 16951 | const extra = sema.code.extraData(Zir.Inst.TypeOfPeer, extended.operand); |
| 17188 | 16952 | const src = block.nodeOffset(extra.data.src_node); |
| 17189 | 16953 | const body = sema.code.bodySlice(extra.data.body_index, extra.data.body_len); |
| ... | ... | @@ -17249,9 +17013,6 @@ fn zirBoolBr( |
| 17249 | 17013 | inst: Zir.Inst.Index, |
| 17250 | 17014 | is_bool_or: bool, |
| 17251 | 17015 | ) CompileError!Air.Inst.Ref { |
| 17252 | const tracy = trace(@src()); | |
| 17253 | defer tracy.end(); | |
| 17254 | ||
| 17255 | 17016 | const pt = sema.pt; |
| 17256 | 17017 | const zcu = pt.zcu; |
| 17257 | 17018 | const gpa = sema.gpa; |
| ... | ... | @@ -17418,9 +17179,6 @@ fn zirIsNonNull( |
| 17418 | 17179 | block: *Block, |
| 17419 | 17180 | inst: Zir.Inst.Index, |
| 17420 | 17181 | ) CompileError!Air.Inst.Ref { |
| 17421 | const tracy = trace(@src()); | |
| 17422 | defer tracy.end(); | |
| 17423 | ||
| 17424 | 17182 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17425 | 17183 | const src = block.nodeOffset(inst_data.src_node); |
| 17426 | 17184 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -17433,9 +17191,6 @@ fn zirIsNonNullPtr( |
| 17433 | 17191 | block: *Block, |
| 17434 | 17192 | inst: Zir.Inst.Index, |
| 17435 | 17193 | ) CompileError!Air.Inst.Ref { |
| 17436 | const tracy = trace(@src()); | |
| 17437 | defer tracy.end(); | |
| 17438 | ||
| 17439 | 17194 | const pt = sema.pt; |
| 17440 | 17195 | const zcu = pt.zcu; |
| 17441 | 17196 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -17472,9 +17227,6 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 17472 | 17227 | } |
| 17473 | 17228 | |
| 17474 | 17229 | fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 17475 | const tracy = trace(@src()); | |
| 17476 | defer tracy.end(); | |
| 17477 | ||
| 17478 | 17230 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17479 | 17231 | const src = block.nodeOffset(inst_data.src_node); |
| 17480 | 17232 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -17483,9 +17235,6 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17483 | 17235 | } |
| 17484 | 17236 | |
| 17485 | 17237 | fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 17486 | const tracy = trace(@src()); | |
| 17487 | defer tracy.end(); | |
| 17488 | ||
| 17489 | 17238 | const pt = sema.pt; |
| 17490 | 17239 | const zcu = pt.zcu; |
| 17491 | 17240 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -17500,9 +17249,6 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 17500 | 17249 | } |
| 17501 | 17250 | |
| 17502 | 17251 | fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 17503 | const tracy = trace(@src()); | |
| 17504 | defer tracy.end(); | |
| 17505 | ||
| 17506 | 17252 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17507 | 17253 | const src = block.nodeOffset(inst_data.src_node); |
| 17508 | 17254 | const operand = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -17514,9 +17260,6 @@ fn zirCondbr( |
| 17514 | 17260 | parent_block: *Block, |
| 17515 | 17261 | inst: Zir.Inst.Index, |
| 17516 | 17262 | ) CompileError!void { |
| 17517 | const tracy = trace(@src()); | |
| 17518 | defer tracy.end(); | |
| 17519 | ||
| 17520 | 17263 | const pt = sema.pt; |
| 17521 | 17264 | const zcu = pt.zcu; |
| 17522 | 17265 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -17866,9 +17609,6 @@ fn zirRetImplicit( |
| 17866 | 17609 | block: *Block, |
| 17867 | 17610 | inst: Zir.Inst.Index, |
| 17868 | 17611 | ) CompileError!void { |
| 17869 | const tracy = trace(@src()); | |
| 17870 | defer tracy.end(); | |
| 17871 | ||
| 17872 | 17612 | const pt = sema.pt; |
| 17873 | 17613 | const zcu = pt.zcu; |
| 17874 | 17614 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| ... | ... | @@ -17913,9 +17653,6 @@ fn zirRetImplicit( |
| 17913 | 17653 | } |
| 17914 | 17654 | |
| 17915 | 17655 | fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 17916 | const tracy = trace(@src()); | |
| 17917 | defer tracy.end(); | |
| 17918 | ||
| 17919 | 17656 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17920 | 17657 | const operand = sema.resolveInst(inst_data.operand); |
| 17921 | 17658 | const src = block.nodeOffset(inst_data.src_node); |
| ... | ... | @@ -17924,9 +17661,6 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi |
| 17924 | 17661 | } |
| 17925 | 17662 | |
| 17926 | 17663 | fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 17927 | const tracy = trace(@src()); | |
| 17928 | defer tracy.end(); | |
| 17929 | ||
| 17930 | 17664 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17931 | 17665 | const src = block.nodeOffset(inst_data.src_node); |
| 17932 | 17666 | const ret_ptr = sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -18071,9 +17805,6 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, extended: Zir.Inst.Ex |
| 18071 | 17805 | /// its state at the point `block` was reached (or, if `block` is `none`, the |
| 18072 | 17806 | /// point this function began execution). |
| 18073 | 17807 | fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_block: Zir.Inst.Ref, operand_zir: Zir.Inst.Ref) CompileError!void { |
| 18074 | const tracy = trace(@src()); | |
| 18075 | defer tracy.end(); | |
| 18076 | ||
| 18077 | 17808 | const pt = sema.pt; |
| 18078 | 17809 | const zcu = pt.zcu; |
| 18079 | 17810 | |
| ... | ... | @@ -18229,9 +17960,6 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { |
| 18229 | 17960 | } |
| 18230 | 17961 | |
| 18231 | 17962 | fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 18232 | const tracy = trace(@src()); | |
| 18233 | defer tracy.end(); | |
| 18234 | ||
| 18235 | 17963 | const pt = sema.pt; |
| 18236 | 17964 | const zcu = pt.zcu; |
| 18237 | 17965 | const comp = zcu.comp; |
| ... | ... | @@ -18361,9 +18089,6 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18361 | 18089 | } |
| 18362 | 18090 | |
| 18363 | 18091 | fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 18364 | const tracy = trace(@src()); | |
| 18365 | defer tracy.end(); | |
| 18366 | ||
| 18367 | 18092 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 18368 | 18093 | const src = block.nodeOffset(inst_data.src_node); |
| 18369 | 18094 | const ty_src = block.src(.{ .node_offset_init_ty = inst_data.src_node }); |
| ... | ... | @@ -18382,9 +18107,6 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 18382 | 18107 | } |
| 18383 | 18108 | |
| 18384 | 18109 | fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_byref: bool) CompileError!Air.Inst.Ref { |
| 18385 | const tracy = trace(@src()); | |
| 18386 | defer tracy.end(); | |
| 18387 | ||
| 18388 | 18110 | const pt = sema.pt; |
| 18389 | 18111 | const zcu = pt.zcu; |
| 18390 | 18112 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | ... | @@ -19622,9 +19344,6 @@ fn zirUnaryMath( |
| 19622 | 19344 | air_tag: Air.Inst.Tag, |
| 19623 | 19345 | comptime eval: fn (Value, Type, Allocator, Zcu.PerThread) Allocator.Error!Value, |
| 19624 | 19346 | ) CompileError!Air.Inst.Ref { |
| 19625 | const tracy = trace(@src()); | |
| 19626 | defer tracy.end(); | |
| 19627 | ||
| 19628 | 19347 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 19629 | 19348 | const operand = sema.resolveInst(inst_data.operand); |
| 19630 | 19349 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| ... | ... | @@ -23441,9 +23160,6 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23441 | 23160 | } |
| 23442 | 23161 | |
| 23443 | 23162 | fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 23444 | const tracy = trace(@src()); | |
| 23445 | defer tracy.end(); | |
| 23446 | ||
| 23447 | 23163 | const pt = sema.pt; |
| 23448 | 23164 | const zcu = pt.zcu; |
| 23449 | 23165 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | ... | @@ -24489,9 +24205,6 @@ fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 24489 | 24205 | } |
| 24490 | 24206 | |
| 24491 | 24207 | fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 24492 | const tracy = trace(@src()); | |
| 24493 | defer tracy.end(); | |
| 24494 | ||
| 24495 | 24208 | const pt = sema.pt; |
| 24496 | 24209 | const zcu = pt.zcu; |
| 24497 | 24210 | const comp = zcu.comp; |
src/Sema/type_resolution.zig+21| ... | ... | @@ -13,6 +13,7 @@ const LazySrcLoc = Zcu.LazySrcLoc; |
| 13 | 13 | const InternPool = @import("../InternPool.zig"); |
| 14 | 14 | const Alignment = InternPool.Alignment; |
| 15 | 15 | const arith = @import("arith.zig"); |
| 16 | const trace = @import("../tracy.zig").trace; | |
| 16 | 17 | |
| 17 | 18 | pub const LayoutResolveReason = enum { |
| 18 | 19 | variable, |
| ... | ... | @@ -174,6 +175,11 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 174 | 175 | const gpa = comp.gpa; |
| 175 | 176 | const ip = &zcu.intern_pool; |
| 176 | 177 | |
| 178 | const tracy = trace(@src()); | |
| 179 | defer tracy.end(); | |
| 180 | tracy.addText(struct_ty.containerTypeName(ip).toSlice(ip)); | |
| 181 | tracy.addTextFmt("ip_index={d}", .{struct_ty.toIntern()}); | |
| 182 | ||
| 177 | 183 | assert(sema.owner.unwrap().type_layout == struct_ty.toIntern()); |
| 178 | 184 | |
| 179 | 185 | const struct_obj = ip.loadStructType(struct_ty.toIntern()); |
| ... | ... | @@ -548,6 +554,11 @@ pub fn resolveStructDefaults(sema: *Sema, struct_ty: Type) CompileError!void { |
| 548 | 554 | const gpa = comp.gpa; |
| 549 | 555 | const ip = &zcu.intern_pool; |
| 550 | 556 | |
| 557 | const tracy = trace(@src()); | |
| 558 | defer tracy.end(); | |
| 559 | tracy.addText(struct_ty.containerTypeName(ip).toSlice(ip)); | |
| 560 | tracy.addTextFmt("ip_index={d}", .{struct_ty.toIntern()}); | |
| 561 | ||
| 551 | 562 | assert(sema.owner.unwrap().struct_defaults == struct_ty.toIntern()); |
| 552 | 563 | |
| 553 | 564 | // We always depend on the layout of `struct_ty`. However, we don't actually need to resolve it |
| ... | ... | @@ -655,6 +666,11 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { |
| 655 | 666 | const gpa = comp.gpa; |
| 656 | 667 | const ip = &zcu.intern_pool; |
| 657 | 668 | |
| 669 | const tracy = trace(@src()); | |
| 670 | defer tracy.end(); | |
| 671 | tracy.addText(union_ty.containerTypeName(ip).toSlice(ip)); | |
| 672 | tracy.addTextFmt("ip_index={d}", .{union_ty.toIntern()}); | |
| 673 | ||
| 658 | 674 | assert(sema.owner.unwrap().type_layout == union_ty.toIntern()); |
| 659 | 675 | |
| 660 | 676 | const union_obj = ip.loadUnionType(union_ty.toIntern()); |
| ... | ... | @@ -1134,6 +1150,11 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { |
| 1134 | 1150 | const gpa = comp.gpa; |
| 1135 | 1151 | const ip = &zcu.intern_pool; |
| 1136 | 1152 | |
| 1153 | const tracy = trace(@src()); | |
| 1154 | defer tracy.end(); | |
| 1155 | tracy.addText(enum_ty.containerTypeName(ip).toSlice(ip)); | |
| 1156 | tracy.addTextFmt("ip_index={d}", .{enum_ty.toIntern()}); | |
| 1157 | ||
| 1137 | 1158 | assert(sema.owner.unwrap().type_layout == enum_ty.toIntern()); |
| 1138 | 1159 | |
| 1139 | 1160 | const enum_obj = ip.loadEnumType(enum_ty.toIntern()); |
src/Zcu.zig+52-3| ... | ... | @@ -29,7 +29,7 @@ const Package = @import("Package.zig"); |
| 29 | 29 | const link = @import("link.zig"); |
| 30 | 30 | const Air = @import("Air.zig"); |
| 31 | 31 | const Zir = std.zig.Zir; |
| 32 | const trace = @import("tracy.zig").trace; | |
| 32 | const tracy = @import("tracy.zig"); | |
| 33 | 33 | const AstGen = std.zig.AstGen; |
| 34 | 34 | const Sema = @import("Sema.zig"); |
| 35 | 35 | const target_util = @import("target.zig"); |
| ... | ... | @@ -2811,6 +2811,7 @@ pub const CompileError = error{ |
| 2811 | 2811 | |
| 2812 | 2812 | pub fn init(zcu: *Zcu, gpa: Allocator, io: Io, thread_count: usize) !void { |
| 2813 | 2813 | try zcu.intern_pool.init(gpa, io, thread_count); |
| 2814 | zcu.initTracyPlots(); | |
| 2814 | 2815 | } |
| 2815 | 2816 | |
| 2816 | 2817 | pub fn deinit(zcu: *Zcu) void { |
| ... | ... | @@ -3161,12 +3162,15 @@ pub fn markDependeeOutdated( |
| 3161 | 3162 | try zcu.markTransitiveDependersPotentiallyOutdated(depender); |
| 3162 | 3163 | } |
| 3163 | 3164 | } |
| 3165 | ||
| 3166 | zcu.updateTracyOutdatedPlots(); | |
| 3164 | 3167 | } |
| 3165 | 3168 | |
| 3166 | 3169 | pub fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void { |
| 3167 | 3170 | if (std.debug.runtime_safety) zcu.outdated_lock.lockUncancelable(zcu.comp.io); |
| 3168 | 3171 | defer if (std.debug.runtime_safety) zcu.outdated_lock.unlock(zcu.comp.io); |
| 3169 | return markPoDependeeUpToDateInner(zcu, dependee); | |
| 3172 | try markPoDependeeUpToDateInner(zcu, dependee); | |
| 3173 | zcu.updateTracyOutdatedPlots(); | |
| 3170 | 3174 | } |
| 3171 | 3175 | /// Assumes that `zcu.outdated_lock` is already held exclusively. |
| 3172 | 3176 | fn markPoDependeeUpToDateInner(zcu: *Zcu, dependee: InternPool.Dependee) !void { |
| ... | ... | @@ -3304,6 +3308,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?AnalUnit { |
| 3304 | 3308 | // Everything is up-to-date. There could be lingering entries in `zcu.potentially_outdated` |
| 3305 | 3309 | // from a dependency loop on a previous update. |
| 3306 | 3310 | zcu.potentially_outdated.clearRetainingCapacity(); |
| 3311 | zcu.updateTracyOutdatedPlots(); | |
| 3307 | 3312 | log.debug("findOutdatedToAnalyze: all up-to-date", .{}); |
| 3308 | 3313 | return null; |
| 3309 | 3314 | } |
| ... | ... | @@ -3337,6 +3342,7 @@ pub fn flushRetryableFailures(zcu: *Zcu) !void { |
| 3337 | 3342 | try zcu.markTransitiveDependersPotentiallyOutdated(depender); |
| 3338 | 3343 | } |
| 3339 | 3344 | zcu.retryable_failures.clearRetainingCapacity(); |
| 3345 | zcu.updateTracyOutdatedPlots(); | |
| 3340 | 3346 | } |
| 3341 | 3347 | |
| 3342 | 3348 | pub fn mapOldZirToNew( |
| ... | ... | @@ -3580,6 +3586,7 @@ pub fn ensureFuncBodyAnalysisQueued(zcu: *Zcu, func: InternPool.Index) !void { |
| 3580 | 3586 | try zcu.outdated_ready.funcs.ensureUnusedCapacity(gpa, 1); |
| 3581 | 3587 | zcu.outdated.putAssumeCapacityNoClobber(.wrap(.{ .func = func }), 0); |
| 3582 | 3588 | zcu.outdated_ready.funcs.putAssumeCapacityNoClobber(func, {}); |
| 3589 | zcu.updateTracyOutdatedPlots(); | |
| 3583 | 3590 | } |
| 3584 | 3591 | } |
| 3585 | 3592 | |
| ... | ... | @@ -3598,6 +3605,7 @@ pub fn ensureNavValAnalysisQueued(zcu: *Zcu, nav: InternPool.Nav.Index) !void { |
| 3598 | 3605 | zcu.outdated.putAssumeCapacityNoClobber(.wrap(.{ .nav_ty = nav }), 0); |
| 3599 | 3606 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(.wrap(.{ .nav_val = nav }), {}); |
| 3600 | 3607 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(.wrap(.{ .nav_ty = nav }), {}); |
| 3608 | zcu.updateTracyOutdatedPlots(); | |
| 3601 | 3609 | } |
| 3602 | 3610 | } |
| 3603 | 3611 | |
| ... | ... | @@ -3614,6 +3622,7 @@ pub fn queueComptimeUnitAnalysis(zcu: *Zcu, cu: InternPool.ComptimeUnit.Id) Allo |
| 3614 | 3622 | try zcu.outdated_ready.other.ensureUnusedCapacity(gpa, 1); |
| 3615 | 3623 | zcu.outdated.putAssumeCapacityNoClobber(unit, 0); |
| 3616 | 3624 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(unit, {}); |
| 3625 | zcu.updateTracyOutdatedPlots(); | |
| 3617 | 3626 | } |
| 3618 | 3627 | |
| 3619 | 3628 | /// If `unit` was marked as outdated or porentially outdated, clears that status and returns `true`. |
| ... | ... | @@ -3632,8 +3641,10 @@ pub fn clearOutdatedState(zcu: *Zcu, unit: AnalUnit) bool { |
| 3632 | 3641 | } else { |
| 3633 | 3642 | assert(!was_ready); |
| 3634 | 3643 | } |
| 3644 | zcu.updateTracyOutdatedPlots(); | |
| 3635 | 3645 | return true; |
| 3636 | 3646 | } else if (zcu.potentially_outdated.swapRemove(unit)) { |
| 3647 | zcu.updateTracyOutdatedPlots(); | |
| 3637 | 3648 | return true; |
| 3638 | 3649 | } else { |
| 3639 | 3650 | return false; |
| ... | ... | @@ -4164,6 +4175,9 @@ pub fn resolveReferences(zcu: *Zcu) Allocator.Error!*const std.AutoArrayHashMapU |
| 4164 | 4175 | return &zcu.resolved_references.?; |
| 4165 | 4176 | } |
| 4166 | 4177 | fn resolveReferencesInner(zcu: *Zcu) Allocator.Error!std.AutoArrayHashMapUnmanaged(AnalUnit, ?ResolvedReference) { |
| 4178 | const trace = tracy.trace(@src()); | |
| 4179 | defer trace.end(); | |
| 4180 | ||
| 4167 | 4181 | const gpa = zcu.gpa; |
| 4168 | 4182 | const comp = zcu.comp; |
| 4169 | 4183 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -5265,6 +5279,7 @@ pub const CodegenTaskPool = struct { |
| 5265 | 5279 | mir.deinit(zcu); |
| 5266 | 5280 | } |
| 5267 | 5281 | assert(pool.available_air_bytes == max_air_bytes_in_flight); |
| 5282 | zcu.updateTracyPlot("air_bytes_in_flight", 0); | |
| 5268 | 5283 | } |
| 5269 | 5284 | |
| 5270 | 5285 | pub fn start( |
| ... | ... | @@ -5298,6 +5313,12 @@ pub const CodegenTaskPool = struct { |
| 5298 | 5313 | } |
| 5299 | 5314 | |
| 5300 | 5315 | pool.available_air_bytes -= effective_air_bytes; |
| 5316 | ||
| 5317 | zcu.updateTracyPlot("air_bytes_in_flight", @max( | |
| 5318 | max_air_bytes_in_flight - pool.available_air_bytes, | |
| 5319 | actual_air_bytes, | |
| 5320 | )); | |
| 5321 | ||
| 5301 | 5322 | break :index pool.free.pop().?; |
| 5302 | 5323 | }; |
| 5303 | 5324 | |
| ... | ... | @@ -5326,8 +5347,9 @@ pub const CodegenTaskPool = struct { |
| 5326 | 5347 | pub fn wait( |
| 5327 | 5348 | index: Index, |
| 5328 | 5349 | pool: *CodegenTaskPool, |
| 5329 | io: Io, | |
| 5350 | zcu: *const Zcu, | |
| 5330 | 5351 | ) PerThread.RunCodegenError!struct { InternPool.Index, codegen.AnyMir } { |
| 5352 | const io = zcu.comp.io; | |
| 5331 | 5353 | const func = pool.task_funcs[@intFromEnum(index)]; |
| 5332 | 5354 | assert(func != .none); |
| 5333 | 5355 | const effective_air_bytes = pool.task_air_bytes[@intFromEnum(index)]; |
| ... | ... | @@ -5343,6 +5365,7 @@ pub const CodegenTaskPool = struct { |
| 5343 | 5365 | pool.available_air_bytes += effective_air_bytes; |
| 5344 | 5366 | pool.free.appendAssumeCapacity(index); |
| 5345 | 5367 | pool.free_cond.signal(io); |
| 5368 | zcu.updateTracyPlot("air_bytes_in_flight", max_air_bytes_in_flight - pool.available_air_bytes); | |
| 5346 | 5369 | } |
| 5347 | 5370 | |
| 5348 | 5371 | return .{ func, try result }; |
| ... | ... | @@ -5376,3 +5399,29 @@ pub const CodegenTaskPool = struct { |
| 5376 | 5399 | return pt.runCodegen(func_index, air); |
| 5377 | 5400 | } |
| 5378 | 5401 | }; |
| 5402 | ||
| 5403 | fn initTracyPlots(zcu: *const Zcu) void { | |
| 5404 | if (zcu.comp.skip_linker_dependencies) return; | |
| 5405 | ||
| 5406 | tracy.plotConfig("air_bytes_in_flight", .{ .format = .memory, .mode = .step }); | |
| 5407 | ||
| 5408 | tracy.plotConfig("outdated + potentially_outdated", .{ .format = .number, .mode = .step, .color = 0xFFFF00 }); | |
| 5409 | tracy.plotConfig("outdated", .{ .format = .number, .mode = .step, .color = 0xFF0000 }); | |
| 5410 | tracy.plotConfig("potentially_outdated", .{ .format = .number, .mode = .step, .color = 0xFF7700 }); | |
| 5411 | tracy.plotConfig("outdated_ready", .{ .format = .number, .mode = .step, .color = 0x00FF00 }); | |
| 5412 | } | |
| 5413 | ||
| 5414 | /// Marked `inline` to prevent binary bloat from trivial generic instances, and to ensure there is | |
| 5415 | /// minimal overhead to this call when Tracy is disabled, even in Debug builds. | |
| 5416 | inline fn updateTracyPlot(zcu: *const Zcu, comptime name: [*:0]const u8, val: u64) void { | |
| 5417 | if (zcu.comp.skip_linker_dependencies) return; | |
| 5418 | tracy.plotInt(name, @intCast(val)); | |
| 5419 | } | |
| 5420 | ||
| 5421 | /// Assumes that `zcu.outdated_lock` is already held. | |
| 5422 | fn updateTracyOutdatedPlots(zcu: *const Zcu) void { | |
| 5423 | zcu.updateTracyPlot("outdated + potentially_outdated", zcu.outdated.count() + zcu.potentially_outdated.count()); | |
| 5424 | zcu.updateTracyPlot("outdated", zcu.outdated.count()); | |
| 5425 | zcu.updateTracyPlot("potentially_outdated", zcu.potentially_outdated.count()); | |
| 5426 | zcu.updateTracyPlot("outdated_ready", zcu.outdated_ready.funcs.count() + zcu.outdated_ready.other.count()); | |
| 5427 | } |
src/Zcu/PerThread.zig+52-36| ... | ... | @@ -313,18 +313,22 @@ pub fn update( |
| 313 | 313 | // `comptime` declarations, any declarations marked `export`, and `test` declarations in the |
| 314 | 314 | // main module if this is a test compilation---become referenced, and so will be picked up |
| 315 | 315 | // up by the main semantic analysis loop below. |
| 316 | for (zcu.analysisRoots()) |analysis_root_mod| { | |
| 317 | const analysis_root_file = zcu.module_roots.get(analysis_root_mod).?.unwrap().?; | |
| 318 | try pt.ensureFilePopulated(analysis_root_file); | |
| 316 | { | |
| 317 | const tracy_trace = traceNamed(@src(), "populate_sema_roots"); | |
| 318 | defer tracy_trace.end(); | |
| 319 | for (zcu.analysisRoots()) |analysis_root_mod| { | |
| 320 | const analysis_root_file = zcu.module_roots.get(analysis_root_mod).?.unwrap().?; | |
| 321 | try pt.ensureFilePopulated(analysis_root_file); | |
| 322 | } | |
| 319 | 323 | } |
| 320 | 324 | |
| 325 | const tracy_trace = traceNamed(@src(), "sema_loop"); | |
| 326 | defer tracy_trace.end(); | |
| 327 | ||
| 321 | 328 | // This is the main semantic analysis loop, which is essentially the main loop of the whole |
| 322 | 329 | // Zig compilation pipeline. It selects some `AnalUnit` which we know needs to be analyzed, |
| 323 | 330 | // and analyzes it, which may in turn discover more `AnalUnit`s which we need to analyze. |
| 324 | 331 | while (try zcu.findOutdatedToAnalyze()) |unit| { |
| 325 | const tracy_trace = traceNamed(@src(), "analyze_outdated"); | |
| 326 | defer tracy_trace.end(); | |
| 327 | ||
| 328 | 332 | const maybe_err: Zcu.SemaError!void = switch (unit.unwrap()) { |
| 329 | 333 | .@"comptime" => |cu| pt.ensureComptimeUnitUpToDate(cu), |
| 330 | 334 | .nav_ty => |nav| pt.ensureNavTypeUpToDate(nav, null), |
| ... | ... | @@ -823,6 +827,9 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void { |
| 823 | 827 | const gpa = comp.gpa; |
| 824 | 828 | const io = comp.io; |
| 825 | 829 | |
| 830 | const tracy_trace = trace(@src()); | |
| 831 | defer tracy_trace.end(); | |
| 832 | ||
| 826 | 833 | // We need to visit every updated File for every TrackedInst in InternPool. |
| 827 | 834 | // This only includes Zig files; ZON files are omitted. |
| 828 | 835 | var updated_files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, UpdatedFile) = .empty; |
| ... | ... | @@ -1008,9 +1015,6 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void { |
| 1008 | 1015 | pub fn ensureFilePopulated(pt: Zcu.PerThread, file_index: Zcu.File.Index) (Allocator.Error || Io.Cancelable)!void { |
| 1009 | 1016 | dev.check(.sema); |
| 1010 | 1017 | |
| 1011 | const tracy_trace = trace(@src()); | |
| 1012 | defer tracy_trace.end(); | |
| 1013 | ||
| 1014 | 1018 | const zcu = pt.zcu; |
| 1015 | 1019 | const comp = zcu.comp; |
| 1016 | 1020 | const io = comp.io; |
| ... | ... | @@ -1019,6 +1023,9 @@ pub fn ensureFilePopulated(pt: Zcu.PerThread, file_index: Zcu.File.Index) (Alloc |
| 1019 | 1023 | |
| 1020 | 1024 | if (zcu.fileRootType(file_index) != .none) return; // already good |
| 1021 | 1025 | |
| 1026 | const tracy_trace = traceNamed(@src(), "create_file_struct"); | |
| 1027 | defer tracy_trace.end(); | |
| 1028 | ||
| 1022 | 1029 | if (zcu.comp.time_report) |*tr| tr.stats.n_imported_files += 1; |
| 1023 | 1030 | |
| 1024 | 1031 | const file = zcu.fileByIndex(file_index); |
| ... | ... | @@ -1065,9 +1072,6 @@ pub fn ensureMemoizedStateUpToDate( |
| 1065 | 1072 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1066 | 1073 | reason: ?*const Zcu.DependencyReason, |
| 1067 | 1074 | ) Zcu.SemaError!void { |
| 1068 | const tracy_trace = trace(@src()); | |
| 1069 | defer tracy_trace.end(); | |
| 1070 | ||
| 1071 | 1075 | const zcu = pt.zcu; |
| 1072 | 1076 | const gpa = zcu.gpa; |
| 1073 | 1077 | |
| ... | ... | @@ -1142,6 +1146,10 @@ fn analyzeMemoizedState( |
| 1142 | 1146 | |
| 1143 | 1147 | log.debug("analyzeMemoizedState({t})", .{stage}); |
| 1144 | 1148 | |
| 1149 | const tracy_trace = trace(@src()); | |
| 1150 | defer tracy_trace.end(); | |
| 1151 | tracy_trace.addText(@tagName(stage)); | |
| 1152 | ||
| 1145 | 1153 | const unit: AnalUnit = .wrap(.{ .memoized_state = stage }); |
| 1146 | 1154 | |
| 1147 | 1155 | try zcu.analysis_in_progress.putNoClobber(gpa, unit, reason); |
| ... | ... | @@ -1174,9 +1182,6 @@ fn analyzeMemoizedState( |
| 1174 | 1182 | /// if necessary. Returns `error.AnalysisFail` if an analysis error is encountered; the caller is |
| 1175 | 1183 | /// free to ignore this, since the error is already registered. |
| 1176 | 1184 | pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu.SemaError!void { |
| 1177 | const tracy_trace = trace(@src()); | |
| 1178 | defer tracy_trace.end(); | |
| 1179 | ||
| 1180 | 1185 | const zcu = pt.zcu; |
| 1181 | 1186 | const gpa = zcu.gpa; |
| 1182 | 1187 | |
| ... | ... | @@ -1257,6 +1262,10 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu |
| 1257 | 1262 | |
| 1258 | 1263 | log.debug("analyzeComptimeUnit {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1259 | 1264 | |
| 1265 | const tracy_trace = trace(@src()); | |
| 1266 | defer tracy_trace.end(); | |
| 1267 | tracy_trace.addTextFmt("cu_id={d}", .{cu_id}); | |
| 1268 | ||
| 1260 | 1269 | const inst_resolved = comptime_unit.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1261 | 1270 | const file = zcu.fileByIndex(inst_resolved.file); |
| 1262 | 1271 | const zir = file.zir.?; |
| ... | ... | @@ -1333,9 +1342,6 @@ pub fn ensureTypeLayoutUpToDate( |
| 1333 | 1342 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1334 | 1343 | reason: ?*const Zcu.DependencyReason, |
| 1335 | 1344 | ) Zcu.SemaError!void { |
| 1336 | const tracy_trace = trace(@src()); | |
| 1337 | defer tracy_trace.end(); | |
| 1338 | ||
| 1339 | 1345 | const zcu = pt.zcu; |
| 1340 | 1346 | const ip = &zcu.intern_pool; |
| 1341 | 1347 | const comp = zcu.comp; |
| ... | ... | @@ -1464,9 +1470,6 @@ pub fn ensureStructDefaultsUpToDate( |
| 1464 | 1470 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1465 | 1471 | reason: ?*const Zcu.DependencyReason, |
| 1466 | 1472 | ) Zcu.SemaError!void { |
| 1467 | const tracy_trace = trace(@src()); | |
| 1468 | defer tracy_trace.end(); | |
| 1469 | ||
| 1470 | 1473 | const zcu = pt.zcu; |
| 1471 | 1474 | const ip = &zcu.intern_pool; |
| 1472 | 1475 | const comp = zcu.comp; |
| ... | ... | @@ -1572,9 +1575,6 @@ pub fn ensureNavValUpToDate( |
| 1572 | 1575 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1573 | 1576 | reason: ?*const Zcu.DependencyReason, |
| 1574 | 1577 | ) Zcu.SemaError!void { |
| 1575 | const tracy_trace = trace(@src()); | |
| 1576 | defer tracy_trace.end(); | |
| 1577 | ||
| 1578 | 1578 | const zcu = pt.zcu; |
| 1579 | 1579 | const gpa = zcu.gpa; |
| 1580 | 1580 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -1677,6 +1677,11 @@ fn analyzeNavVal( |
| 1677 | 1677 | |
| 1678 | 1678 | log.debug("analyzeNavVal {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1679 | 1679 | |
| 1680 | const tracy_trace = trace(@src()); | |
| 1681 | defer tracy_trace.end(); | |
| 1682 | tracy_trace.addText(old_nav.fqn.toSlice(ip)); | |
| 1683 | tracy_trace.addTextFmt("nav_id={d}", .{nav_id}); | |
| 1684 | ||
| 1680 | 1685 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1681 | 1686 | const file = zcu.fileByIndex(inst_resolved.file); |
| 1682 | 1687 | const zir = file.zir.?; |
| ... | ... | @@ -1939,9 +1944,6 @@ pub fn ensureNavTypeUpToDate( |
| 1939 | 1944 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1940 | 1945 | reason: ?*const Zcu.DependencyReason, |
| 1941 | 1946 | ) Zcu.SemaError!void { |
| 1942 | const tracy_trace = trace(@src()); | |
| 1943 | defer tracy_trace.end(); | |
| 1944 | ||
| 1945 | 1947 | const zcu = pt.zcu; |
| 1946 | 1948 | const gpa = zcu.gpa; |
| 1947 | 1949 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -2044,6 +2046,11 @@ fn analyzeNavType( |
| 2044 | 2046 | |
| 2045 | 2047 | log.debug("analyzeNavType {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 2046 | 2048 | |
| 2049 | const tracy_trace = trace(@src()); | |
| 2050 | defer tracy_trace.end(); | |
| 2051 | tracy_trace.addText(old_nav.fqn.toSlice(ip)); | |
| 2052 | tracy_trace.addTextFmt("nav_id={d}", .{nav_id}); | |
| 2053 | ||
| 2047 | 2054 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 2048 | 2055 | const file = zcu.fileByIndex(inst_resolved.file); |
| 2049 | 2056 | const zir = file.zir.?; |
| ... | ... | @@ -2183,9 +2190,6 @@ pub fn ensureFuncBodyUpToDate( |
| 2183 | 2190 | ) Zcu.SemaError!void { |
| 2184 | 2191 | dev.check(.sema); |
| 2185 | 2192 | |
| 2186 | const tracy_trace = trace(@src()); | |
| 2187 | defer tracy_trace.end(); | |
| 2188 | ||
| 2189 | 2193 | const zcu = pt.zcu; |
| 2190 | 2194 | const gpa = zcu.gpa; |
| 2191 | 2195 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -2283,6 +2287,11 @@ fn analyzeFuncBody( |
| 2283 | 2287 | |
| 2284 | 2288 | log.debug("analyzeFuncBody {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 2285 | 2289 | |
| 2290 | const tracy_trace = trace(@src()); | |
| 2291 | defer tracy_trace.end(); | |
| 2292 | tracy_trace.addText(ip.getNav(func.owner_nav).fqn.toSlice(ip)); | |
| 2293 | tracy_trace.addTextFmt("func_ip_index={d}", .{func_index}); | |
| 2294 | ||
| 2286 | 2295 | var air = try pt.analyzeFuncBodyInner(func_index, reason); |
| 2287 | 2296 | var air_owned = true; |
| 2288 | 2297 | defer if (air_owned) air.deinit(gpa); |
| ... | ... | @@ -2592,6 +2601,9 @@ fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool { |
| 2592 | 2601 | const comp = zcu.comp; |
| 2593 | 2602 | const gpa = zcu.gpa; |
| 2594 | 2603 | |
| 2604 | const tracy_trace = trace(@src()); | |
| 2605 | defer tracy_trace.end(); | |
| 2606 | ||
| 2595 | 2607 | var any_fatal_files = false; |
| 2596 | 2608 | zcu.multi_module_err = null; |
| 2597 | 2609 | zcu.failed_imports.clearRetainingCapacity(); |
| ... | ... | @@ -3028,14 +3040,16 @@ pub fn scanNamespace( |
| 3028 | 3040 | namespace_index: Zcu.Namespace.Index, |
| 3029 | 3041 | decls: []const Zir.Inst.Index, |
| 3030 | 3042 | ) Allocator.Error!void { |
| 3031 | const tracy_trace = trace(@src()); | |
| 3032 | defer tracy_trace.end(); | |
| 3033 | ||
| 3034 | 3043 | const zcu = pt.zcu; |
| 3035 | 3044 | const ip = &zcu.intern_pool; |
| 3036 | 3045 | const gpa = zcu.gpa; |
| 3037 | 3046 | const namespace = zcu.namespacePtr(namespace_index); |
| 3038 | 3047 | |
| 3048 | const tracy_trace = trace(@src()); | |
| 3049 | defer tracy_trace.end(); | |
| 3050 | tracy_trace.addText(Type.fromInterned(namespace.owner_type).containerTypeName(ip).toSlice(ip)); | |
| 3051 | tracy_trace.addTextFmt("type_ip_index={d}", .{namespace.owner_type}); | |
| 3052 | ||
| 3039 | 3053 | const tracked_unit = zcu.trackUnitSema( |
| 3040 | 3054 | Type.fromInterned(namespace.owner_type).containerTypeName(ip).toSlice(ip), |
| 3041 | 3055 | null, |
| ... | ... | @@ -3247,9 +3261,6 @@ fn analyzeFuncBodyInner( |
| 3247 | 3261 | func_index: InternPool.Index, |
| 3248 | 3262 | reason: ?*const Zcu.DependencyReason, |
| 3249 | 3263 | ) Zcu.SemaError!Air { |
| 3250 | const tracy_trace = trace(@src()); | |
| 3251 | defer tracy_trace.end(); | |
| 3252 | ||
| 3253 | 3264 | const zcu = pt.zcu; |
| 3254 | 3265 | const comp = zcu.comp; |
| 3255 | 3266 | const gpa = comp.gpa; |
| ... | ... | @@ -4556,6 +4567,11 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4556 | 4567 | const codegen_prog_node = zcu.codegen_prog_node.start(fqn.toSlice(ip), 0); |
| 4557 | 4568 | defer codegen_prog_node.end(); |
| 4558 | 4569 | |
| 4570 | const tracy_trace = trace(@src()); | |
| 4571 | defer tracy_trace.end(); | |
| 4572 | tracy_trace.addText(fqn.toSlice(ip)); | |
| 4573 | tracy_trace.addTextFmt("func_ip_index={d}", .{func_index}); | |
| 4574 | ||
| 4559 | 4575 | if (codegen.legalizeFeatures(pt, nav)) |features| { |
| 4560 | 4576 | try air.legalize(pt, features); |
| 4561 | 4577 | } |
src/codegen.zig+7| ... | ... | @@ -186,6 +186,12 @@ pub fn emitFunction( |
| 186 | 186 | const zcu = pt.zcu; |
| 187 | 187 | const func = zcu.funcInfo(func_index); |
| 188 | 188 | const target = &zcu.navFileScope(func.owner_nav).mod.?.resolved_target.result; |
| 189 | ||
| 190 | const tracy_trace = trace(@src()); | |
| 191 | defer tracy_trace.end(); | |
| 192 | tracy_trace.addText(zcu.intern_pool.getNav(func.owner_nav).fqn.toSlice(&zcu.intern_pool)); | |
| 193 | tracy_trace.addTextFmt("func_ip_index={d}", .{func_index}); | |
| 194 | ||
| 189 | 195 | switch (target_util.zigBackend(target, zcu.comp.config.use_llvm)) { |
| 190 | 196 | else => unreachable, |
| 191 | 197 | inline .stage2_aarch64, |
| ... | ... | @@ -236,6 +242,7 @@ pub fn generateLazySymbol( |
| 236 | 242 | ) (CodeGenError || std.Io.Writer.Error)!void { |
| 237 | 243 | const tracy = trace(@src()); |
| 238 | 244 | defer tracy.end(); |
| 245 | tracy.addTextFmt("{t}, {f}", .{ lazy_sym.kind, Type.fromInterned(lazy_sym.ty).fmt(pt) }); | |
| 239 | 246 | |
| 240 | 247 | const comp = bin_file.comp; |
| 241 | 248 | const zcu = pt.zcu; |
src/link.zig+1-1| ... | ... | @@ -1573,7 +1573,7 @@ pub fn doZcuTask(comp: *Compilation, tid: Zcu.PerThread.Id, task: ZcuTask) void |
| 1573 | 1573 | }, |
| 1574 | 1574 | .link_func => |codegen_task| nav: { |
| 1575 | 1575 | timer.pause(io); |
| 1576 | const func, var mir = codegen_task.wait(&zcu.codegen_task_pool, io) catch |err| switch (err) { | |
| 1576 | const func, var mir = codegen_task.wait(&zcu.codegen_task_pool, zcu) catch |err| switch (err) { | |
| 1577 | 1577 | error.Canceled, error.AlreadyReported => { |
| 1578 | 1578 | comp.link_prog_node.completeOne(); |
| 1579 | 1579 | return; |
src/link/Elf2.zig+5| ... | ... | @@ -14,6 +14,7 @@ const InternPool = @import("../InternPool.zig"); |
| 14 | 14 | const link = @import("../link.zig"); |
| 15 | 15 | const MappedFile = @import("MappedFile.zig"); |
| 16 | 16 | const target_util = @import("../target.zig"); |
| 17 | const tracy = @import("../tracy.zig"); | |
| 17 | 18 | const Type = @import("../Type.zig"); |
| 18 | 19 | const Value = @import("../Value.zig"); |
| 19 | 20 | const Zcu = @import("../Zcu.zig"); |
| ... | ... | @@ -5865,6 +5866,8 @@ fn flushFileOffset(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 5865 | 5866 | } |
| 5866 | 5867 | |
| 5867 | 5868 | fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 5869 | const trace = tracy.trace(@src()); | |
| 5870 | defer trace.end(); | |
| 5868 | 5871 | switch (elf.getNode(ni)) { |
| 5869 | 5872 | .file => unreachable, |
| 5870 | 5873 | .ehdr, .shdr => try elf.flushFileOffset(ni), |
| ... | ... | @@ -6019,6 +6022,8 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 6019 | 6022 | } |
| 6020 | 6023 | |
| 6021 | 6024 | fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 6025 | const trace = tracy.trace(@src()); | |
| 6026 | defer trace.end(); | |
| 6022 | 6027 | _, const size = ni.location(&elf.mf).resolve(&elf.mf); |
| 6023 | 6028 | switch (elf.getNode(ni)) { |
| 6024 | 6029 | .file => {}, |
src/main.zig+2-4| ... | ... | @@ -218,8 +218,8 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void { |
| 218 | 218 | var environ_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err}); |
| 219 | 219 | |
| 220 | 220 | if (tracy.enable_allocation) { |
| 221 | var gpa_tracy = tracy.tracyAllocator(gpa); | |
| 222 | return mainArgs(gpa_tracy.allocator(), arena, io, args, &environ_map); | |
| 221 | var tracy_allocator: tracy.Allocator = .{ .parent_allocator = gpa }; | |
| 222 | return mainArgs(tracy_allocator.interface(), arena, io, args, &environ_map); | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if (native_os == .wasi) { |
| ... | ... | @@ -4239,7 +4239,6 @@ fn serve( |
| 4239 | 4239 | switch (hdr.tag) { |
| 4240 | 4240 | .exit => return cleanExit(io), |
| 4241 | 4241 | .update => { |
| 4242 | tracy.frameMark(); | |
| 4243 | 4242 | file_system_inputs.clearRetainingCapacity(); |
| 4244 | 4243 | |
| 4245 | 4244 | if (arg_mode == .translate_c) { |
| ... | ... | @@ -4296,7 +4295,6 @@ fn serve( |
| 4296 | 4295 | //); |
| 4297 | 4296 | }, |
| 4298 | 4297 | .hot_update => { |
| 4299 | tracy.frameMark(); | |
| 4300 | 4298 | file_system_inputs.clearRetainingCapacity(); |
| 4301 | 4299 | if (child_pid) |pid| { |
| 4302 | 4300 | try comp.hotCodeSwap(main_progress_node, pid); |
src/tracy.zig+133-176| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const assert = std.debug.assert; | |
| 3 | ||
| 2 | 4 | const builtin = @import("builtin"); |
| 3 | 5 | const build_options = @import("build_options"); |
| 4 | 6 | |
| 5 | 7 | pub const enable = if (builtin.is_test) false else build_options.enable_tracy; |
| 6 | 8 | pub const enable_allocation = enable and build_options.enable_tracy_allocation; |
| 7 | 9 | pub const enable_callstack = enable and build_options.enable_tracy_callstack; |
| 8 | pub const callstack_depth = if (enable_callstack and build_options.tracy_callstack_depth > 0) build_options.tracy_callstack_depth else 10; | |
| 10 | pub const callstack_depth = if (enable_callstack) build_options.tracy_callstack_depth else 0; | |
| 9 | 11 | |
| 10 | 12 | const ___tracy_c_zone_context = extern struct { |
| 11 | 13 | id: u32, |
| ... | ... | @@ -19,6 +21,12 @@ const ___tracy_c_zone_context = extern struct { |
| 19 | 21 | ___tracy_emit_zone_text(self, text.ptr, text.len); |
| 20 | 22 | } |
| 21 | 23 | |
| 24 | pub inline fn addTextFmt(self: @This(), comptime fmt: []const u8, args: anytype) void { | |
| 25 | var buf: [512]u8 = undefined; | |
| 26 | const slice = std.fmt.bufPrint(&buf, fmt, args) catch &buf; | |
| 27 | self.addText(slice); | |
| 28 | } | |
| 29 | ||
| 22 | 30 | pub inline fn setName(self: @This(), name: []const u8) void { |
| 23 | 31 | ___tracy_emit_zone_name(self, name.ptr, name.len); |
| 24 | 32 | } |
| ... | ... | @@ -42,6 +50,12 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct { |
| 42 | 50 | _ = text; |
| 43 | 51 | } |
| 44 | 52 | |
| 53 | pub inline fn addTextFmt(self: @This(), comptime fmt: []const u8, args: anytype) void { | |
| 54 | _ = self; | |
| 55 | _ = fmt; | |
| 56 | _ = args; | |
| 57 | } | |
| 58 | ||
| 45 | 59 | pub inline fn setName(self: @This(), name: []const u8) void { |
| 46 | 60 | _ = self; |
| 47 | 61 | _ = name; |
| ... | ... | @@ -71,11 +85,7 @@ pub inline fn trace(comptime src: std.lang.SourceLocation) Ctx { |
| 71 | 85 | }; |
| 72 | 86 | }; |
| 73 | 87 | |
| 74 | if (enable_callstack) { | |
| 75 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); | |
| 76 | } else { | |
| 77 | return ___tracy_emit_zone_begin(&global.loc, 1); | |
| 78 | } | |
| 88 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); | |
| 79 | 89 | } |
| 80 | 90 | |
| 81 | 91 | pub inline fn traceNamed(comptime src: std.lang.SourceLocation, comptime name: [:0]const u8) Ctx { |
| ... | ... | @@ -91,11 +101,7 @@ pub inline fn traceNamed(comptime src: std.lang.SourceLocation, comptime name: [ |
| 91 | 101 | }; |
| 92 | 102 | }; |
| 93 | 103 | |
| 94 | if (enable_callstack) { | |
| 95 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); | |
| 96 | } else { | |
| 97 | return ___tracy_emit_zone_begin(&global.loc, 1); | |
| 98 | } | |
| 104 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); | |
| 99 | 105 | } |
| 100 | 106 | |
| 101 | 107 | pub inline fn fiberEnter(fiber: [*:0]const u8) void { |
| ... | ... | @@ -108,102 +114,93 @@ pub inline fn fiberLeave() void { |
| 108 | 114 | ___tracy_fiber_leave(); |
| 109 | 115 | } |
| 110 | 116 | |
| 111 | pub fn tracyAllocator(allocator: std.mem.Allocator) TracyAllocator(null) { | |
| 112 | return TracyAllocator(null).init(allocator); | |
| 117 | pub inline fn plotConfig(comptime name: [*:0]const u8, config: PlotConfig) void { | |
| 118 | if (!enable) return; | |
| 119 | ___tracy_emit_plot_config( | |
| 120 | name, | |
| 121 | config.format, | |
| 122 | config.mode, | |
| 123 | @intFromBool(config.fill), | |
| 124 | // https://github.com/wolfpld/tracy/issues/1232 | |
| 125 | @byteSwap(config.color), | |
| 126 | ); | |
| 113 | 127 | } |
| 114 | 128 | |
| 115 | pub fn TracyAllocator(comptime name: ?[:0]const u8) type { | |
| 116 | return struct { | |
| 117 | parent_allocator: std.mem.Allocator, | |
| 129 | pub inline fn plotInt(comptime name: [*:0]const u8, val: i64) void { | |
| 130 | if (!enable) return; | |
| 131 | ___tracy_emit_plot_int(name, val); | |
| 132 | } | |
| 118 | 133 | |
| 119 | const Self = @This(); | |
| 134 | pub const Allocator = struct { | |
| 135 | parent_allocator: std.mem.Allocator, | |
| 120 | 136 | |
| 121 | pub fn init(parent_allocator: std.mem.Allocator) Self { | |
| 122 | return .{ | |
| 123 | .parent_allocator = parent_allocator, | |
| 124 | }; | |
| 125 | } | |
| 137 | comptime { | |
| 138 | assert(enable); // used `tracy.Allocator` with Tracy disabled | |
| 139 | } | |
| 126 | 140 | |
| 127 | pub fn allocator(self: *Self) std.mem.Allocator { | |
| 128 | return .{ | |
| 129 | .ptr = self, | |
| 130 | .vtable = &.{ | |
| 131 | .alloc = allocFn, | |
| 132 | .resize = resizeFn, | |
| 133 | .remap = remapFn, | |
| 134 | .free = freeFn, | |
| 135 | }, | |
| 136 | }; | |
| 137 | } | |
| 141 | pub fn interface(self: *Allocator) std.mem.Allocator { | |
| 142 | return .{ | |
| 143 | .ptr = self, | |
| 144 | .vtable = &.{ | |
| 145 | .alloc = allocFn, | |
| 146 | .resize = resizeFn, | |
| 147 | .remap = remapFn, | |
| 148 | .free = freeFn, | |
| 149 | }, | |
| 150 | }; | |
| 151 | } | |
| 138 | 152 | |
| 139 | fn allocFn(ptr: *anyopaque, len: usize, alignment: std.mem.Alignment, ret_addr: usize) ?[*]u8 { | |
| 140 | const self: *Self = @ptrCast(@alignCast(ptr)); | |
| 141 | const result = self.parent_allocator.rawAlloc(len, alignment, ret_addr); | |
| 142 | if (result) |memory| { | |
| 143 | if (len != 0) { | |
| 144 | if (name) |n| { | |
| 145 | allocNamed(memory, len, n); | |
| 146 | } else { | |
| 147 | alloc(memory, len); | |
| 148 | } | |
| 149 | } | |
| 150 | } else { | |
| 151 | messageColor("allocation failed", 0xFF0000); | |
| 152 | } | |
| 153 | return result; | |
| 153 | fn allocFn(ptr: *anyopaque, len: usize, alignment: std.mem.Alignment, ret_addr: usize) ?[*]u8 { | |
| 154 | const self: *Allocator = @ptrCast(@alignCast(ptr)); | |
| 155 | assert(len > 0); | |
| 156 | if (self.parent_allocator.rawAlloc(len, alignment, ret_addr)) |memory| { | |
| 157 | ___tracy_emit_memory_alloc_callstack(memory, len, callstack_depth, 0); | |
| 158 | return memory; | |
| 159 | } else { | |
| 160 | messageColor("allocation failed", 0xFF0000); | |
| 161 | return null; | |
| 154 | 162 | } |
| 163 | } | |
| 155 | 164 | |
| 156 | fn resizeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) bool { | |
| 157 | const self: *Self = @ptrCast(@alignCast(ptr)); | |
| 158 | if (self.parent_allocator.rawResize(memory, alignment, new_len, ret_addr)) { | |
| 159 | if (name) |n| { | |
| 160 | freeNamed(memory.ptr, n); | |
| 161 | allocNamed(memory.ptr, new_len, n); | |
| 162 | } else { | |
| 163 | free(memory.ptr); | |
| 164 | alloc(memory.ptr, new_len); | |
| 165 | } | |
| 166 | ||
| 167 | return true; | |
| 168 | } | |
| 169 | ||
| 170 | // during normal operation the compiler hits this case thousands of times due to this | |
| 171 | // emitting messages for it is both slow and causes clutter | |
| 165 | fn resizeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) bool { | |
| 166 | const self: *Allocator = @ptrCast(@alignCast(ptr)); | |
| 167 | assert(memory.len > 0); | |
| 168 | assert(new_len > 0); | |
| 169 | // We need to mark the free before calling the implementation to avoid a race. | |
| 170 | ___tracy_emit_memory_free_callstack(memory.ptr, callstack_depth, 0); | |
| 171 | if (self.parent_allocator.rawResize(memory, alignment, new_len, ret_addr)) { | |
| 172 | ___tracy_emit_memory_alloc_callstack(memory.ptr, new_len, callstack_depth, 0); | |
| 173 | return true; | |
| 174 | } else { | |
| 175 | // No `messageColor` call here because this case is hit frequently in normal operation. | |
| 176 | ___tracy_emit_memory_alloc_callstack(memory.ptr, memory.len, callstack_depth, 0); | |
| 172 | 177 | return false; |
| 173 | 178 | } |
| 179 | } | |
| 174 | 180 | |
| 175 | fn remapFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 { | |
| 176 | const self: *Self = @ptrCast(@alignCast(ptr)); | |
| 177 | if (self.parent_allocator.rawRemap(memory, alignment, new_len, ret_addr)) |new_memory| { | |
| 178 | if (name) |n| { | |
| 179 | freeNamed(memory.ptr, n); | |
| 180 | allocNamed(new_memory, new_len, n); | |
| 181 | } else { | |
| 182 | free(memory.ptr); | |
| 183 | alloc(new_memory, new_len); | |
| 184 | } | |
| 185 | return new_memory; | |
| 186 | } else { | |
| 187 | messageColor("reallocation failed", 0xFF0000); | |
| 188 | return null; | |
| 189 | } | |
| 181 | fn remapFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 { | |
| 182 | const self: *Allocator = @ptrCast(@alignCast(ptr)); | |
| 183 | assert(memory.len > 0); | |
| 184 | assert(new_len > 0); | |
| 185 | // We need to mark the free before calling the implementation to avoid a race. | |
| 186 | ___tracy_emit_memory_free_callstack(memory.ptr, callstack_depth, 0); | |
| 187 | if (self.parent_allocator.rawRemap(memory, alignment, new_len, ret_addr)) |new_memory| { | |
| 188 | ___tracy_emit_memory_alloc_callstack(new_memory, new_len, callstack_depth, 0); | |
| 189 | return new_memory; | |
| 190 | } else { | |
| 191 | // No `messageColor` call here because this case is hit frequently in normal operation. | |
| 192 | ___tracy_emit_memory_alloc_callstack(memory.ptr, memory.len, callstack_depth, 0); | |
| 193 | return null; | |
| 190 | 194 | } |
| 195 | } | |
| 191 | 196 | |
| 192 | fn freeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, ret_addr: usize) void { | |
| 193 | const self: *Self = @ptrCast(@alignCast(ptr)); | |
| 194 | self.parent_allocator.rawFree(memory, alignment, ret_addr); | |
| 195 | // this condition is to handle free being called on an empty slice that was never even allocated | |
| 196 | // example case: `std.process.getSelfExeSharedLibPaths` can return `&[_][:0]u8{}` | |
| 197 | if (memory.len != 0) { | |
| 198 | if (name) |n| { | |
| 199 | freeNamed(memory.ptr, n); | |
| 200 | } else { | |
| 201 | free(memory.ptr); | |
| 202 | } | |
| 203 | } | |
| 204 | } | |
| 205 | }; | |
| 206 | } | |
| 197 | fn freeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, ret_addr: usize) void { | |
| 198 | const self: *Allocator = @ptrCast(@alignCast(ptr)); | |
| 199 | assert(memory.len > 0); | |
| 200 | ___tracy_emit_memory_free_callstack(memory.ptr, callstack_depth, 0); | |
| 201 | self.parent_allocator.rawFree(memory, alignment, ret_addr); | |
| 202 | } | |
| 203 | }; | |
| 207 | 204 | |
| 208 | 205 | // This function only accepts comptime-known strings, see `messageCopy` for runtime strings |
| 209 | 206 | pub inline fn message(comptime msg: [:0]const u8) void { |
| ... | ... | @@ -213,7 +210,7 @@ pub inline fn message(comptime msg: [:0]const u8) void { |
| 213 | 210 | // This function only accepts comptime-known strings, see `messageColorCopy` for runtime strings |
| 214 | 211 | pub inline fn messageColor(comptime msg: [:0]const u8, color: u24) void { |
| 215 | 212 | if (!enable) return; |
| 216 | ___tracy_emit_logStringL(.Info, color, if (enable_callstack) callstack_depth else 0, msg.ptr); | |
| 213 | ___tracy_emit_logStringL(.Info, color, callstack_depth, msg.ptr); | |
| 217 | 214 | } |
| 218 | 215 | |
| 219 | 216 | pub inline fn messageCopy(msg: []const u8) void { |
| ... | ... | @@ -222,84 +219,29 @@ pub inline fn messageCopy(msg: []const u8) void { |
| 222 | 219 | |
| 223 | 220 | pub inline fn messageColorCopy(msg: []const u8, color: u24) void { |
| 224 | 221 | if (!enable) return; |
| 225 | ___tracy_emit_logString(.Info, color, if (enable_callstack) callstack_depth else 0, msg.len, msg.ptr); | |
| 222 | ___tracy_emit_logString(.Info, color, callstack_depth, msg.len, msg.ptr); | |
| 226 | 223 | } |
| 227 | 224 | |
| 228 | pub inline fn frameMark() void { | |
| 229 | if (!enable) return; | |
| 230 | ___tracy_emit_frame_mark(null); | |
| 225 | /// Used to store strings which Tracy requires to have stable pointers for the program's entire | |
| 226 | /// lifetime. All such strings will be leaked. | |
| 227 | /// | |
| 228 | /// The `enable` check ensures that this is not referenced if Tracy is disabled. | |
| 229 | var tracy_arena: std.heap.ArenaAllocator = if (enable) .init(std.heap.page_allocator); | |
| 230 | ||
| 231 | pub inline fn namedFrame(name: []const u8) Frame { | |
| 232 | if (!enable) return .{ .name = {} }; | |
| 233 | const stable_name = tracy_arena.allocator().dupeSentinel(u8, name, 0) catch @panic("tracy arena OOM"); | |
| 234 | ___tracy_emit_frame_mark_start(stable_name.ptr); | |
| 235 | return .{ .name = stable_name.ptr }; | |
| 231 | 236 | } |
| 232 | 237 | |
| 233 | pub inline fn frameMarkNamed(comptime name: [:0]const u8) void { | |
| 234 | if (!enable) return; | |
| 235 | ___tracy_emit_frame_mark(name.ptr); | |
| 236 | } | |
| 237 | ||
| 238 | pub inline fn namedFrame(comptime name: [:0]const u8) Frame(name) { | |
| 239 | frameMarkStart(name); | |
| 240 | return .{}; | |
| 241 | } | |
| 242 | ||
| 243 | pub fn Frame(comptime name: [:0]const u8) type { | |
| 244 | return struct { | |
| 245 | pub fn end(_: @This()) void { | |
| 246 | frameMarkEnd(name); | |
| 247 | } | |
| 248 | }; | |
| 249 | } | |
| 250 | ||
| 251 | inline fn frameMarkStart(comptime name: [:0]const u8) void { | |
| 252 | if (!enable) return; | |
| 253 | ___tracy_emit_frame_mark_start(name.ptr); | |
| 254 | } | |
| 255 | ||
| 256 | inline fn frameMarkEnd(comptime name: [:0]const u8) void { | |
| 257 | if (!enable) return; | |
| 258 | ___tracy_emit_frame_mark_end(name.ptr); | |
| 259 | } | |
| 260 | ||
| 261 | extern fn ___tracy_emit_frame_mark_start(name: [*:0]const u8) void; | |
| 262 | extern fn ___tracy_emit_frame_mark_end(name: [*:0]const u8) void; | |
| 263 | ||
| 264 | inline fn alloc(ptr: [*]u8, len: usize) void { | |
| 265 | if (!enable) return; | |
| 266 | ||
| 267 | if (enable_callstack) { | |
| 268 | ___tracy_emit_memory_alloc_callstack(ptr, len, callstack_depth, 0); | |
| 269 | } else { | |
| 270 | ___tracy_emit_memory_alloc(ptr, len, 0); | |
| 271 | } | |
| 272 | } | |
| 273 | ||
| 274 | inline fn allocNamed(ptr: [*]u8, len: usize, comptime name: [:0]const u8) void { | |
| 275 | if (!enable) return; | |
| 276 | ||
| 277 | if (enable_callstack) { | |
| 278 | ___tracy_emit_memory_alloc_callstack_named(ptr, len, callstack_depth, 0, name.ptr); | |
| 279 | } else { | |
| 280 | ___tracy_emit_memory_alloc_named(ptr, len, 0, name.ptr); | |
| 281 | } | |
| 282 | } | |
| 283 | ||
| 284 | inline fn free(ptr: [*]u8) void { | |
| 285 | if (!enable) return; | |
| 286 | ||
| 287 | if (enable_callstack) { | |
| 288 | ___tracy_emit_memory_free_callstack(ptr, callstack_depth, 0); | |
| 289 | } else { | |
| 290 | ___tracy_emit_memory_free(ptr, 0); | |
| 238 | pub const Frame = struct { | |
| 239 | name: if (enable) [*:0]const u8 else void, | |
| 240 | pub inline fn end(frame: Frame) void { | |
| 241 | if (!enable) return; | |
| 242 | ___tracy_emit_frame_mark_end(frame.name); | |
| 291 | 243 | } |
| 292 | } | |
| 293 | ||
| 294 | inline fn freeNamed(ptr: [*]u8, comptime name: [:0]const u8) void { | |
| 295 | if (!enable) return; | |
| 296 | ||
| 297 | if (enable_callstack) { | |
| 298 | ___tracy_emit_memory_free_callstack_named(ptr, callstack_depth, 0, name.ptr); | |
| 299 | } else { | |
| 300 | ___tracy_emit_memory_free_named(ptr, 0, name.ptr); | |
| 301 | } | |
| 302 | } | |
| 244 | }; | |
| 303 | 245 | |
| 304 | 246 | pub const MessageSeverity = enum(i8) { |
| 305 | 247 | Trace, // Broadly track variable states and events in the software program. |
| ... | ... | @@ -310,24 +252,39 @@ pub const MessageSeverity = enum(i8) { |
| 310 | 252 | Fatal, // Describes a critical event that will lead to a software failure/crash. |
| 311 | 253 | }; |
| 312 | 254 | |
| 313 | extern fn ___tracy_emit_zone_begin(srcloc: *const ___tracy_source_location_data, active: i32) ___tracy_c_zone_context; | |
| 255 | pub const PlotConfig = struct { | |
| 256 | format: Format, | |
| 257 | mode: Mode, | |
| 258 | fill: bool = true, | |
| 259 | color: u24 = 0, | |
| 260 | ||
| 261 | pub const Format = enum(i32) { | |
| 262 | number = 0, | |
| 263 | memory = 1, | |
| 264 | percentage = 2, | |
| 265 | watt = 3, | |
| 266 | }; | |
| 267 | ||
| 268 | pub const Mode = enum(i32) { | |
| 269 | line = 0, | |
| 270 | step = 1, | |
| 271 | }; | |
| 272 | }; | |
| 273 | ||
| 274 | extern fn ___tracy_emit_frame_mark_start(name: [*:0]const u8) void; | |
| 275 | extern fn ___tracy_emit_frame_mark_end(name: [*:0]const u8) void; | |
| 314 | 276 | extern fn ___tracy_emit_zone_begin_callstack(srcloc: *const ___tracy_source_location_data, depth: i32, active: i32) ___tracy_c_zone_context; |
| 315 | 277 | extern fn ___tracy_emit_zone_text(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void; |
| 316 | 278 | extern fn ___tracy_emit_zone_name(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void; |
| 317 | 279 | extern fn ___tracy_emit_zone_color(ctx: ___tracy_c_zone_context, color: u32) void; |
| 318 | 280 | extern fn ___tracy_emit_zone_value(ctx: ___tracy_c_zone_context, value: u64) void; |
| 319 | 281 | extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void; |
| 320 | extern fn ___tracy_emit_memory_alloc(ptr: *const anyopaque, size: usize, secure: i32) void; | |
| 321 | 282 | extern fn ___tracy_emit_memory_alloc_callstack(ptr: *const anyopaque, size: usize, depth: i32, secure: i32) void; |
| 322 | extern fn ___tracy_emit_memory_free(ptr: *const anyopaque, secure: i32) void; | |
| 323 | 283 | extern fn ___tracy_emit_memory_free_callstack(ptr: *const anyopaque, depth: i32, secure: i32) void; |
| 324 | extern fn ___tracy_emit_memory_alloc_named(ptr: *const anyopaque, size: usize, secure: i32, name: [*:0]const u8) void; | |
| 325 | extern fn ___tracy_emit_memory_alloc_callstack_named(ptr: *const anyopaque, size: usize, depth: i32, secure: i32, name: [*:0]const u8) void; | |
| 326 | extern fn ___tracy_emit_memory_free_named(ptr: *const anyopaque, secure: i32, name: [*:0]const u8) void; | |
| 327 | extern fn ___tracy_emit_memory_free_callstack_named(ptr: *const anyopaque, depth: i32, secure: i32, name: [*:0]const u8) void; | |
| 328 | 284 | extern fn ___tracy_emit_logString(severity: MessageSeverity, color: i32, callstack_depth: i32, size: usize, txt: [*]const u8) void; |
| 329 | 285 | extern fn ___tracy_emit_logStringL(severity: MessageSeverity, color: i32, callstack_depth: i32, txt: [*:0]const u8) void; |
| 330 | extern fn ___tracy_emit_frame_mark(name: ?[*:0]const u8) void; | |
| 286 | extern fn ___tracy_emit_plot_int(name: [*:0]const u8, val: i64) void; | |
| 287 | extern fn ___tracy_emit_plot_config(name: [*:0]const u8, format: PlotConfig.Format, mode: PlotConfig.Mode, fill: i32, color: u32) void; | |
| 331 | 288 | extern fn ___tracy_fiber_enter(fiber: [*:0]const u8) void; |
| 332 | 289 | extern fn ___tracy_fiber_leave() void; |
| 333 | 290 |