]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/image-analyzer/vm/vm.factor
tools.image-analyzer: new set of vocabs for reading and analyzing factor images
[factor.git] / extra / tools / image-analyzer / vm / vm.factor
1 USING: alien.c-types assocs classes.struct kernel.private vm ;
2 IN: tools.image-analyzer.vm
3
4 ! These structs and words correspond to vm/image.hpp
5 STRUCT: image-header
6     { magic cell }
7     { version cell }
8     { data-relocation-base cell }
9     { data-size cell }
10     { code-relocation-base cell }
11     { code-size cell }
12     { true-object cell }
13     { bignum-zero cell }
14     { bignum-pos-one cell }
15     { bignum-neg-one cell }
16     { special-objects cell[special-object-count] } ;
17
18 ! These structs and words correspond to vm/layouts.hpp
19 STRUCT: object
20     { header cell } ;
21
22 STRUCT: alien
23     { header cell }
24     { base cell }
25     { expired cell }
26     { displacement cell }
27     { address cell } ;
28
29 STRUCT: array
30     { header cell }
31     { capacity cell } ;
32
33 STRUCT: bignum
34     { header cell }
35     { capacity cell } ;
36
37 ! Different on 32 bit
38 STRUCT: byte-array
39     { header cell }
40     { capacity cell } ;
41
42 STRUCT: dll
43     { header cell }
44     { path cell }
45     { handle void* } ;
46
47 ! Different on 32 bit
48 STRUCT: float
49     { header cell }
50     { n double } ;
51
52 STRUCT: quotation
53     { header cell }
54     { array cell }
55     { cached_effect cell }
56     { cache_counter cell }
57     { entry_point cell } ;
58
59 STRUCT: string
60     { header cell }
61     { length cell }
62     { aux cell }
63     { hashcode cell } ;
64
65 STRUCT: tuple
66     { header cell }
67     { layout cell } ;
68
69 STRUCT: tuple-layout
70     { header cell }
71     { capacity cell }
72     { klass cell }
73     { size cell }
74     { echelon cell } ;
75
76 STRUCT: word
77     { header cell }
78     { hashcode cell }
79     { name cell }
80     { vocabulary cell }
81     { def cell }
82     { props cell }
83     { pic_def cell }
84     { pic_tail_def cell }
85     { subprimitive cell }
86     { entry_point cell } ;
87
88 STRUCT: wrapper
89     { header cell }
90     { object cell } ;
91
92 UNION: no-payload
93     alien
94     dll
95     float
96     quotation
97     wrapper
98     word ;
99
100 UNION: array-payload
101     array
102     bignum ;
103
104 : tag>class ( tag -- class )
105     {
106         { 2 array }
107         { 3 float }
108         { 4 quotation }
109         { 5 bignum }
110         { 6 alien }
111         { 7 tuple }
112         { 8 wrapper }
113         { 9 byte-array }
114         { 11 string }
115         { 12 word }
116         { 13 dll }
117     } at ;
118
119 ! These structs and words correspond to vm/code_blocks.hpp
120 STRUCT: code-block
121     { header cell }
122     { owner cell }
123     { parameters cell }
124     { relocation cell } ;