1 ;;;; target-only code that knows how to load compiled code directly
4 ;;;; FIXME: The filename here is confusing because "core" here means
5 ;;;; "main memory", while elsewhere in the system it connotes a
6 ;;;; ".core" file dumping the contents of main memory.
8 ;;;; This software is part of the SBCL system. See the README file for
11 ;;;; This software is derived from the CMU CL system, which was
12 ;;;; written at Carnegie Mellon University and released into the
13 ;;;; public domain. The software is in the public domain and is
14 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
15 ;;;; files for more information.
19 ;;; Make a function entry, filling in slots from the ENTRY-INFO.
20 (defun make-fun-entry (entry-info code-obj object)
21 (declare (type entry-info entry-info) (type core-object object))
22 (let ((offset (label-position (entry-info-offset entry-info))))
23 (declare (type index offset))
24 (unless (zerop (logand offset sb!vm:lowtag-mask))
25 (error "Unaligned function object, offset = #X~X." offset))
26 (let ((res (%primitive compute-fun code-obj offset)))
27 (setf (%simple-fun-self res) res)
28 (setf (%simple-fun-next res) (%code-entry-points code-obj))
29 (setf (%code-entry-points code-obj) res)
30 (setf (%simple-fun-name res) (entry-info-name entry-info))
31 (setf (%simple-fun-arglist res) (entry-info-arguments entry-info))
32 (setf (%simple-fun-type res) (entry-info-type entry-info))
34 (note-fun entry-info res object))))
36 ;;; Dump a component to core. We pass in the assembler fixups, code
37 ;;; vector and node info.
38 (defun make-core-component (component segment length trace-table fixup-notes object)
39 (declare (type component component)
40 (type sb!assem:segment segment)
42 (list trace-table fixup-notes)
43 (type core-object object))
45 (let* ((2comp (component-info component))
46 (constants (ir2-component-constants 2comp))
47 (trace-table (pack-trace-table trace-table))
48 (trace-table-len (length trace-table))
49 (trace-table-bits (* trace-table-len tt-bits-per-entry))
50 (total-length (+ length
51 (ceiling trace-table-bits sb!vm:n-byte-bits)))
52 (box-num (- (length constants) sb!vm:code-trace-table-offset-slot))
54 ;; FIXME: In CMU CL the X86 behavior here depended on
55 ;; *ENABLE-DYNAMIC-SPACE-CODE*, but in SBCL we always use
56 ;; dynamic space code, so we shoudl just rename the
57 ;; allocate-dynamic-code-object vop and lose this #+ stuff
59 (%primitive allocate-dynamic-code-object box-num total-length)
61 (%primitive allocate-code-object box-num total-length))
62 (fill-ptr (code-instructions code-obj)))
63 (declare (type index box-num total-length))
65 (sb!assem:on-segment-contents-vectorly
68 (declare (type (simple-array sb!assem:assembly-unit 1) v))
69 (copy-byte-vector-to-system-area v fill-ptr)
70 (setf fill-ptr (sap+ fill-ptr (length v)))))
72 (do-core-fixups code-obj fixup-notes)
74 (dolist (entry (ir2-component-entries 2comp))
75 (make-fun-entry entry code-obj object))
77 (sb!vm:sanctify-for-execution code-obj)
79 (let ((info (debug-info-for-component component)))
80 (push info (core-object-debug-info object))
81 (setf (%code-debug-info code-obj) info))
83 (setf (code-header-ref code-obj sb!vm:code-trace-table-offset-slot)
85 (copy-to-system-area trace-table
86 (* sb!vm:vector-data-offset sb!vm:n-word-bits)
91 (do ((index sb!vm:code-constants-offset (1+ index)))
92 ((>= index (length constants)))
93 (let ((const (aref constants index)))
97 (setf (code-header-ref code-obj index)
98 (constant-value const)))
102 (reference-core-fun code-obj index (cdr const) object))
104 (setf (code-header-ref code-obj index)
105 (fdefinition-object (cdr const) t))))))))))