e94fa846c19c0060e6d444ceaf4dc9f9e0d4d352
[sbcl.git] / src / assembly / ppc / array.lisp
1 ;;;; various array operations that are too expensive (in space) to do
2 ;;;; inline
3
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.
12
13 (in-package "SB!VM")
14 \f
15 (define-assembly-routine (allocate-vector
16                           (:policy :fast-safe)
17                           (:translate allocate-vector)
18                           (:arg-types positive-fixnum
19                                       positive-fixnum
20                                       positive-fixnum))
21     ((:arg type any-reg a0-offset)
22      (:arg length any-reg a1-offset)
23      (:arg words any-reg a2-offset)
24      (:res result descriptor-reg a0-offset)
25
26      (:temp ndescr non-descriptor-reg nl0-offset)
27      (:temp pa-flag non-descriptor-reg nl3-offset)
28      (:temp vector descriptor-reg a3-offset))
29   (pseudo-atomic (pa-flag)
30     (inst ori vector alloc-tn other-pointer-lowtag)
31     ;; boxed words == unboxed bytes
32     (inst addi ndescr words (* (1+ vector-data-offset) n-word-bytes))
33     (inst clrrwi ndescr ndescr n-lowtag-bits)
34     (inst add alloc-tn alloc-tn ndescr)
35     (inst srwi ndescr type word-shift)
36     (storew ndescr vector 0 other-pointer-lowtag)
37     (storew length vector vector-length-slot other-pointer-lowtag))
38   ;; This makes sure the zero byte at the end of a string is paged in so
39   ;; the kernel doesn't bitch if we pass it the string.
40   (storew zero-tn alloc-tn 0)
41   (move result vector))
42