X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fdump.lisp;h=398bfca40e2b46a5c89d3aa237f098df4d0b8516;hb=11b8fcf55c80cb2686fb49663fa4d96f9b152ce4;hp=82469dd5dfc7e4294e1b0c89a7c8531b4e83e532;hpb=86210c4e406c1b2ff10cc3bac0e71435867db48b;p=sbcl.git diff --git a/src/compiler/dump.lisp b/src/compiler/dump.lisp index 82469dd..398bfca 100644 --- a/src/compiler/dump.lisp +++ b/src/compiler/dump.lisp @@ -246,6 +246,17 @@ ;;;; opening and closing fasl files +;;; A utility function to write strings to (unsigned-byte 8) streams. +;;; We restrict this to ASCII (with the averrance) because of +;;; ambiguity of higher bytes: Unicode, some ISO-8859-x, or what? This +;;; could be revisited in the event of doing funky things with stream +;;; encodings -- CSR, 2002-04-25 +(defun fasl-write-string (string stream) + (loop for char across string + do (let ((code (char-code char))) + (aver (<= 0 code 127)) + (write-byte code stream)))) + ;;; Open a fasl file, write its header, and return a FASL-OUTPUT ;;; object for dumping to it. Some human-readable information about ;;; the source code is given by the string WHERE. If BYTE-P is true, @@ -255,29 +266,31 @@ (declare (type pathname name)) (let* ((stream (open name :direction :output - :if-exists :new-version + :if-exists :supersede :element-type 'sb!assem:assembly-unit)) (res (make-fasl-output :stream stream))) ;; Begin the header with the constant machine-readable (and ;; semi-human-readable) string which is used to identify fasl files. - (write-string *fasl-header-string-start-string* stream) + (fasl-write-string *fasl-header-string-start-string* stream) ;; The constant string which begins the header is followed by ;; arbitrary human-readable text, terminated by a special ;; character code. - (with-standard-io-syntax - (format stream - "~% ~ - compiled from ~S~% ~ - at ~A~% ~ - on ~A~% ~ - using ~A version ~A~%" - where - (format-universal-time nil (get-universal-time)) - (machine-instance) - (sb!xc:lisp-implementation-type) - (sb!xc:lisp-implementation-version))) + (fasl-write-string + (with-standard-io-syntax + (format nil + "~% ~ + compiled from ~S~% ~ + at ~A~% ~ + on ~A~% ~ + using ~A version ~A~%" + where + (format-universal-time nil (get-universal-time)) + (machine-instance) + (sb!xc:lisp-implementation-type) + (sb!xc:lisp-implementation-version))) + stream) (dump-byte +fasl-header-string-stop-char-code+ res) ;; Finish the header by outputting fasl file implementation and @@ -563,9 +576,8 @@ ;;; this function is not parallel to other functions DUMP-FOO, e.g. ;;; DUMP-SYMBOL and DUMP-LIST. The mapping between names and behavior ;;; should be made more consistent. +(declaim (ftype (function (package fasl-output) index) dump-package)) (defun dump-package (pkg file) - (declare (type package pkg) (type fasl-output file)) - #+nil (declare (values index)) (declare (inline assoc)) (cond ((cdr (assoc pkg (fasl-output-packages file) :test #'eq))) (t @@ -808,8 +820,17 @@ ;; KLUDGE: What exactly does the (ASH .. -3) stuff do? -- WHN 19990902 (simple-bit-vector (dump-unsigned-vector 1 (ash (+ (the index len) 7) -3))) + ;; KLUDGE: This isn't the best way of expressing that the host + ;; may not have specializations for (unsigned-byte 2) and + ;; (unsigned-byte 4), which means that these types are + ;; type-equivalent to (simple-array (unsigned-byte 8) (*)); + ;; the workaround is to remove them from the etypecase, since + ;; they can't be dumped from the cross-compiler anyway. -- + ;; CSR, 2002-05-07 + #-sb-xc-host ((simple-array (unsigned-byte 2) (*)) (dump-unsigned-vector 2 (ash (+ (the index (ash len 1)) 7) -3))) + #-sb-xc-host ((simple-array (unsigned-byte 4) (*)) (dump-unsigned-vector 4 (ash (+ (the index (ash len 2)) 7) -3))) ((simple-array (unsigned-byte 8) (*))