(defvar *read-only*)
(defconstant read-only-core-space-id 3)
+(defconstant max-core-space-id 3)
+(defconstant deflated-core-space-id-flag 4)
+
(defconstant descriptor-low-bits 16
"the number of bits in the low half of the descriptor")
(defconstant target-space-alignment (ash 1 descriptor-low-bits)
\f
;;;; representation of descriptors
+(defun is-fixnum-lowtag (lowtag)
+ (zerop (logand lowtag sb!vm:fixnum-tag-mask)))
+
+(defun is-other-immediate-lowtag (lowtag)
+ ;; The other-immediate lowtags are similar to the fixnum lowtags, in
+ ;; that they have an "effective length" that is shorter than is used
+ ;; for the pointer lowtags. Unlike the fixnum lowtags, however, the
+ ;; other-immediate lowtags are always effectively two bits wide.
+ (= (logand lowtag 3) sb!vm:other-immediate-0-lowtag))
+
(defstruct (descriptor
(:constructor make-descriptor
(high low &optional gspace word-offset))
(def!method print-object ((des descriptor) stream)
(let ((lowtag (descriptor-lowtag des)))
(print-unreadable-object (des stream :type t)
- (cond ((or (= lowtag sb!vm:even-fixnum-lowtag)
- (= lowtag sb!vm:odd-fixnum-lowtag))
+ (cond ((is-fixnum-lowtag lowtag)
(let ((unsigned (logior (ash (descriptor-high des)
(1+ (- descriptor-low-bits
sb!vm:n-lowtag-bits)))
(if (> unsigned #x1FFFFFFF)
(- unsigned #x40000000)
unsigned))))
- ((or (= lowtag sb!vm:other-immediate-0-lowtag)
- (= lowtag sb!vm:other-immediate-1-lowtag)
- #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
- (= lowtag sb!vm:other-immediate-2-lowtag)
- #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
- (= lowtag sb!vm:other-immediate-3-lowtag))
+ ((is-other-immediate-lowtag lowtag)
(format stream
"for other immediate: #X~X, type #b~8,'0B"
(ash (descriptor-bits des) (- sb!vm:n-widetag-bits))
;; it's hard to see how it could have been wrong, since CMU CL
;; genesis worked. It would be nice to understand how this came
;; to be.. -- WHN 19990901
- (logior (ash bits (- 1 sb!vm:n-lowtag-bits))
+ (logior (ash bits (- sb!vm:n-fixnum-tag-bits))
(ash -1 (1+ sb!vm:n-positive-fixnum-bits)))
- (ash bits (- 1 sb!vm:n-lowtag-bits)))))
+ (ash bits (- sb!vm:n-fixnum-tag-bits)))))
(defun descriptor-word-sized-integer (des)
;; Extract an (unsigned-byte 32), from either its fixnum or bignum
;; representation.
(let ((lowtag (descriptor-lowtag des)))
- (if (or (= lowtag sb!vm:even-fixnum-lowtag)
- (= lowtag sb!vm:odd-fixnum-lowtag))
+ (if (is-fixnum-lowtag lowtag)
(make-random-descriptor (descriptor-fixnum des))
(read-wordindexed des 1))))
(defun make-fixnum-descriptor (num)
(when (>= (integer-length num)
- (1+ (- sb!vm:n-word-bits sb!vm:n-lowtag-bits)))
+ (- sb!vm:n-word-bits sb!vm:n-fixnum-tag-bits))
(error "~W is too big for a fixnum." num))
- (make-random-descriptor (ash num (1- sb!vm:n-lowtag-bits))))
+ (make-random-descriptor (ash num sb!vm:n-fixnum-tag-bits)))
(defun make-other-immediate-descriptor (data type)
(make-descriptor (ash data (- sb!vm:n-widetag-bits descriptor-low-bits))
(defun number-to-core (number)
(typecase number
(integer (if (< (integer-length number)
- (- (1+ sb!vm:n-word-bits) sb!vm:n-lowtag-bits))
+ (- sb!vm:n-word-bits sb!vm:n-fixnum-tag-bits))
(make-fixnum-descriptor number)
(bignum-to-core number)))
(ratio (number-pair-to-core (number-to-core (numerator number))
(cold-set-layout-slot result 'info *nil-descriptor*)
(cold-set-layout-slot result 'pure *nil-descriptor*)
(cold-set-layout-slot result 'n-untagged-slots nuntagged)
+ (cold-set-layout-slot result 'source-location *nil-descriptor*)
(cold-set-layout-slot result 'for-std-class-p *nil-descriptor*)
(setf (gethash name *cold-layouts*)
(subseq line (1+ p2)))
(values (parse-integer line :end p1 :radix 16)
(subseq line (1+ p2))))
+ ;; KLUDGE CLH 2010-05-31: on darwin, nm gives us
+ ;; _function but dlsym expects us to look up
+ ;; function, without the leading _ . Therefore, we
+ ;; strip it off here.
+ #!+darwin
+ (when (equal (char name 0) #\_)
+ (setf name (subseq name 1)))
(multiple-value-bind (old-value found)
(gethash name *cold-foreign-symbol-table*)
(when (and found
(warn "redefining ~S from #X~X to #X~X"
name old-value value)))
(/show "adding to *cold-foreign-symbol-table*:" name value)
- (setf (gethash name *cold-foreign-symbol-table*) value))))))
+ (setf (gethash name *cold-foreign-symbol-table*) value)
+ #!+win32
+ (let ((at-position (position #\@ name)))
+ (when at-position
+ (let ((name (subseq name 0 at-position)))
+ (multiple-value-bind (old-value found)
+ (gethash name *cold-foreign-symbol-table*)
+ (when (and found
+ (not (= old-value value)))
+ (warn "redefining ~S from #X~X to #X~X"
+ name old-value value)))
+ (setf (gethash name *cold-foreign-symbol-table*)
+ value)))))))))
(values)) ;; PROGN
(defun cold-foreign-symbol-address (name)
;; modified.
(copy-seq *fop-funs*))
-(defvar *normal-fop-funs*)
-
;;; Cause a fop to have a special definition for cold load.
;;;
;;; This is similar to DEFINE-FOP, but unlike DEFINE-FOP, this version
(defun cold-load (filename)
#!+sb-doc
"Load the file named by FILENAME into the cold load image being built."
- (let* ((*normal-fop-funs* *fop-funs*)
- (*fop-funs* *cold-fop-funs*)
+ (let* ((*fop-funs* *cold-fop-funs*)
(*cold-load-filename* (etypecase filename
(string filename)
(pathname (namestring filename)))))
(define-cold-fop (fop-empty-list) nil)
(define-cold-fop (fop-truth) t)
-(define-cold-fop (fop-normal-load :stackp nil)
- (setq *fop-funs* *normal-fop-funs*))
-
-(define-fop (fop-maybe-cold-load 82 :stackp nil)
- (when *cold-load-filename*
- (setq *fop-funs* *cold-fop-funs*)))
-
-(define-cold-fop (fop-maybe-cold-load :stackp nil))
-
(clone-cold-fop (fop-struct)
(fop-small-struct)
(let* ((size (clone-arg))
(let ((index (read-arg ,package-len)))
(push-fop-table
(cold-load-symbol (read-arg ,pname-len)
- (svref *current-fop-table* index)))))))
+ (ref-fop-table index)))))))
(frob fop-symbol-in-package-save #.sb!vm:n-word-bytes #.sb!vm:n-word-bytes)
(frob fop-small-symbol-in-package-save 1 #.sb!vm:n-word-bytes)
(frob fop-symbol-in-byte-package-save #.sb!vm:n-word-bytes 1)
(let ((total-elements 1))
(dotimes (axis rank)
(let ((dim (pop-stack)))
- (unless (or (= (descriptor-lowtag dim) sb!vm:even-fixnum-lowtag)
- (= (descriptor-lowtag dim) sb!vm:odd-fixnum-lowtag))
+ (unless (is-fixnum-lowtag (descriptor-lowtag dim))
(error "non-fixnum dimension? (~S)" dim))
(setf total-elements
(* total-elements
(logior (ash (descriptor-high dim)
(- descriptor-low-bits
- (1- sb!vm:n-lowtag-bits)))
+ sb!vm:n-fixnum-tag-bits))
(ash (descriptor-low dim)
- (- 1 sb!vm:n-lowtag-bits)))))
+ sb!vm:n-fixnum-tag-bits))))
(write-wordindexed result
(+ sb!vm:array-dimensions-offset axis)
dim)))
;;;; cold fops for fixing up circularities
(define-cold-fop (fop-rplaca :pushp nil)
- (let ((obj (svref *current-fop-table* (read-word-arg)))
+ (let ((obj (ref-fop-table (read-word-arg)))
(idx (read-word-arg)))
(write-memory (cold-nthcdr idx obj) (pop-stack))))
(define-cold-fop (fop-rplacd :pushp nil)
- (let ((obj (svref *current-fop-table* (read-word-arg)))
+ (let ((obj (ref-fop-table (read-word-arg)))
(idx (read-word-arg)))
(write-wordindexed (cold-nthcdr idx obj) 1 (pop-stack))))
(define-cold-fop (fop-svset :pushp nil)
- (let ((obj (svref *current-fop-table* (read-word-arg)))
+ (let ((obj (ref-fop-table (read-word-arg)))
(idx (read-word-arg)))
(write-wordindexed obj
(+ idx
(pop-stack))))
(define-cold-fop (fop-structset :pushp nil)
- (let ((obj (svref *current-fop-table* (read-word-arg)))
+ (let ((obj (ref-fop-table (read-word-arg)))
(idx (read-word-arg)))
(write-wordindexed obj (1+ idx) (pop-stack))))
(maybe-record-with-munged-name "-SUBTYPE" "subtype_" 4)
(maybe-record-with-munged-name "-SC-NUMBER" "sc_" 5)
(maybe-record-with-translated-name '("-SIZE") 6)
- (maybe-record-with-translated-name '("-START" "-END" "-PAGE-BYTES") 7 :large t)
+ (maybe-record-with-translated-name '("-START" "-END" "-PAGE-BYTES"
+ "-CARD-BYTES" "-GRANULARITY")
+ 7 :large t)
(maybe-record-with-translated-name '("-CORE-ENTRY-TYPE-CODE") 8)
(maybe-record-with-translated-name '("-CORE-SPACE-ID") 9)
+ (maybe-record-with-translated-name '("-CORE-SPACE-ID-FLAG") 9)
(maybe-record-with-translated-name '("-GENERATION+") 10))))))
;; KLUDGE: these constants are sort of important, but there's no
;; pleasing way to inform the code above about them. So we fake
(format t "/* These offsets are SLOT-OFFSET * N-WORD-BYTES - LOWTAG~%")
(format t " * so they work directly on tagged addresses. */~2%")
(let ((name (sb!vm:primitive-object-name obj))
- (lowtag (eval (sb!vm:primitive-object-lowtag obj))))
- (when lowtag
- (dolist (slot (sb!vm:primitive-object-slots obj))
- (format t "#define ~A_~A_OFFSET ~D~%"
- (c-symbol-name name)
- (c-symbol-name (sb!vm:slot-name slot))
- (- (* (sb!vm:slot-offset slot) sb!vm:n-word-bytes) lowtag)))
- (terpri)))
+ (lowtag (or (symbol-value (sb!vm:primitive-object-lowtag obj))
+ 0)))
+ (dolist (slot (sb!vm:primitive-object-slots obj))
+ (format t "#define ~A_~A_OFFSET ~D~%"
+ (c-symbol-name name)
+ (c-symbol-name (sb!vm:slot-name slot))
+ (- (* (sb!vm:slot-offset slot) sb!vm:n-word-bytes) lowtag)))
+ (terpri))
(format t "#endif /* LANGUAGE_ASSEMBLY */~2%"))
(defun write-structure-object (dd)
(defconstant new-directory-core-entry-type-code 3861)
(defconstant initial-fun-core-entry-type-code 3863)
(defconstant page-table-core-entry-type-code 3880)
-#!+(and sb-lutex sb-thread)
-(defconstant lutex-table-core-entry-type-code 3887)
(defconstant end-core-entry-type-code 3840)
(declaim (ftype (function (sb!vm:word) sb!vm:word) write-word))