0.9.2.43:
[sbcl/lichteblau.git] / src / code / alloc.lisp
blobe325f375ce5679fd10cf818be7842071ae47022b
1 ;;;; Lisp-side allocation (used currently only for direct allocation
2 ;;;; to static space).
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6 ;;;;
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
13 (in-package "SB!VM")
15 #!-sb-fluid (declaim (inline store-word))
16 (defun store-word (word base &optional (offset 0) (lowtag 0))
17 (declare (type (unsigned-byte #.sb!vm:n-word-bits) word base offset)
18 (type (unsigned-byte #.n-lowtag-bits) lowtag))
19 (setf (sap-ref-word (int-sap base) (- (ash offset word-shift) lowtag)) word))
21 (defun allocate-static-vector (widetag length words)
22 (declare (type (unsigned-byte #.n-widetag-bits) widetag)
23 (type (unsigned-byte #.n-word-bits) words)
24 (type index length))
25 (handler-case
26 ;; FIXME: Is WITHOUT-GCING enough to do lisp-side allocation
27 ;; to static space, or should we have WITHOUT-INTERRUPTS here
28 ;; as well?
29 (without-gcing
30 (let* ((pointer *static-space-free-pointer*) ; in words
31 (free (* pointer n-word-bytes))
32 (vector (logior free other-pointer-lowtag)) ; in bytes, yay
33 ;; rounded to dual word boundary
34 (nwords (logandc2 (+ lowtag-mask (+ words vector-data-offset 1))
35 lowtag-mask))
36 (new-pointer (+ *static-space-free-pointer* nwords))
37 (new-free (* new-pointer n-word-bytes)))
38 (unless (> static-space-end new-free)
39 (error 'simple-storage-condition
40 :format-control "Not enough memory left in static space to ~
41 allocate vector."))
42 (store-word widetag
43 vector 0 other-pointer-lowtag)
44 (store-word (ash length word-shift)
45 vector vector-length-slot other-pointer-lowtag)
46 (store-word 0 new-free)
47 (prog1
48 (make-lisp-obj vector)
49 (setf *static-space-free-pointer* new-pointer))))
50 (serious-condition (c)
51 ;; unwind from WITHOUT-GCING
52 (error c))))