From 0d814af3162ae3f19df6f41eb09097db3677a5ad Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Fri, 18 Aug 2017 00:47:25 -0400 Subject: [PATCH] Use {set,get}_alloc_pointer() abstraction in lieu of #ifdefs --- src/runtime/coreparse.c | 8 ++------ src/runtime/globals.c | 8 ++++---- src/runtime/globals.h | 8 ++++---- src/runtime/marknsweepgc.c | 11 +++-------- src/runtime/save.c | 21 ++------------------- 5 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/runtime/coreparse.c b/src/runtime/coreparse.c index 02a2daedf..6aeff9958 100644 --- a/src/runtime/coreparse.c +++ b/src/runtime/coreparse.c @@ -47,6 +47,7 @@ #include "validate.h" #include "gc-internal.h" #include "runtime-options.h" +#include "pseudo-atomic.h" #include @@ -670,13 +671,8 @@ process_directory(int fd, lispobj *ptr, int count, os_vm_offset_t file_offset) * at the time the core was saved. * For gencgc we don't look at current_dynamic_space */ current_dynamic_space = (lispobj *)addr; + set_alloc_pointer((lispobj)free_pointer); - /* FIXME: why not use set_alloc_pointer() ? */ -#if defined(ALLOCATION_POINTER) - SetSymbolValue(ALLOCATION_POINTER, (lispobj)free_pointer,0); -#else - dynamic_space_free_pointer = free_pointer; -#endif anon_dynamic_space_start = (os_vm_address_t)(addr + len); /* This assertion safeguards the test in zero_pages_with_mmap() * which trusts that if addr > anon_dynamic_space_start diff --git a/src/runtime/globals.c b/src/runtime/globals.c index 207646fa4..d7b10ea18 100644 --- a/src/runtime/globals.c +++ b/src/runtime/globals.c @@ -42,11 +42,11 @@ lispobj *current_binding_stack_pointer; /* The Object Formerly Known As current_dynamic_space_free_pointer */ lispobj *dynamic_space_free_pointer; #endif -lispobj* read_only_space_free_pointer; -lispobj* static_space_free_pointer; +lispobj *read_only_space_free_pointer; +lispobj *static_space_free_pointer; #ifdef LISP_FEATURE_IMMOBILE_SPACE -lispobj* immobile_space_free_pointer; -lispobj* immobile_fixedobj_free_pointer; +lispobj *immobile_space_free_pointer; +lispobj *immobile_fixedobj_free_pointer; #endif os_vm_address_t anon_dynamic_space_start; diff --git a/src/runtime/globals.h b/src/runtime/globals.h index cddb0c019..b094bc132 100644 --- a/src/runtime/globals.h +++ b/src/runtime/globals.h @@ -68,11 +68,11 @@ extern lispobj *current_binding_stack_pointer; * routines. */ extern lispobj *dynamic_space_free_pointer; #endif -extern lispobj* read_only_space_free_pointer; -extern lispobj* static_space_free_pointer; +extern lispobj *read_only_space_free_pointer; +extern lispobj *static_space_free_pointer; #ifdef LISP_FEATURE_IMMOBILE_SPACE -extern lispobj* immobile_space_free_pointer; -extern lispobj* immobile_fixedobj_free_pointer; +extern lispobj *immobile_space_free_pointer; +extern lispobj *immobile_fixedobj_free_pointer; #endif extern os_vm_address_t anon_dynamic_space_start; diff --git a/src/runtime/marknsweepgc.c b/src/runtime/marknsweepgc.c index 43b214a03..61bc78549 100644 --- a/src/runtime/marknsweepgc.c +++ b/src/runtime/marknsweepgc.c @@ -50,6 +50,7 @@ #include "genesis/gc-tables.h" #include "genesis/vector.h" #include "forwarding-ptr.h" +#include "pseudo-atomic.h" #include "var-io.h" #include @@ -2151,14 +2152,8 @@ void defrag_immobile_space(int* components, boolean verbose) // Dynamic space // We can safely ignore allocation region boundaries. - fixup_space((lispobj*)DYNAMIC_SPACE_START, - ((lispobj) -#ifdef reg_ALLOC - dynamic_space_free_pointer -#else - SymbolValue(ALLOCATION_POINTER,0) -#endif - - DYNAMIC_SPACE_START) >> WORD_SHIFT); + fixup_space(current_dynamic_space, + (lispobj*)get_alloc_pointer() - current_dynamic_space); // Copy the spaces back where they belong. diff --git a/src/runtime/save.c b/src/runtime/save.c index d8224ede6..ef75bccc7 100644 --- a/src/runtime/save.c +++ b/src/runtime/save.c @@ -35,6 +35,7 @@ #include "gc-internal.h" #include "thread.h" #include "arch.h" +#include "pseudo-atomic.h" #include "genesis/static-symbols.h" #include "genesis/symbol.h" @@ -333,30 +334,12 @@ save_to_filehandle(FILE *file, char *filename, lispobj init_function, core_start_pos, core_compression_level); #endif -#ifdef reg_ALLOC -#ifdef LISP_FEATURE_GENCGC - output_space(file, - DYNAMIC_CORE_SPACE_ID, - (lispobj *)DYNAMIC_SPACE_START, - dynamic_space_free_pointer, - core_start_pos, - core_compression_level); -#else output_space(file, DYNAMIC_CORE_SPACE_ID, (lispobj *)current_dynamic_space, - dynamic_space_free_pointer, + (lispobj *)get_alloc_pointer(), core_start_pos, core_compression_level); -#endif -#else - output_space(file, - DYNAMIC_CORE_SPACE_ID, - (lispobj *)DYNAMIC_SPACE_START, - (lispobj *)SymbolValue(ALLOCATION_POINTER,0), - core_start_pos, - core_compression_level); -#endif write_lispobj(INITIAL_FUN_CORE_ENTRY_TYPE_CODE, file); write_lispobj(3, file); -- 2.11.4.GIT