0.8.3.39:
[sbcl.git] / src / assembly / mips / 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 nl4-offset))
28   ;; This is kinda sleezy, changing words like this.  But we can because
29   ;; the vop thinks it is temporary.
30   (inst addu words (+ (1- (ash 1 n-lowtag-bits))
31                       (* vector-data-offset n-word-bytes)))
32   (inst li ndescr (lognot lowtag-mask))
33   (inst and words ndescr)
34   (inst srl ndescr type word-shift)
35
36   (pseudo-atomic (pa-flag)
37     (inst or result alloc-tn other-pointer-lowtag)
38     (inst addu alloc-tn words)
39     (storew ndescr result 0 other-pointer-lowtag)
40     (storew length result vector-length-slot other-pointer-lowtag)))