File: static-alloc.impure.lisp

package info (click to toggle)
sbcl 2%3A2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 52,008 kB
  • sloc: lisp: 535,135; ansic: 42,629; sh: 5,737; asm: 2,406; pascal: 717; makefile: 432; python: 56; cpp: 27
file content (29 lines) | stat: -rw-r--r-- 1,332 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

#-relocatable-static-space
(dolist (type '(single-float double-float (unsigned-byte 8)
                (unsigned-byte 32) (signed-byte 32)
                base-char character))
  (let* ((vectors (loop
                     for i upto 128
                     collect (sb-int:make-static-vector
                              256 :element-type type)))
         (saps (mapcar #'sb-sys:vector-sap vectors)))
    (gc :full t)
    (assert (every #'sb-sys:sap=
                   saps
                   (mapcar #'sb-sys:vector-sap vectors)))))

;;; Compute the physical size of some vectors and make sure it's right.
;;; Why, you might ask, can't this simply use SB-VM::PRIMITIVE-OBJECT-SIZE
;;; to compare against the size of a non-static vector?
;;; Because PRIMITIVE-OBJECT-SIZE always gives you the _CORRECT_ answer
;;; for the object, not the amount of space the allocator took,
;;; and this test needs to assert correctness of the allocator.
#-relocatable-static-space
(dolist (type '(base-char character))
  (loop for i from 1 to 20
     do (let* ((before sb-vm:*static-space-free-pointer*)
              (obj (sb-vm::make-static-vector i :element-type type))
              (after sb-vm:*static-space-free-pointer*)
              (used (sb-sys:sap- after before)))
          (assert (= used (sb-vm::primitive-object-size obj))))))