From ed2198c06a1996a2e9851f497fe71e2042a973c0 Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 12 Jul 2024 18:07:00 +0300 Subject: [PATCH] disable tail calls in bqn_fmt & bqn_repr far from performance-critical, but helpful for stack traces --- src/load.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/load.c b/src/load.c index 2d8ace52..2f27c513 100644 --- a/src/load.c +++ b/src/load.c @@ -182,10 +182,16 @@ B compObj_c2(B t, B w, B x) { return w; } +#if __clang__ + #define NO_TAIL_CALLS __attribute__((disable_tail_calls)) +#else + #define NO_TAIL_CALLS __attribute__((optimize("-fno-optimize-sibling-calls"))) +#endif + #if FORMATTER GLOBAL B load_fmt, load_repr; -B bqn_fmt(B x) { return c1G(load_fmt, x); } -B bqn_repr(B x) { return c1G(load_repr, x); } +NO_TAIL_CALLS B bqn_fmt(B x) { return c1G(load_fmt, x); } +NO_TAIL_CALLS B bqn_repr(B x) { return c1G(load_repr, x); } #else B bqn_fmt(B x) { return x; } B bqn_repr(B x) { return x; }