7f428e7eed9939994f32ba36563ac3bf58114c0a
[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     (inst add ndescr words (* (1+ vector-data-offset) n-word-bytes))
30     (inst andn ndescr 7)
31     (inst add alloc-tn ndescr)
32     (inst srl ndescr type word-shift)
33     (storew ndescr vector 0 other-pointer-lowtag)
34     (storew length vector vector-length-slot other-pointer-lowtag))
35   ;; This makes sure the zero byte at the end of a string is paged in so
36   ;; the kernel doesn't bitch if we pass it the string.
37   (storew zero-tn alloc-tn 0)
38   (move result vector))