From dfa1380262cc75b700585a4041cf57d504a876c4 Mon Sep 17 00:00:00 2001 From: danyabeerzun Date: Thu, 23 Jan 2020 20:11:31 +0300 Subject: [PATCH] Fix GC bug: add swap spaces when extend; Fix debug info --- runtime/runtime.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/runtime.c b/runtime/runtime.c index a9e889a39..b0452cd46 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -1443,6 +1443,7 @@ static void * gc (size_t size) { fflush (stdout); #endif if (extend_spaces ()) { + gc_swap_spaces (); init_to_space (1); return gc (size); } @@ -1560,13 +1561,17 @@ extern void * alloc (size_t size) { #endif return p; } + init_to_space (0); #ifdef DEBUG_PRINT printf ("alloc: call gc: %zu\n", size); fflush (stdout); printFromSpace(); fflush (stdout); - printf("gc END\n\n"); fflush (stdout); + p = gc (size); + printf("gc END %p %p %p\n\n", from_space.begin, + from_space.end, from_space.current); fflush (stdout); printFromSpace(); fflush (stdout); -#endif - init_to_space (0); + return p; +#else return gc (size); +#endif } # endif