| ... | @@ -1,13 +1,18 @@ | ... | @@ -1,13 +1,18 @@ |
| | 1 | pub const enabled = switch (build_options.io_mode) { |
| | 2 | .threaded => build_options.enable_debug_extensions, |
| | 3 | .evented => false, // would use threadlocals in a way incompatible with evented |
| | 4 | }; |
| | 5 | |
| 1 | /// We override the panic implementation to our own one, so we can print our own information before | 6 | /// We override the panic implementation to our own one, so we can print our own information before |
| 2 | /// calling the default panic handler. This declaration must be re-exposed from `@import("root")`. | 7 | /// calling the default panic handler. This declaration must be re-exposed from `@import("root")`. |
| 3 | pub const panic = std.debug.FullPanic(panicImpl); | 8 | pub const panic = std.debug.FullPanic(if (enabled) panicImpl else std.debug.defaultPanic); |
| 4 | | 9 | |
| 5 | /// We let std install its segfault handler, but we override the target-agnostic handler it calls, | 10 | /// We let std install its segfault handler, but we override the target-agnostic handler it calls, |
| 6 | /// so we can print our own information before calling the default segfault logic. This declaration | 11 | /// so we can print our own information before calling the default segfault logic. This declaration |
| 7 | /// must be re-exposed from `@import("root")`. | 12 | /// must be re-exposed from `@import("root")`. |
| 8 | pub const debug = struct { | 13 | pub const debug = if (enabled) struct { |
| 9 | pub const handleSegfault = handleSegfaultImpl; | 14 | pub const handleSegfault = handleSegfaultImpl; |
| 10 | }; | 15 | } else struct {}; |
| 11 | | 16 | |
| 12 | /// Printed in panic messages when suggesting a command to run, allowing copy-pasting the command. | 17 | /// Printed in panic messages when suggesting a command to run, allowing copy-pasting the command. |
| 13 | /// Set by `main` as soon as arguments are known. The value here is a default in case we somehow | 18 | /// Set by `main` as soon as arguments are known. The value here is a default in case we somehow |
| ... | @@ -25,7 +30,7 @@ fn panicImpl(msg: []const u8, first_trace_addr: ?usize) noreturn { | ... | @@ -25,7 +30,7 @@ fn panicImpl(msg: []const u8, first_trace_addr: ?usize) noreturn { |
| 25 | std.debug.defaultPanic(msg, first_trace_addr orelse @returnAddress()); | 30 | std.debug.defaultPanic(msg, first_trace_addr orelse @returnAddress()); |
| 26 | } | 31 | } |
| 27 | | 32 | |
| 28 | pub const AnalyzeBody = struct { | 33 | pub const AnalyzeBody = if (enabled) struct { |
| 29 | parent: ?*AnalyzeBody, | 34 | parent: ?*AnalyzeBody, |
| 30 | sema: *Sema, | 35 | sema: *Sema, |
| 31 | block: *Sema.Block, | 36 | block: *Sema.Block, |
| ... | @@ -52,9 +57,15 @@ pub const AnalyzeBody = struct { | ... | @@ -52,9 +57,15 @@ pub const AnalyzeBody = struct { |
| 52 | std.debug.assert(current.? == ab); // `Sema.analyzeBodyInner` did not match push/pop calls | 57 | std.debug.assert(current.? == ab); // `Sema.analyzeBodyInner` did not match push/pop calls |
| 53 | current = ab.parent; | 58 | current = ab.parent; |
| 54 | } | 59 | } |
| | 60 | } else struct { |
| | 61 | const current: ?noreturn = null; |
| | 62 | // Dummy implementation, with functions marked `inline` to avoid interfering with tail calls. |
| | 63 | pub inline fn push(_: AnalyzeBody, _: *Sema, _: *Sema.Block, _: []const Zir.Inst.Index) void {} |
| | 64 | pub inline fn pop(_: AnalyzeBody) void {} |
| | 65 | pub inline fn setBodyIndex(_: @This(), _: usize) void {} |
| 55 | }; | 66 | }; |
| 56 | | 67 | |
| 57 | pub const CodegenFunc = struct { | 68 | pub const CodegenFunc = if (enabled) struct { |
| 58 | zcu: *const Zcu, | 69 | zcu: *const Zcu, |
| 59 | func_index: InternPool.Index, | 70 | func_index: InternPool.Index, |
| 60 | threadlocal var current: ?CodegenFunc = null; | 71 | threadlocal var current: ?CodegenFunc = null; |
| ... | @@ -66,6 +77,11 @@ pub const CodegenFunc = struct { | ... | @@ -66,6 +77,11 @@ pub const CodegenFunc = struct { |
| 66 | std.debug.assert(current.?.func_index == func_index); | 77 | std.debug.assert(current.?.func_index == func_index); |
| 67 | current = null; | 78 | current = null; |
| 68 | } | 79 | } |
| | 80 | } else struct { |
| | 81 | const current: ?noreturn = null; |
| | 82 | // Dummy implementation |
| | 83 | pub fn start(_: *const Zcu, _: InternPool.Index) void {} |
| | 84 | pub fn stop(_: InternPool.Index) void {} |
| 69 | }; | 85 | }; |
| 70 | | 86 | |
| 71 | fn dumpCrashContext() Io.Writer.Error!void { | 87 | fn dumpCrashContext() Io.Writer.Error!void { |
| ... | @@ -172,3 +188,5 @@ const Zcu = @import("Zcu.zig"); | ... | @@ -172,3 +188,5 @@ const Zcu = @import("Zcu.zig"); |
| 172 | const InternPool = @import("InternPool.zig"); | 188 | const InternPool = @import("InternPool.zig"); |
| 173 | const dev = @import("dev.zig"); | 189 | const dev = @import("dev.zig"); |
| 174 | const print_zir = @import("print_zir.zig"); | 190 | const print_zir = @import("print_zir.zig"); |
| | 191 | |
| | 192 | const build_options = @import("build_options"); |