]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/constants/constants.factor
7d8ef4791b58d6b99d1262ddb1635fa865993901
[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 alien.syntax 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 : vm-spare-context-offset ( -- n ) 1 bootstrap-cells ; inline
32 : context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
33 : context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline
34 : context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline
35 : context-retainstack-offset ( -- n ) 3 bootstrap-cells ; inline
36 : context-callstack-save-offset ( -- n ) 4 bootstrap-cells ; inline
37 : context-callstack-seg-offset ( -- n ) 7 bootstrap-cells ; inline
38 : segment-start-offset ( -- n ) 0 bootstrap-cells ; inline
39 : segment-size-offset ( -- n ) 1 bootstrap-cells ; inline
40 : segment-end-offset ( -- n ) 2 bootstrap-cells ; inline
41
42 ! Relocation classes
43 ENUM: f
44     rc-absolute-cell
45     rc-absolute
46     rc-relative
47     rc-absolute-ppc-2/2
48     rc-absolute-ppc-2
49     rc-relative-ppc-2
50     rc-relative-ppc-3
51     rc-relative-arm-3
52     rc-indirect-arm
53     rc-indirect-arm-pc
54     rc-absolute-2
55     rc-absolute-1 ;
56
57 ! Relocation types
58 ENUM: f
59     rt-dlsym
60     rt-entry-point
61     rt-entry-point-pic
62     rt-entry-point-pic-tail
63     rt-here
64     rt-this
65     rt-literal
66     rt-untagged
67     rt-megamorphic-cache-hits
68     rt-vm
69     rt-cards-offset
70     rt-decks-offset
71     rt-exception-handler
72     rt-float ;
73
74 : rc-absolute? ( n -- ? )
75     ${
76         rc-absolute-ppc-2/2
77         rc-absolute-cell
78         rc-absolute
79         rc-absolute-2
80         rc-absolute-1
81     } member? ;