]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/constants/constants.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / compiler / constants / constants.factor
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 ;
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 : header-offset ( -- n ) object tag-number neg ; inline
14 : float-offset ( -- n ) 8 float tag-number - ; inline
15 : string-offset ( -- n ) 4 bootstrap-cells string tag-number - ; inline
16 : string-aux-offset ( -- n ) 2 bootstrap-cells string tag-number - ; inline
17 : profile-count-offset ( -- n ) 7 bootstrap-cells \ word tag-number - ; inline
18 : byte-array-offset ( -- n ) 2 bootstrap-cells byte-array tag-number - ; inline
19 : alien-offset ( -- n ) 3 bootstrap-cells alien tag-number - ; inline
20 : underlying-alien-offset ( -- n ) bootstrap-cell alien tag-number - ; inline
21 : tuple-class-offset ( -- n ) bootstrap-cell tuple tag-number - ; inline
22 : word-xt-offset ( -- n ) 9 bootstrap-cells \ word tag-number - ; inline
23 : quot-xt-offset ( -- n ) 5 bootstrap-cells quotation tag-number - ; inline
24 : word-code-offset ( -- n ) 10 bootstrap-cells \ word tag-number - ; inline
25 : array-start-offset ( -- n ) 2 bootstrap-cells array tag-number - ; inline
26 : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
27
28 ! Relocation classes
29 CONSTANT: rc-absolute-cell    0
30 CONSTANT: rc-absolute         1
31 CONSTANT: rc-relative         2
32 CONSTANT: rc-absolute-ppc-2/2 3
33 CONSTANT: rc-absolute-ppc-2   4
34 CONSTANT: rc-relative-ppc-2   5
35 CONSTANT: rc-relative-ppc-3   6
36 CONSTANT: rc-relative-arm-3   7
37 CONSTANT: rc-indirect-arm     8
38 CONSTANT: rc-indirect-arm-pc  9
39
40 ! Relocation types
41 CONSTANT: rt-primitive   0
42 CONSTANT: rt-dlsym       1
43 CONSTANT: rt-dispatch    2
44 CONSTANT: rt-xt          3
45 CONSTANT: rt-xt-pic      4
46 CONSTANT: rt-here        5
47 CONSTANT: rt-this        6
48 CONSTANT: rt-immediate   7
49 CONSTANT: rt-stack-chain 8
50 CONSTANT: rt-untagged    9
51
52 : rc-absolute? ( n -- ? )
53     [ rc-absolute-ppc-2/2 = ]
54     [ rc-absolute-cell = ]
55     [ rc-absolute = ]
56     tri or or ;