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