1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: math kernel layouts system strings words quotations byte-arrays
4 alien arrays literals sequences ;
7 ! These constants must match vm/memory.h
10 : card-mark ( -- n ) HEX: 40 HEX: 80 bitor ; inline
12 ! These constants must match vm/layouts.h
13 : slot-offset ( slot tag -- n ) [ bootstrap-cells ] dip - ; inline
15 : float-offset ( -- n ) 8 float type-number - ; inline
16 : string-offset ( -- n ) 4 string type-number slot-offset ; inline
17 : string-aux-offset ( -- n ) 2 string type-number slot-offset ; inline
18 : profile-count-offset ( -- n ) 8 \ word type-number slot-offset ; inline
19 : byte-array-offset ( -- n ) 16 byte-array type-number - ; inline
20 : alien-offset ( -- n ) 4 alien type-number slot-offset ; inline
21 : underlying-alien-offset ( -- n ) 1 alien type-number slot-offset ; inline
22 : tuple-class-offset ( -- n ) 1 tuple type-number slot-offset ; inline
23 : word-xt-offset ( -- n ) 10 \ word type-number slot-offset ; inline
24 : quot-xt-offset ( -- n ) 4 quotation type-number slot-offset ; inline
25 : word-code-offset ( -- n ) 11 \ word type-number slot-offset ; inline
26 : array-start-offset ( -- n ) 2 array type-number slot-offset ; inline
27 : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
30 CONSTANT: rc-absolute-cell 0
31 CONSTANT: rc-absolute 1
32 CONSTANT: rc-relative 2
33 CONSTANT: rc-absolute-ppc-2/2 3
34 CONSTANT: rc-absolute-ppc-2 4
35 CONSTANT: rc-relative-ppc-2 5
36 CONSTANT: rc-relative-ppc-3 6
37 CONSTANT: rc-relative-arm-3 7
38 CONSTANT: rc-indirect-arm 8
39 CONSTANT: rc-indirect-arm-pc 9
42 CONSTANT: rt-primitive 0
44 CONSTANT: rt-dispatch 2
47 CONSTANT: rt-xt-pic-tail 5
50 CONSTANT: rt-immediate 8
51 CONSTANT: rt-stack-chain 9
52 CONSTANT: rt-untagged 10
53 CONSTANT: rt-megamorphic-cache-hits 11
55 CONSTANT: rt-cards-offset 13
56 CONSTANT: rt-decks-offset 14
58 : rc-absolute? ( n -- ? )
59 ${ rc-absolute-ppc-2/2 rc-absolute-cell rc-absolute } member? ;