/[cmucl]/src/code/save.lisp
ViewVC logotype

Contents of /src/code/save.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Thu Sep 27 02:24:19 1990 UTC (23 years, 6 months ago) by wlott
Branch: MAIN
Changes since 1.2: +8 -5 lines
Added :constants argument to save-lisp.  It gets passed on to purify.
1 ram 1.1 ;;; -*- Mode: Lisp; Package: Lisp; Log: code.log -*-
2     ;;;
3     ;;; **********************************************************************
4     ;;; This code was written as part of the Spice Lisp project at
5     ;;; Carnegie-Mellon University, and has been placed in the public domain.
6     ;;; Spice Lisp is currently incomplete and under active development.
7     ;;; If you want to use this code or any part of Spice Lisp, please contact
8     ;;; Scott Fahlman (FAHLMAN@CMUC).
9     ;;; **********************************************************************
10     ;;;
11 wlott 1.3 ;;; $Header: /tiger/var/lib/cvsroots/cmucl/src/code/save.lisp,v 1.3 1990/09/27 02:24:19 wlott Exp $
12 wlott 1.2 ;;;
13     ;;; Dump the current lisp image into a core file. All the real work is done
14     ;;; be C.
15     ;;;
16     ;;; Written by William Lott.
17 ram 1.1 ;;;
18     ;;;
19     (in-package "LISP")
20    
21     (in-package "EXTENSIONS")
22 wlott 1.2 (export '(print-herald save-lisp *before-save-initializations*
23     *after-save-initializations* *environment-list* *editor-lisp-p*))
24 ram 1.1 (in-package "LISP")
25    
26 wlott 1.2 (defvar *before-save-initializations* nil
27     "This is a list of functions which are called before creating a saved core
28     image. These functions are executed in the child process which has no ports,
29     so they cannot do anything that tries to talk to the outside world.")
30 ram 1.1
31 wlott 1.2 (defvar *after-save-initializations* nil
32     "This is a list of functions which are called when a saved core image starts
33     up. The system itself should be initialized at this point, but applications
34     might not be.")
35 ram 1.1
36 wlott 1.2 (defvar *environment-list* nil
37     "An alist mapping environment variables (as keywords) to either values")
38 ram 1.1
39 wlott 1.2 (defvar *editor-lisp-p* nil
40     "This is true if and only if the lisp was started with the -edit switch.")
41    
42    
43    
44     ;;; Filled in by the startup code.
45 ram 1.1 (defvar lisp-environment-list)
46    
47    
48 wlott 1.2 (def-c-routine "save" (boolean)
49     (file null-terminated-string))
50 ram 1.1
51 wlott 1.2
52     (defun save-lisp (core-file-name &key
53     (purify t)
54     (root-structures ())
55 wlott 1.3 (constants nil)
56 wlott 1.2 (init-function
57     #'(lambda ()
58     (throw 'top-level-catcher nil)))
59     (load-init-file t)
60     (print-herald t)
61     (process-command-line t))
62     "Saves a CMU Common Lisp core image in the file of the specified name. The
63     following keywords are defined:
64    
65     :purify
66     If true, do a purifying GC which moves all dynamically allocated
67     objects into static space so that they stay pure. This takes somewhat
68     longer than the normal GC which is otherwise done, but GC's will done
69     less often and take less time in the resulting core file.
70    
71     :root-structures
72 wlott 1.3 :constants
73     These should be a list of the main entry points in any newly loaded
74     systems and a list of any large data structures that will never again
75     be changed. These need not be supplied, but locality and/or GC performance
76     will be better if they are. They are meaningless if :purify is NIL.
77 wlott 1.2
78     :init-function
79     This is a function which is called when the created core file is
80     resumed. The default function simply aborts to the top level
81     read-eval-print loop. If the function returns it will be the value
82     of Save-Lisp.
83    
84     :load-init-file
85     If true, then look for an init.lisp or init.fasl file when the core
86     file is resumed.
87    
88     :print-herald
89     If true, print out the lisp system herald when starting."
90    
91     (if purify
92 wlott 1.3 (purify :root-structures root-structures :constants constants)
93 wlott 1.2 (gc))
94     (unless (save (namestring core-file-name))
95     (dolist (f *before-save-initializations*) (funcall f))
96     (dolist (f *after-save-initializations*) (funcall f))
97     (reinit)
98     (dolist (ele lisp-environment-list)
99     (let ((=pos (position #\= (the simple-string ele))))
100     (when =pos
101     (push (cons (intern (string-upcase (subseq ele 0 =pos))
102     *keyword-package*)
103     (subseq ele (1+ =pos)))
104     *environment-list*))))
105     (setf (search-list "default:") (list (default-directory)))
106     (setf (search-list "path:") (setup-path-search-list))
107     (when process-command-line (ext::process-command-strings))
108     (setf *editor-lisp-p* nil)
109     (macrolet ((find-switch (name)
110     `(find ,name *command-line-switches*
111     :key #'cmd-switch-name
112     :test #'(lambda (x y)
113     (declare (simple-string x y))
114     (string-equal x y)))))
115     (when (and process-command-line (find-switch "edit"))
116     (setf *editor-lisp-p* t))
117     (when (and load-init-file
118     (not (and process-command-line (find-switch "noinit"))))
119     (let* ((cl-switch (find-switch "init"))
120     (name (or (and cl-switch
121     (or (cmd-switch-value cl-switch)
122     (car (cmd-switch-words cl-switch))
123     "init"))
124     "init")))
125     (load (merge-pathnames name (user-homedir-pathname))
126     :if-does-not-exist nil))))
127     (when print-herald
128     (print-herald))
129     (when process-command-line
130     (ext::invoke-switch-demons *command-line-switches*
131     *command-switch-demons*))
132     (funcall init-function)))
133    
134    
135     (defun print-herald ()
136     (macrolet ((frob (variable)
137     `(if (boundp ',variable)
138     ,variable
139     "<not loaded>")))
140     (write-string "CMU Common Lisp ")
141     (write-string (lisp-implementation-version))
142     (write-string ", running on ")
143     (write-line (machine-instance))
144     (write-string "Hemlock ")
145     (write-string (frob *hemlock-version*))
146     (write-string ", Compiler ")
147     (write-line (frob compiler-version))
148     (write-line "Send bug reports and questions to Gripe."))
149     (values))
150    
151    
152     ;;;; Random functions used by worldload.
153    
154     (defun assert-user-package ()
155     (unless (eq *package* (find-package "USER"))
156     (error "Change *PACKAGE* to the USER package and try again.")))
157    
158     (defun initial-init-function ()
159     (gc-on)
160     (throw 'top-level-catcher nil))
161    

  ViewVC Help
Powered by ViewVC 1.1.5