source: branches/lispworks/load-wood.lisp@ 22

Last change on this file since 22 was 8, checked in by Gail Zacharias, 17 years ago

compiler:with-optimization-level is Lispworks-only

  • Property svn:eol-style set to native
File size: 11.8 KB
Line 
1;;;-*- Mode: Lisp; Package: (WOOD) -*-
2
3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4;;
5;; load-wood.lisp
6;; Load this file and evaluate (wood::load-wood)
7;; You may need to edit the definition of the "wood" logical host.
8;;
9;; Portions Copyright © 2006 Clozure Associates and Anvita eReference (www.Anvita.info)
10;; Copyright © 1996 Digitool, Inc.
11;; Copyright © 1992-1995 Apple Computer, Inc.
12;; All rights reserved.
13;; Permission is given to use, copy, and modify this software provided
14;; that Digitool is given credit in all derivative works.
15;; This software is provided "as is". Digitool makes no warranty or
16;; representation, either express or implied, with respect to this software,
17;; its quality, accuracy, merchantability, or fitness for a particular
18;; purpose.
19;;
20
21;;;;;;;;;;;;;;;;;;;;;;;;;;
22;;
23;; Modification History
24;;
25;; 02/01/06 gz LispWorks port
26;; 04/11/97 bill compile-and-load checks for "Wrong PFSL version" as well
27;; as "Wrong FASL version".
28;; ------------- 0.961
29;; 09/20/96 bill The WOOD package definition mentions the imported symbols as symbols,
30;; not strings, for versions of MCL that don't already include them (e.g. 3.9).
31;; ------------- 0.96
32;; 07/20/96 bill import databases-locked-p, with-databases-unlocked, funcall-with-databases-unlocked
33;; from CCL.
34;; Don't load break-loop-patch if ccl::databases-locked-p is fbound
35;; 07/09/96 bill AlanR's fix to (setf (logical-pathname-translations "wood") ...)
36;; (pathname-directory ...) -> (or (pathname-directory ...) '(:absolute))
37;; ------------- 0.95
38;; 06/04/96 bill load-wood loads break-loop-patch
39;; 05/09/96 bill export with-databases-unlocked and databases-locked-p
40;; ------------- 0.94 = MCL-PPC 3.9
41;; 03/21/96 bill compile-and-load resignals any error it doesn't recognize
42;; 03/09/96 bill say ccl::*.fasl-pathname* instead of ".fasl".
43;; ------------- 0.93
44;; 08/11/95 bill translate this file's pathname to a physical one when
45;; defining the "wood" logical pathname to prevent
46;; a recursive definition.
47;; 08/11/95 bill compile-and-load deletes fasl files for other MCL versions.
48;; 08/11/95 bill load-wood loads big-io-buffer-patch if necessary
49;; 08/10/95 bill export p-assoc & p-do-btree
50;; 05/31/95 bill export make-shared-buffer, make-shared-buffer-pool
51;; 05/25/95 bill add disk-page-hash to *wood-files*
52;; ------------- 0.9
53;; 01/17/95 bill export p-store-pptr, pptr-pointer, pptr-pheap,
54;; with-transaction, start-transaction, commit-transaction,
55;; abort-transaction
56;; 11/02/94 ows export pptr, pheap-pathname
57;; 10/25/94 bill export pptr-p, p-loaded?, p-stored?,
58;; wood-disk-resident-slot-names, define-disk-resident-slots
59;; 03/14/94 bill Don't push anything onto *module-search-path*
60;; -------------- 0.8
61;; 12/27/93 bill export p-btree-count, p-hash-table-count, initialize-persistent-instance
62;; 12/17/93 bill Use "wood:wood;..." instead of "wood:..." to prevent
63;; bogus default directories.
64;; Add "version-control" to *wood-files*
65;; 03/29/93 bill Add "q" and "wood-gc" to *wood-files*
66;; -------------- 0.6
67;; 12/16/92 bill p-btree-clear -> p-clear-btree
68;; 10/21/92 bill p-nth, p-nthcdr
69;; 08/31/92 bill export p-make-load-function, p-make-load-function
70;; 08/06/92 bill (provide "WOOD")
71;; 07/30/92 bill export p-btree-p and p-hash-table-p
72;; -------------- 0.5
73;; 07/27/92 bill Export all documented symbols.
74;;
75
76(defpackage :wood
77 #+ppc-target
78 (:import-from "CCL"
79 ccl::databases-locked-p
80 ccl::funcall-with-databases-unlocked
81 ccl::with-databases-unlocked)
82 (:export #:load-wood
83 #:open-pheap #:close-pheap #:with-open-pheap #:root-object #:flush-pheap
84 #:make-shared-buffer #:make-shared-buffer-pool
85 #:pheap #:p-loading-pheap
86 #:p-load #:p-store #:p-stored? #:p-loaded?
87 #:p-make-area #:with-consing-area
88 #:p-cons #:p-list #:p-list-in-area #:p-make-list
89 #:p-make-uvector #:p-make-array #:p-vector
90 #:p-listp #:p-consp #:p-atom #:p-uvectorp #:p-packagep #:p-symbolp
91 #:p-stringp #:p-simple-string-p #:p-vectorp #:p-simple-vector-p #:p-arrayp
92 #:pload-barrier-p
93 #:p-car #:p-cdr #:p-caar #:p-cadr #:p-cdar #:p-cddr
94 #:p-caaar #:p-caadr #:p-cadar #:p-caddr #:p-cdaar #:p-cdadr #:p-cddar
95 #:p-cdddr #:p-caaaar #:p-caaadr #:p-caadar #:p-caaddr #:p-cadaar
96 #:p-cadadr #:p-caddar #:p-cadddr #:p-cdaaar #:p-cdaadr #:p-cdadar
97 #:p-cdaddr #:p-cddaar #:p-cddadr #:p-cdddar #:p-cddddr
98 #:p-nth #:p-nthcdr #:p-last #:p-delq #:p-dolist #:p-assoc
99 #:p-instance-class #:p-slot-value
100 #:p-uvsize #:p-uvref #:p-uvector-subtype-p #:p-svref #:p-%svref #:p-length
101 #:p-aref #:p-array-rank #:p-array-dimensions #:p-array-dimension
102 #:p-intern #:p-find-symbol #:p-find-package #:p-make-package
103 #:p-symbol-name #:p-symbol-package #:p-symbol-value
104 #:p-package-name #:p-package-nicknames
105 #:p-make-btree #:p-btree-p #:p-btree-lookup #:p-btree-store #:p-btree-delete
106 #:p-clear-btree #:p-map-btree #:p-do-btree #:p-btree-count #:p-map-btree-keystrings
107 #:p-make-hash-table #:p-hash-table-p #:p-gethash #:p-remhash #:p-clrhash
108 #:p-hash-table-size #:p-maphash #:p-hash-table-count
109 #:wood-slot-names-vector #:wood-slot-value #:initialize-persistent-instance
110 #:p-make-load-function #:p-make-load-function-object #:p-make-load-function-using-pheap
111 #:p-make-load-function-saving-slots #:progn-load-functions #:progn-init-functions
112 #:p-store-pptr #:opened-pheap
113 #:p-make-pload-barrier #:p-load-through-barrier
114 #:gc-pheap-file #:clear-memory<->disk-tables
115 #:with-egc #:*avoid-cons-caching*
116 #:pptr-p #:pptr #:pptr-pointer #:pptr-pheap
117 #:wood-disk-resident-slot-names #:define-disk-resident-slots
118 #:pheap-pathname #:move-pheap-file
119 #:with-databases-locked #:with-databases-unlocked #:databases-locked-p
120 #:with-transaction #:start-transaction #:commit-transaction #:abort-transaction
121 ))
122
123(in-package :wood)
124
125; Assume fixnum addresses.
126; Comment out this form to compile Wood for files larger than 256 megs (8 Megs in LWW)
127#-LispWorks4 ;; LWW4 fixnums are tiny.
128(eval-when (:compile-toplevel :execute :load-toplevel)
129 (pushnew :wood-fixnum-addresses *features*))
130
131;; For simpler conditionalizations
132#+(and ccl (not ppc-target))
133(eval-when (:compile-toplevel :execute :load-toplevel)
134 (pushnew :ccl-68k-target *features*))
135
136#|
137#+LispWorks
138(eval-when (:compile-toplevel :execute :load-toplevel)
139 ;; For some reason, in lispworks the SYSTEM package has the nickname :CCL, which makes it harder
140 ;; to catch porting errors here. This can be removed once the port is complete.
141 (let ((pkg (find-package "CCL")))
142 (when pkg
143 (rename-package pkg (package-name pkg) (remove "CCL" (package-nicknames pkg) :test #'equal)))))
144|#
145
146
147;; #+ccl (... #_Foo ...) errs out because #_ is undefined.
148#+LispWorks
149(eval-when (:compile-toplevel :execute :load-toplevel)
150 (when (null (get-dispatch-macro-character #\# #\_))
151 (set-dispatch-macro-character #\# #\_
152 #'(lambda(s c n)
153 (declare (ignore c n))
154 (read s nil nil t)
155 nil))))
156
157(setf (logical-pathname-translations "wood")
158 (let ((path (or *load-pathname* #+ccl *loading-file-source-file*
159 #+LispWorks dspec:*source-pathname*
160 #+LispWorks system:*current-pathname*)))
161 (if path
162 (let* ((dest-dir (make-pathname :device (pathname-device path)
163 :host (pathname-host path)
164 :directory (append
165 (or (pathname-directory path)
166 '(:absolute))
167 '(:wild-inferiors))
168 :name :wild
169 :type :wild))
170 (physical-dir (translate-logical-pathname dest-dir)))
171 ; This is what you'll get if you load this file
172 ; or evaluate this form from this buffer.
173 `(("wood;**;*.*" ,physical-dir)
174 ("**;*.*" ,physical-dir)))
175 ; This is what you'll get if you evalute this form
176 ; from the listener.
177 '(("wood;**;*.*" "ccl:wood;**;*.*")))))
178
179(defun fasl-pathname (pathname)
180 (merge-pathnames pathname
181 #+ccl ccl::*.fasl-pathname*
182 #+lispworks (make-pathname :type system:*binary-file-type*)))
183
184(defvar *debug-wood* nil)
185
186(defun compile-if-needed (file &optional force)
187 (let ((lisp (merge-pathnames file ".lisp"))
188 (fasl (fasl-pathname file)))
189 (when (or force
190 (not (probe-file fasl))
191 (> (file-write-date lisp) (file-write-date fasl)))
192 #+LispWorks
193 (compiler:with-optimization-level
194 (if *debug-wood*
195 (compiler::set-optimization-level :safety 3 :debug 3)
196 (compiler::set-optimization-level :speed 3 :safety 0 :debug 0 :float 0))
197 (compile-file lisp :verbose t))
198 #-LispWorks
199 (compile-file lisp :verbose t))))
200
201(defun compile-and-load (file &optional force-compile)
202 (compile-if-needed file force-compile)
203 (handler-bind ((simple-error
204 #'(lambda (condition)
205 (if (member (simple-condition-format-string condition)
206 '("Wrong FASL version." "Wrong PFSL version.")
207 :test 'equalp)
208 (progn
209 (format t "~&;Deleting FASL file from other MCL version...")
210 (delete-file (fasl-pathname file))
211 (return-from compile-and-load (compile-and-load file force-compile)))
212 (error condition)))))
213 (load file :verbose t)))
214
215(defparameter *wood-files*
216 '("compat"
217 #+ccl "block-io-mcl" #+ccl "split-lfun"
218 "q"
219 "disk-page-hash" "disk-cache" "woodequ" "disk-cache-accessors"
220 #+ccl "disk-cache-inspector" #+LispWorks "lw-inspector"
221 "persistent-heap" "version-control"
222 "btrees" "persistent-clos"
223 ;; Not ported yet
224 #-LispWorks "recovery" #-LispWorks "wood-gc"))
225
226(defun load-wood (&optional force-compile)
227 (with-compilation-unit ()
228 (compile-if-needed "wood:wood;load-wood")
229 #-lispworks (unless (boundp 'ccl::*elements-per-buffer*)
230 (compile-and-load "wood:patches;big-io-buffer-patch"))
231 (dolist (file *wood-files*)
232 (compile-and-load (merge-pathnames file "wood:wood;") force-compile))
233 #+ppc-target
234 (unless (fboundp 'ccl::databases-locked-p)
235 (compile-and-load "wood:patches;break-loop-patch" force-compile))
236 (provide "WOOD")))
237
238; This should be called only after load-wood.
239; It compiles the changed files
240(defun compile-wood ()
241 (with-compilation-unit ()
242 (compile-if-needed "wood:wood;load-wood")
243 (dolist (file *wood-files*)
244 (compile-if-needed (merge-pathnames file "wood:wood;")))))
245;;; 1 3/10/94 bill 1.8d247
246;;; 2 3/23/94 bill 1.8d277
247;;; 3 7/26/94 Derek 1.9d027
248;;; 4 9/19/94 Cassels 1.9d061
249;;; 5 11/01/94 Derek 1.9d085 Bill's Saving Library Task
250;;; 6 11/05/94 kab 1.9d087
251;;; 7 11/21/94 gsb 1.9d100
252;;; 2 2/18/95 RŽti 1.10d019
253;;; 3 3/23/95 bill 1.11d010
254;;; 4 4/19/95 bill 1.11d021
255;;; 5 6/02/95 bill 1.11d040
Note: See TracBrowser for help on using the repository browser.