SCHEME_OBJECT * to = Free;
SCHEME_OBJECT * prim_table_start;
SCHEME_OBJECT * c_code_table_start;
+ const char * filename;
bool result;
PRIMITIVE_HEADER (2);
CHECK_ARG (1, INTERPRETER_APPLICABLE_P);
- CHECK_ARG (2, STRING_P);
+ filename = ((const char *) (arg_extended_string (2, NULL)));
Primitive_GC_If_Needed (5);
initialize_fasl_header (true, true);
result = false;
else
{
- const char * filename = (STRING_POINTER (ARG_REF (2)));
fasl_file_handle_t handle;
export_primitive_table (prim_table_start);
(declare (usual-integrations))
-(add-boot-deps! '(runtime dynamic))
+(add-boot-deps! '(runtime dynamic)
+ '(runtime gc-finalizer))
\f
;;; (DISK-SAVE filename #!optional identify)
;;; Saves a world image in FILENAME. IDENTIFY has the following meaning:
(define-deferred *within-restore-window?* (make-unsettable-parameter #f))
(define (disk-save filename #!optional id)
- (let ((filename (->namestring (merge-pathnames filename)))
+ (let ((filename* (disk-save-filename filename))
(id (if (default-object? id) world-id id))
(time (local-decoded-time)))
+ (set! filename #f)
(gc-clean)
((without-interrupts
(lambda ()
(do ()
(((ucode-primitive dump-band)
restart
- (string-for-primitive filename)))
+ (disk-save-filename-string filename*)))
(with-simple-restart 'retry "Try again."
(lambda ()
- (error "Disk save failed:" filename))))
+ (error "Disk save failed!"))))
(continuation
(lambda ()
(set! time-world-saved time)
(event-distributor/invoke! event:after-restart)
#t))))))))))
\f
+;;; Kludge to store disk-save filenames outside the Scheme heap so they
+;;; don't get dumped in bands.
+
+(define (disk-save-filename filename)
+ (let* ((pathname (merge-pathnames filename))
+ (namestring (->namestring pathname))
+ (primitive (string-for-primitive namestring))
+ (n (string-length primitive))
+ (cell
+ (make-gc-finalized-object disk-save-filenames
+ (lambda (p)
+ (weak-set-cdr! p
+ ((ucode-primitive allocate-external-string 1) n)))
+ (lambda (s)
+ (make-cell s))))
+ (string (cell-contents cell)))
+ ((ucode-primitive substring-move-left! 5) primitive 0 n string 0)
+ cell))
+
+(define (disk-save-filename-string f)
+ (cell-contents f))
+
+(define-deferred disk-save-filenames
+ (make-gc-finalizer (ucode-primitive deallocate-external-string 1)
+ cell? cell-contents set-cell-contents!))
+\f
(define (disk-restore #!optional filename)
;; Force order of events -- no need to run event:before-exit if
;; there's an error here.