1 ;;;; support routines for arrays and vectors
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 (define-assembly-routine (allocate-vector
16 (:translate allocate-vector)
17 (:arg-types positive-fixnum
20 ((:arg type any-reg a0-offset)
21 (:arg length any-reg a1-offset)
22 (:arg words any-reg a2-offset)
23 (:res result descriptor-reg a0-offset)
25 (:temp ndescr non-descriptor-reg nl0-offset)
26 (:temp vector descriptor-reg a3-offset))
28 (inst or vector alloc-tn other-pointer-lowtag)
29 ;; boxed words == unboxed bytes
30 (inst add ndescr words (* (1+ vector-data-offset) n-word-bytes))
32 (inst add alloc-tn ndescr)
33 (inst srl ndescr type word-shift)
34 (storew ndescr vector 0 other-pointer-lowtag)
35 (storew length vector vector-length-slot other-pointer-lowtag))
36 ;; This makes sure the zero byte at the end of a string is paged in so
37 ;; the kernel doesn't bitch if we pass it the string.
38 (storew zero-tn alloc-tn 0)