717fa078e7e88edd97b5f9e178511f39f09ca0a5
[sbcl.git] / src / assembly / sparc / array.lisp
1 ;;;; support routines for arrays and vectors
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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.
11
12 (in-package "SB!VM")
13
14 (define-assembly-routine (allocate-vector
15                           (:policy :fast-safe)
16                           (:translate allocate-vector)
17                           (:arg-types positive-fixnum
18                                       positive-fixnum
19                                       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)
24
25                           (:temp ndescr non-descriptor-reg nl0-offset)
26                           (:temp vector descriptor-reg a3-offset))
27   (pseudo-atomic ()
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))
31     (inst andn ndescr 7)
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)
39   (move result vector))