From 98052fdf306f2e079ab8ca594adb509b0d83c9c8 Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Wed, 2 Aug 2017 01:29:42 -0400 Subject: [PATCH] Change *restart-lisp-function* to a C symbol --- src/code/save.lisp | 12 +++++++----- src/compiler/arm/parms.lisp | 3 +-- src/compiler/arm64/parms.lisp | 1 - src/compiler/ppc/parms.lisp | 3 +-- src/compiler/sparc/parms.lisp | 3 +-- src/compiler/x86-64/parms.lisp | 6 +----- src/compiler/x86/parms.lisp | 5 +---- src/runtime/gencgc.c | 15 ++++++++++----- 8 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/code/save.lisp b/src/code/save.lisp index 88207d8a9..8e86aeead 100644 --- a/src/code/save.lisp +++ b/src/code/save.lisp @@ -37,7 +37,7 @@ (application-type int)) #!+gencgc -(defvar sb!vm::*restart-lisp-function*) +(define-alien-variable "lisp_init_function" (unsigned #.sb-vm:n-machine-word-bits)) (define-condition save-condition (reference-condition) () @@ -214,9 +214,10 @@ sufficiently motivated to do lengthy fixes." ;; prior causes compilation to occur into immobile space. ;; Failing to see all immobile code would miss some relocs. (sb!kernel::choose-code-component-order root-structures)) - ;; Save the restart function into a static symbol, to allow GC-AND-SAVE - ;; access to it even after the GC has moved it. - (setf sb!vm::*restart-lisp-function* #'restart-lisp) + ;; Save the restart function. Logically a passed argument, but can't be, + ;; as it would require pinning around the whole save operation. + (with-pinned-objects (#'restart-lisp) + (setf lisp-init-function (get-lisp-obj-address #'restart-lisp))) ;; Do a destructive non-conservative GC, and then save a core. ;; A normal GC will leave huge amounts of storage unreclaimed ;; (over 50% on x86). This needs to be done by a single function @@ -227,7 +228,8 @@ sufficiently motivated to do lengthy fixes." (foreign-bool compression) (or compression 0) #!+win32 (ecase application-type (:console 0) (:gui 1)) - #!-win32 0)) + #!-win32 0) + (setf lisp-init-function 0)) ; only reach here on save error #!-gencgc (progn (if purify (purify :root-structures root-structures) (gc)) diff --git a/src/compiler/arm/parms.lisp b/src/compiler/arm/parms.lisp index f5f5c8d50..317f65b29 100644 --- a/src/compiler/arm/parms.lisp +++ b/src/compiler/arm/parms.lisp @@ -148,8 +148,7 @@ ;; interrupt handling *pseudo-atomic-atomic* - *pseudo-atomic-interrupted* - #!+gencgc *restart-lisp-function*) + *pseudo-atomic-interrupted*) #'equalp) (defconstant-eqx +static-fdefns+ diff --git a/src/compiler/arm64/parms.lisp b/src/compiler/arm64/parms.lisp index f55f5c2aa..77329c7d1 100644 --- a/src/compiler/arm64/parms.lisp +++ b/src/compiler/arm64/parms.lisp @@ -126,7 +126,6 @@ *pseudo-atomic-interrupted*) *allocation-pointer* ;; interrupt handling - #!+gencgc *restart-lisp-function* ,@+common-static-symbols+) #'equalp) diff --git a/src/compiler/ppc/parms.lisp b/src/compiler/ppc/parms.lisp index 205c476ac..683c7f6b6 100644 --- a/src/compiler/ppc/parms.lisp +++ b/src/compiler/ppc/parms.lisp @@ -174,8 +174,7 @@ ;;; can be loaded directly out of them by indirecting relative to NIL. ;;; (defconstant-eqx +static-symbols+ - `#(,@+common-static-symbols+ - #!+gencgc *restart-lisp-function*) + `#(,@+common-static-symbols+) #'equalp) (defconstant-eqx +static-fdefns+ diff --git a/src/compiler/sparc/parms.lisp b/src/compiler/sparc/parms.lisp index 11c6f268b..865a0a920 100644 --- a/src/compiler/sparc/parms.lisp +++ b/src/compiler/sparc/parms.lisp @@ -204,8 +204,7 @@ ;;; can be loaded directly out of them by indirecting relative to NIL. ;;; (defconstant-eqx +static-symbols+ - `#(,@+common-static-symbols+ - #!+gencgc *restart-lisp-function*) + `#(,@+common-static-symbols+) #'equalp) (defconstant-eqx +static-fdefns+ diff --git a/src/compiler/x86-64/parms.lisp b/src/compiler/x86-64/parms.lisp index 98a309239..83d16d256 100644 --- a/src/compiler/x86-64/parms.lisp +++ b/src/compiler/x86-64/parms.lisp @@ -151,11 +151,7 @@ *pseudo-atomic-bits* *allocation-pointer* - *binding-stack-pointer* - - ;; For GC-AND-SAVE - *restart-lisp-function* - ) + *binding-stack-pointer*) #'equalp) ;;; FIXME: with #!+immobile-space, this should be the empty list, diff --git a/src/compiler/x86/parms.lisp b/src/compiler/x86/parms.lisp index 8ef6310a6..160873747 100644 --- a/src/compiler/x86/parms.lisp +++ b/src/compiler/x86/parms.lisp @@ -250,10 +250,7 @@ *fp-constant-l2t* *fp-constant-l2e* *fp-constant-lg2* - *fp-constant-ln2* - - ;; For GC-AND-SAVE - *restart-lisp-function*) + *fp-constant-ln2*) #'equalp) (defconstant-eqx +static-fdefns+ diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index b16bee6d8..d51fb50e5 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -167,6 +167,9 @@ int gc_n_stack_pins; struct hopscotch_table pinned_objects; #endif +/* This is always 0 except during gc_and_save() */ +lispobj lisp_init_function; + /// Constants defined in gc-internal: /// #define BOXED_PAGE_FLAG 1 /// #define UNBOXED_PAGE_FLAG 2 @@ -3421,9 +3424,12 @@ garbage_collect_generation(generation_index_t generation, int raise) scavenge_generations(generation+1, PSEUDO_STATIC_GENERATION); #ifdef LISP_FEATURE_SB_TRACEROOT - scavenge(&gc_object_watcher, 1); + if (gc_object_watcher) scavenge(&gc_object_watcher, 1); #endif scavenge_pinned_ranges(); + /* The Lisp start function is stored in the core header, not a static + * symbol. It is passed to gc_and_save() in this C variable */ + if (lisp_init_function) scavenge(&lisp_init_function, 1); /* Finally scavenge the new_space generation. Keep going until no * more objects are moved into the new generation */ @@ -4317,8 +4323,7 @@ prepare_for_final_gc () char gc_coalesce_string_literals = 0; /* Do a non-conservative GC, and then save a core with the initial - * function being set to the value of the static symbol - * SB!VM:RESTART-LISP-FUNCTION */ + * function being set to the value of 'lisp_init_function' */ void gc_and_save(char *filename, boolean prepend_runtime, boolean save_runtime_options, boolean compressed, @@ -4370,12 +4375,12 @@ gc_and_save(char *filename, boolean prepend_runtime, /* The dumper doesn't know that pages need to be zeroed before use. */ zero_all_free_pages(); - save_to_filehandle(file, filename, SymbolValue(RESTART_LISP_FUNCTION,0), + save_to_filehandle(file, filename, lisp_init_function, prepend_runtime, save_runtime_options, compressed ? compression_level : COMPRESSION_LEVEL_NONE); /* Oops. Save still managed to fail. Since we've mangled the stack * beyond hope, there's not much we can do. - * (beyond FUNCALLing RESTART_LISP_FUNCTION, but I suspect that's + * (beyond FUNCALLing lisp_init_function, but I suspect that's * going to be rather unsatisfactory too... */ lose("Attempt to save core after non-conservative GC failed.\n"); } -- 2.11.4.GIT