From d930e7f9750175c4f31cb2827982174a9393606c Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 19 May 2023 17:32:14 +0300 Subject: [PATCH] add nogc message to thrF --- src/core/stuff.c | 1 + src/h.h | 4 ++-- src/opt/mm_buddy.h | 2 +- src/utils/mut.h | 2 +- src/vm.c | 4 +--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/stuff.c b/src/core/stuff.c index b119cec4..52aad7ed 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -351,6 +351,7 @@ NOINLINE void print_fmt(char* p, ...) { decG(r); } NOINLINE void thrF(char* p, ...) { + NOGC_CHECK("throwing during noAlloc"); va_list a; va_start(a, p); B r = do_fmt(emptyCVec(), p, a); diff --git a/src/h.h b/src/h.h index f59929b7..3b676be7 100644 --- a/src/h.h +++ b/src/h.h @@ -327,7 +327,7 @@ typedef struct Arr { #define UD assert(false) extern bool cbqn_noAlloc; NOINLINE void cbqn_NOGC_start(); // function to allow breakpointing - #define NOGC_CHECK if (cbqn_noAlloc && !gc_depth) fatal("allocating during noalloc"); + #define NOGC_CHECK(M) do { if (cbqn_noAlloc && !gc_depth) fatal(M); } while (0) #define NOGC_S cbqn_NOGC_start() #define NOGC_E cbqn_noAlloc=false #else @@ -337,7 +337,7 @@ typedef struct Arr { #define UD __builtin_unreachable() #define NOGC_S #define NOGC_E - #define NOGC_CHECK + #define NOGC_CHECK(M) #endif #if WARN_SLOW void warn_slow1(char* s, B x); diff --git a/src/opt/mm_buddy.h b/src/opt/mm_buddy.h index d13f63ea..fc64aa11 100644 --- a/src/opt/mm_buddy.h +++ b/src/opt/mm_buddy.h @@ -23,7 +23,7 @@ extern EmptyValue* mm_buckets[64]; #if !ALLOC_NOINLINE || ALLOC_IMPL || ALLOC_IMPL_MMX ALLOC_FN void* mm_alloc(u64 sz, u8 type) { assert(sz>=16); - NOGC_CHECK; + NOGC_CHECK("allocating during noalloc"); preAlloc(sz, type); #if VERIFY_TAIL i64 logAlloc = LOG2(sz + VERIFY_TAIL); diff --git a/src/utils/mut.h b/src/utils/mut.h index 2ee5d364..5c77fca6 100644 --- a/src/utils/mut.h +++ b/src/utils/mut.h @@ -96,7 +96,7 @@ static void mut_copy(Mut* m, usz ms, B x, usz xs, usz l) { assert(isArr(x)); m-> // after that, the only valid operation on the Mut will be MUT_APPEND // using this append system will no longer prevent allocations from being done during the lifetime of the Mut #define MUT_APPEND_INIT(N) ux N##_ci = 0; NOGC_E; -#define MUT_APPEND(N, X, XS, L) ({ ux l_ = (L); NOGC_CHECK; \ +#define MUT_APPEND(N, X, XS, L) ({ ux l_ = (L); NOGC_CHECK("MUT_APPEND during noalloc"); \ mut_copy(N, N##_ci, X, XS, l_); \ N##_ci+= l_; \ if (PTY(N->val) == t_harr) { NOGC_E; N->val->ia = N##_ci; } \ diff --git a/src/vm.c b/src/vm.c index d6bd7b10..4b5cd8f6 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1677,9 +1677,7 @@ void before_exit(void); NOINLINE NORETURN void throwImpl(bool rethrow) { // printf("gStack %p-%p:\n", gStackStart, gStack); B* c = gStack; // while (c>gStackStart) { printI(*--c); putchar('\n'); } printf("gStack printed\n"); - #if DEBUG - if (cbqn_noAlloc && !gc_depth) fatal("throwing during noAlloc"); - #endif + NOGC_CHECK("throwing during noAlloc"); if (!rethrow) envPrevHeight = envCurr-envStart + 1; #if CATCH_ERRORS if (cf>cfStart) { // something wants to catch errors