0.pre7.58:
[sbcl.git] / src / assembly / x86 / alloc.lisp
1 ;;;; allocating simple objects
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 \f
14 ;;;; from signed/unsigned
15
16 ;;; KLUDGE: Why don't we want vops for this one and the next
17 ;;; one? -- WHN 19990916
18 #+sb-assembling ; We don't want a vop for this one.
19 (define-assembly-routine
20     (move-from-signed)
21     ((:temp eax unsigned-reg eax-offset)
22      (:temp ebx unsigned-reg ebx-offset))
23   (inst mov ebx eax)
24   (inst shl ebx 1)
25   (inst jmp :o bignum)
26   (inst shl ebx 1)
27   (inst jmp :o bignum)
28   (inst ret)
29   BIGNUM
30
31   (with-fixed-allocation (ebx bignum-widetag (+ bignum-digits-offset 1))
32     (storew eax ebx bignum-digits-offset other-pointer-lowtag))
33
34   (inst ret))
35
36 #+sb-assembling ; We don't want a vop for this one either.
37 (define-assembly-routine
38   (move-from-unsigned)
39   ((:temp eax unsigned-reg eax-offset)
40    (:temp ebx unsigned-reg ebx-offset))
41
42   (inst test eax #xe0000000)
43   (inst jmp :nz bignum)
44   ;; Fixnum
45   (inst mov ebx eax)
46   (inst shl ebx 2)
47   (inst ret)
48
49   BIGNUM
50   ;;; Note: On the mips port space for a two word bignum is always
51   ;;; allocated and the header size is set to either one or two words
52   ;;; as appropriate. On the mips port this is faster, and smaller
53   ;;; inline, but produces more garbage. The inline x86 version uses
54   ;;; the same approach, but here we save garbage and allocate the
55   ;;; smallest possible bignum.
56   (inst jmp :ns one-word-bignum)
57   (inst mov ebx eax)
58
59   ;; Two word bignum
60   (with-fixed-allocation (ebx bignum-widetag (+ bignum-digits-offset 2))
61     (storew eax ebx bignum-digits-offset other-pointer-lowtag))
62   (inst ret)
63
64   ONE-WORD-BIGNUM
65   (with-fixed-allocation (ebx bignum-widetag (+ bignum-digits-offset 1))
66     (storew eax ebx bignum-digits-offset other-pointer-lowtag))
67   (inst ret))