]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/image-analyzer/vm/vm.factor
tools.image-analyzer.*: support for callstack reading
[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: callstack
43     { header cell }
44     { length cell } ;
45
46 STRUCT: dll
47     { header cell }
48     { path cell }
49     { handle void* } ;
50
51 ! Different on 32 bit
52 STRUCT: float
53     { header cell }
54     { n double } ;
55
56 STRUCT: quotation
57     { header cell }
58     { array cell }
59     { cached_effect cell }
60     { cache_counter cell }
61     { entry_point cell } ;
62
63 STRUCT: string
64     { header cell }
65     { length cell }
66     { aux cell }
67     { hashcode cell } ;
68
69 STRUCT: tuple
70     { header cell }
71     { layout cell } ;
72
73 STRUCT: tuple-layout
74     { header cell }
75     { capacity cell }
76     { klass cell }
77     { size cell }
78     { echelon cell } ;
79
80 STRUCT: word
81     { header cell }
82     { hashcode cell }
83     { name cell }
84     { vocabulary cell }
85     { def cell }
86     { props cell }
87     { pic_def cell }
88     { pic_tail_def cell }
89     { subprimitive cell }
90     { entry_point cell } ;
91
92 STRUCT: wrapper
93     { header cell }
94     { object cell } ;
95
96 UNION: no-payload
97     alien
98     dll
99     float
100     quotation
101     wrapper
102     word ;
103
104 UNION: array-payload
105     array
106     bignum ;
107
108 : tag>class ( tag -- class )
109     {
110         { 2 array }
111         { 3 float }
112         { 4 quotation }
113         { 5 bignum }
114         { 6 alien }
115         { 7 tuple }
116         { 8 wrapper }
117         { 9 byte-array }
118         { 10 callstack }
119         { 11 string }
120         { 12 word }
121         { 13 dll }
122     } at ;
123
124 ! These structs and words correspond to vm/code_blocks.hpp
125 STRUCT: code-block
126     { header cell }
127     { owner cell }
128     { parameters cell }
129     { relocation cell } ;