diff --git a/src/opt/mm_buddyTemplate.c b/src/opt/mm_buddyTemplate.c index 2af2f1e4..81c87e8d 100644 --- a/src/opt/mm_buddyTemplate.c +++ b/src/opt/mm_buddyTemplate.c @@ -37,7 +37,7 @@ FORCE_INLINE void BN(splitTo)(EmptyValue* c, i64 from, i64 to, bool notEqual) { static NOINLINE void* BN(allocateMore)(i64 bucket, u8 type, i64 from, i64 to) { u64 sz = BSZ(from); if (mm_heapAlloc+sz >= mm_heapMax) { - if (sz>100000) thrM("Heap size limit reached"); // if allocating a large thing, it should be possible to recover + if (sz>100000) thrOOM(); // if allocating a large thing, it may be possible to recover printf("Heap size limit reached\n"); abort(); } mm_heapAlloc+= sz; diff --git a/src/vm.c b/src/vm.c index d83b2187..86694f71 100644 --- a/src/vm.c +++ b/src/vm.c @@ -988,7 +988,7 @@ void print_vmStack() { #endif } - +B oomMessage; void comp_init() { TIi(t_comp ,freeO) = comp_freeO; TIi(t_comp ,freeF) = comp_freeF; TIi(t_comp ,visit) = comp_visit; TIi(t_comp ,print) = comp_print; @@ -1007,6 +1007,8 @@ void comp_init() { TIi(t_funBl,fn_iw) = funBl_iw; TIi(t_md1Bl,m1_iw) = md1Bl_iw; TIi(t_md2Bl,m2_iw) = md2Bl_iw; TIi(t_funBl,fn_ix) = funBl_ix; TIi(t_md1Bl,m1_ix) = md1Bl_ix; TIi(t_md2Bl,m2_ix) = md2Bl_ix; + oomMessage = m_str8l("Out of memory"); gc_add(oomMessage); + #ifndef GS_REALLOC allocStack((void**)&gStack, (void**)&gStackStart, (void**)&gStackEnd, sizeof(B), GS_SIZE); #endif @@ -1254,4 +1256,4 @@ NOINLINE void freeThrown() { NOINLINE NORETURN void thrM(char* s) { thr(fromUTF8(s, strlen(s))); } -NOINLINE NORETURN void thrOOM() { thrM("Out of memory"); } +NOINLINE NORETURN void thrOOM() { thr(inc(oomMessage)); }