- (if purify
- (purify :root-structures root-structures
- :environment-name environment-name)
- #-gencgc (gc) #+gencgc (gc :full t))
- (flet ((restart-lisp ()
- (handling-end-of-the-world
- (reinit)
- (funcall toplevel))))
- ;; FIXME: Perhaps WITHOUT-GCING should be wrapped around the
- ;; LET as well, to avoid the off chance of an interrupt triggering
- ;; GC and making our saved RESTART-LISP address invalid?
- (without-gcing
- (save (unix-namestring core-file-name nil)
- (get-lisp-obj-address #'restart-lisp)))))
+ (labels ((restart-lisp ()
+ (handling-end-of-the-world
+ (reinit)
+ #!+hpux (sb!sys:%primitive sb!vm::setup-return-from-lisp-stub)
+ (progn
+ (funcall toplevel)
+ (sb!ext:quit))))
+ (foreign-bool (value)
+ (if value 1 0))
+ (save-core (gc)
+ (let ((name (native-namestring
+ (physicalize-pathname core-file-name)
+ :as-file t)))
+ (when gc
+ #!-gencgc (gc)
+ ;; 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
+ ;; since the GC will invalidate the stack.
+ #!+gencgc (gc-and-save name
+ (foreign-bool executable)
+ (foreign-bool save-runtime-options)))
+ (without-gcing
+ (save name
+ (get-lisp-obj-address #'restart-lisp)
+ (foreign-bool executable)
+ (foreign-bool save-runtime-options))))))
+ ;; Save the restart function into a static symbol, to allow GC-AND-SAVE
+ ;; access to it even after the GC has moved it.
+ #!+gencgc
+ (setf sb!vm::*restart-lisp-function* #'restart-lisp)
+ (cond #!-gencgc
+ (purify
+ (purify :root-structures root-structures
+ :environment-name environment-name)
+ (save-core nil))
+ (t
+ ;; Compact the environment even though we're skipping the
+ ;; other purification stages.
+ (sb!kernel::compact-environment-aux "Auxiliary" 200)
+ (save-core t)))))