1 ! Copyright (C) 2006, 2007 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel cpu.architecture cpu.arm.assembler
4 cpu.arm.architecture namespaces math sequences
5 generator generator.registers generator.fixup system layouts
9 : load-zone-ptr ( reg -- ) "nursery" f rot %alien-global ;
11 : %allot ( header size -- )
12 #! Store a pointer to 'size' bytes allocated from the
14 8 align ! align the size
15 R12 load-zone-ptr ! nusery -> r12
16 R11 R12 cell <+> LDR ! nursery.here -> r11
17 R11 R11 pick ADD ! increment r11
18 R11 R12 cell <+> STR ! r11 -> nursery.here
19 R11 R11 rot SUB ! old value
20 R12 swap type-number tag-fixnum MOV ! compute header
21 R12 R11 0 <+> STR ! store header
24 : %store-tagged ( reg tag -- )
25 >r dup fresh-object v>operand R11 r> tag-number ORR ;
27 : %allot-bignum ( #digits -- )
28 #! 1 cell header, 1 cell length, 1 cell sign, + digits
29 #! length is the # of digits + sign
30 bignum over 3 + cells %allot
31 R12 swap 1+ v>operand MOV ! compute the length
32 R12 R11 cell <+> STR ! store the length
35 : %allot-bignum-signed-1 ( dst src -- )
36 #! on entry, reg is a 30-bit quantity sign-extended to
38 #! exits with tagged ptr to bignum in reg.
43 0 >bignum pick EQ load-literal
47 ! is the fixnum negative?
52 dup v>operand dup 0 LT RSB
56 R12 R11 2 cells <+> STR
58 v>operand R11 3 cells <+> STR
59 ! tag the bignum, store it in reg
64 M: arm-backend %box-alien ( dst src -- )
67 over v>operand f v>operand EQ MOV
71 v>operand R11 3 cells <+> STR
74 R12 R11 1 cells <+> STR
75 ! Store underlying-alien slot
76 R12 R11 2 cells <+> STR
77 ! Store tagged ptr in reg