]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/constants/constants.factor
58586e73045a309d0e5937bd055848b95ced17eb
[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: alien arrays byte-arrays kernel layouts literals math
4 quotations sequences strings words ;
5 IN: compiler.constants
6
7 CONSTANT: card-bits 8
8 CONSTANT: deck-bits 18
9
10 : card-mark ( -- n ) 0x40 0x80 bitor ; inline
11
12 : slot-offset ( slot tag -- n ) [ bootstrap-cells ] dip - ; inline
13
14 : float-offset ( -- n ) 8 float type-number - ; inline
15 : string-offset ( -- n ) 4 string type-number slot-offset ; inline
16 : byte-array-offset ( -- n ) 16 byte-array type-number - ; inline
17 : alien-offset ( -- n ) 4 alien type-number slot-offset ; inline
18 : tuple-class-offset ( -- n ) 1 tuple type-number slot-offset ; inline
19 : word-entry-point-offset ( -- n ) 9 \ word type-number slot-offset ; inline
20 : quot-entry-point-offset ( -- n ) 4 quotation type-number slot-offset ; inline
21 : array-start-offset ( -- n ) 2 array type-number slot-offset ; inline
22 : callstack-length-offset ( -- n ) 1 \ callstack type-number slot-offset ; inline
23 : callstack-top-offset ( -- n ) 2 \ callstack type-number slot-offset ; inline
24 : context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
25 : context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline
26 : context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline
27 : context-retainstack-offset ( -- n ) 3 bootstrap-cells ; inline
28 : context-callstack-save-offset ( -- n ) 4 bootstrap-cells ; inline
29 : context-callstack-seg-offset ( -- n ) 7 bootstrap-cells ; inline
30 : segment-start-offset ( -- n ) 0 bootstrap-cells ; inline
31 : segment-end-offset ( -- n ) 2 bootstrap-cells ; inline
32
33 ! Offsets in vm struct. Should be kept in sync with:
34 !   vm/vm.hpp
35 : vm-context-offset ( -- n )
36     0 bootstrap-cells ; inline
37 : vm-spare-context-offset ( -- n )
38     1 bootstrap-cells ; inline
39 : vm-signal-handler-addr-offset ( -- n )
40     8 bootstrap-cells ; inline
41 : vm-fault-flag-offset ( -- n )
42     9 bootstrap-cells ; inline
43 : vm-special-object-offset ( n -- offset )
44     bootstrap-cells 10 bootstrap-cells + ;
45
46 CONSTANT: rc-absolute-cell 0
47 CONSTANT: rc-absolute 1
48 CONSTANT: rc-relative 2
49 CONSTANT: rc-absolute-ppc-2/2 3
50 CONSTANT: rc-absolute-ppc-2 4
51 CONSTANT: rc-relative-ppc-2-pc 5
52 CONSTANT: rc-relative-ppc-3-pc 6
53 CONSTANT: rc-absolute-2 10
54 CONSTANT: rc-absolute-1 11
55 CONSTANT: rc-absolute-ppc-2/2/2/2 12
56
57 CONSTANT: rt-dlsym 0
58 CONSTANT: rt-entry-point 1
59 CONSTANT: rt-entry-point-pic 2
60 CONSTANT: rt-entry-point-pic-tail 3
61 CONSTANT: rt-here 4
62 CONSTANT: rt-this 5
63 CONSTANT: rt-literal 6
64 CONSTANT: rt-untagged 7
65 CONSTANT: rt-megamorphic-cache-hits 8
66 CONSTANT: rt-vm 9
67 CONSTANT: rt-cards-offset 10
68 CONSTANT: rt-decks-offset 11
69 CONSTANT: rt-dlsym-toc 13
70 CONSTANT: rt-inline-cache-miss 14
71 CONSTANT: rt-safepoint 15
72
73 : rc-absolute? ( n -- ? )
74     ${
75         $ rc-absolute-ppc-2/2
76         $ rc-absolute-cell
77         $ rc-absolute
78         $ rc-absolute-2
79         $ rc-absolute-1
80     } member? ;