1 ;;;; dumping functionality which isn't needed in cross-compilation
2 ;;;; (and, typically, which is awkward to implement in the
3 ;;;; cross-compilation host)
5 ;;;; This software is part of the SBCL system. See the README file for
8 ;;;; This software is derived from the CMU CL system, which was
9 ;;;; written at Carnegie Mellon University and released into the
10 ;;;; public domain. The software is in the public domain and is
11 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
12 ;;;; files for more information.
14 (in-package "SB!FASL")
16 ;;; a helper function shared by DUMP-SIMPLE-CHARACTER-STRING and
17 ;;; DUMP-SYMBOL (in the target compiler: the cross-compiler uses the
18 ;;; portability knowledge and always dumps BASE-STRINGS).
20 (defun dump-characters-of-string (s fasl-output
)
21 (declare (type string s
) (type fasl-output fasl-output
))
23 (dump-unsigned-byte-32 (char-code c
) fasl-output
))
26 (defun dump-simple-character-string (s file
)
27 (declare (type (simple-array character
(*)) s
))
28 (dump-fop 'fop-character-string file
(length s
))
29 (dump-characters-of-string s file
)
32 ;;; Dump the first N bytes of VEC out to FILE. VEC is some sort of unboxed
33 ;;; vector-like thing that we can BLT from.
34 (defun dump-raw-bytes (vec n fasl-output
)
35 (declare (type index n
) (type fasl-output fasl-output
))
36 ;; FIXME: Why not WRITE-SEQUENCE?
37 (sb!impl
::buffer-output
(fasl-output-stream fasl-output
) vec
0 n
)
40 ;;; Dump a multi-dimensional array. Note: any displacements are folded out.
42 ;;; This isn't needed at cross-compilation time because SBCL doesn't
43 ;;; use multi-dimensional arrays internally. And it's hard to
44 ;;; implement at cross-compilation time because it uses
45 ;;; WITH-ARRAY-DATA. If it ever becomes necessary to implement it at
46 ;;; cross-compilation time, it might possible to use ROW-MAJOR-AREF
47 ;;; stuff to do it portably.
48 (defun dump-multi-dim-array (array file
)
49 (let ((rank (array-rank array
)))
51 (dump-integer (array-dimension array i
) file
))
52 (with-array-data ((vector array
) (start) (end))
53 (if (and (= start
0) (= end
(length vector
)))
54 (sub-dump-object vector file
)
55 (sub-dump-object (subseq vector start end
) file
)))
56 (dump-fop 'fop-array file
)
58 (eq-save-object array file
)))
60 #!+(and long-float x86
)
61 (defun dump-long-float (float file
)
62 (declare (long-float float
))
63 (let ((exp-bits (long-float-exp-bits float
))
64 (high-bits (long-float-high-bits float
))
65 (low-bits (long-float-low-bits float
)))
66 ;; We could get away with DUMP-WORD here, since the x86 has 4-byte words,
67 ;; but we prefer to make things as explicit as possible.
69 (dump-integer-as-n-bytes low-bits
4 file
)
70 (dump-integer-as-n-bytes high-bits
4 file
)
71 (dump-integer-as-n-bytes exp-bits
2 file
)))
73 #!+(and long-float sparc
)
74 (defun dump-long-float (float file
)
75 (declare (long-float float
))
76 (let ((exp-bits (long-float-exp-bits float
))
77 (high-bits (long-float-high-bits float
))
78 (mid-bits (long-float-mid-bits float
))
79 (low-bits (long-float-low-bits float
)))
80 ;; We could get away with DUMP-WORD here, since the sparc has 4-byte
81 ;; words, but we prefer to make things as explicit as possible.
83 (dump-integer-as-n-bytes low-bits
4 file
)
84 (dump-integer-as-n-bytes mid-bits
4 file
)
85 (dump-integer-as-n-bytes high-bits
4 file
)
86 (dump-integer-as-n-bytes exp-bits
4 file
)))