Skip to content

Commit c794bd4

Browse files
committed
add branch hint to panic
1 parent eecc835 commit c794bd4

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/android/android.zig

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ const Panic = struct {
169169
threadlocal var panic_stage: usize = 0;
170170

171171
fn panic(message: []const u8, ret_addr: ?usize) noreturn {
172+
@branchHint(.cold);
172173
if (comptime !builtin.abi.isAndroid()) @compileError("do not use Android panic for non-Android builds");
173174
const first_trace_addr = ret_addr orelse @returnAddress();
174175
panicImpl(first_trace_addr, message);
@@ -245,14 +246,7 @@ const Panic = struct {
245246
/// - Provide custom "io" namespace so we can easily customize getStdErr() to be our own writer
246247
/// - Provide other functions from std.debug.*
247248
fn panicImpl(first_trace_addr: ?usize, msg: []const u8) noreturn {
248-
// NOTE(jae): 2024-09-22
249-
// Cannot mark this as cold(true) OR setCold() depending on Zig version as we get an invalid builtin function
250-
// comptime {
251-
// if (builtin.zig_version.minor == 13)
252-
// @setCold(true)
253-
// else
254-
// @cold(true);
255-
// }
249+
@branchHint(.cold);
256250

257251
if (enable_segfault_handler) {
258252
// If a segfault happens while panicking, we want it to actually segfault, not trigger

0 commit comments

Comments
 (0)