]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/constants/constants.factor
Stop wearing monocle and use the term "entry point" instead of "XT" throughout VM...
[factor.git] / basis / compiler / constants / constants.factor
1 ! Copyright (C) 2008, 2010 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 ;
5 IN: compiler.constants
6
7 ! These constants must match vm/memory.h
8 CONSTANT: card-bits 8
9 CONSTANT: deck-bits 18
10 : card-mark ( -- n ) HEX: 40 HEX: 80 bitor ; inline
11
12 ! These constants must match vm/layouts.h
13 : slot-offset ( slot tag -- n ) [ bootstrap-cells ] dip - ; inline
14
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-entry-point-offset ( -- n ) 10 \ word type-number slot-offset ; inline
24 : quot-entry-point-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
28 : callstack-length-offset ( -- n ) 1 \ callstack type-number slot-offset ; inline
29 : callstack-top-offset ( -- n ) 2 \ callstack type-number slot-offset ; inline
30 : vm-context-offset ( -- n ) 0 bootstrap-cells ; inline
31 : context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
32 : context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline
33 : context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline
34 : context-retainstack-offset ( -- n ) 3 bootstrap-cells ; inline
35
36 ! Relocation classes
37 CONSTANT: rc-absolute-cell 0
38 CONSTANT: rc-absolute 1
39 CONSTANT: rc-relative 2
40 CONSTANT: rc-absolute-ppc-2/2 3
41 CONSTANT: rc-absolute-ppc-2 4
42 CONSTANT: rc-relative-ppc-2 5
43 CONSTANT: rc-relative-ppc-3 6
44 CONSTANT: rc-relative-arm-3 7
45 CONSTANT: rc-indirect-arm 8
46 CONSTANT: rc-indirect-arm-pc 9
47 CONSTANT: rc-absolute-2 10
48
49 ! Relocation types
50 CONSTANT: rt-primitive 0
51 CONSTANT: rt-dlsym 1
52 CONSTANT: rt-entry-point 2
53 CONSTANT: rt-entry-point-pic 3
54 CONSTANT: rt-entry-point-pic-tail 4
55 CONSTANT: rt-here 5
56 CONSTANT: rt-this 6
57 CONSTANT: rt-literal 7
58 CONSTANT: rt-untagged 8
59 CONSTANT: rt-megamorphic-cache-hits 9
60 CONSTANT: rt-vm 10
61 CONSTANT: rt-cards-offset 11
62 CONSTANT: rt-decks-offset 12
63
64 : rc-absolute? ( n -- ? )
65     ${ rc-absolute-ppc-2/2 rc-absolute-cell rc-absolute } member? ;