summaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-01-09 15:45:27 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-01-09 15:45:27 -0800
commit7d5f0b7e3613f8e8be84ac0d541a7bbcb4782f1d (patch)
treeb76f4aa9c360724a432b5ebe6ced2dcd11e49858 /gc.c
parentfdf67dae2092e0d6fe460e16a939080493e00a3b (diff)
downloadtxr-7d5f0b7e3613f8e8be84ac0d541a7bbcb4782f1d.tar.gz
txr-7d5f0b7e3613f8e8be84ac0d541a7bbcb4782f1d.tar.bz2
txr-7d5f0b7e3613f8e8be84ac0d541a7bbcb4782f1d.zip
gc: obtain stack top using alloca.
This trick gets rid of the hack for aarch64. If we call alloca, the pointer we get should be below all frame information. Even if for the given target, the compiler-generated code happens to be saving callee-saved registers below the declared variables, any pointer we get from alloca must be below all of that still. * gc.c (STACK_TOP_EXTRA_WORDS): Macro removed. (mark): Don't subtract STACK_TOP_EXTRA_WORDS from gc_stack_top; take the top as-is. (gc): Don't allocate the machine context as an automatic variable; obtain the storage for it from alloca. That then also serves as the stack top.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gc.c b/gc.c
index 3029158c..f3a354c6 100644
--- a/gc.c
+++ b/gc.c
@@ -32,6 +32,7 @@
#include <wchar.h>
#include <signal.h>
#include "config.h"
+#include "alloca.h"
#if HAVE_VALGRIND
#include <valgrind/memcheck.h>
#endif
@@ -52,12 +53,6 @@
#define FRESHOBJ_VEC_SIZE (8 * HEAP_SIZE)
#define DFL_MALLOC_DELTA_THRESH (64L * 1024 * 1024)
-#if __aarch64__
-#define STACK_TOP_EXTRA_WORDS 12
-#else
-#define STACK_TOP_EXTRA_WORDS 0
-#endif
-
#if HAVE_MEMALIGN || HAVE_POSIX_MEMALIGN
#define OBJ_ALIGN (sizeof (obj_t))
#else
@@ -521,7 +516,7 @@ static void mark(val *gc_stack_top)
/*
* Finally, the stack.
*/
- mark_mem_region(gc_stack_top - STACK_TOP_EXTRA_WORDS, gc_stack_bottom);
+ mark_mem_region(gc_stack_top, gc_stack_bottom);
}
static int sweep_one(obj_t *block)
@@ -795,7 +790,7 @@ void gc(void)
static int gc_counter;
#endif
int swept;
- mach_context_t mc;
+ mach_context_t *pmc = convert(mach_context_t *, alloca(sizeof *pmc));
assert (gc_enabled);
@@ -807,11 +802,11 @@ void gc(void)
full_gc = 1;
#endif
- save_context(mc);
+ save_context(*pmc);
gc_enabled = 0;
rcyc_empty();
iobuf_list_empty();
- mark(coerce(val *, &mc));
+ mark(coerce(val *, pmc));
hash_process_weak();
prepare_finals();
swept = sweep();