]> gitweb.factorcode.org Git - factor.git/blob - vm/code_blocks.hpp
vm: eliminating literal table work in progress
[factor.git] / vm / code_blocks.hpp
1 namespace factor
2 {
3
4 /* The compiled code heap is structured into blocks. */
5 struct code_block
6 {
7         cell header;
8         cell owner; /* tagged pointer to word, quotation or f */
9         cell literals; /* tagged pointer to array or f */
10         cell relocation; /* tagged pointer to byte-array or f */
11
12         bool free_p() const
13         {
14                 return header & 1 == 1;
15         }
16
17         code_block_type type() const
18         {
19                 return (code_block_type)((header >> 1) & 0x3);
20         }
21
22         void set_type(code_block_type type)
23         {
24                 header = ((header & ~0x7) | (type << 1));
25         }
26
27         bool pic_p() const
28         {
29                 return type() == code_block_pic;
30         }
31
32         bool optimized_p() const
33         {
34                 return type() == code_block_optimized;
35         }
36
37         cell size() const
38         {
39                 return header & ~7;
40         }
41
42         void *xt() const
43         {
44                 return (void *)(this + 1);
45         }
46 };
47
48 }