Big code GC refactoring
[factor/jcg.git] / vm / code_block.h
blob7ee60d24cf4d9214d06cd376d532404fef5fb5d3
1 typedef enum {
2 /* arg is a primitive number */
3 RT_PRIMITIVE,
4 /* arg is a literal table index, holding an array pair (symbol/dll) */
5 RT_DLSYM,
6 /* a pointer to a compiled word reference */
7 RT_DISPATCH,
8 /* a compiled word reference */
9 RT_XT,
10 /* current offset */
11 RT_HERE,
12 /* a local label */
13 RT_LABEL,
14 /* immediate literal */
15 RT_IMMEDIATE,
16 /* address of stack_chain var */
17 RT_STACK_CHAIN
18 } F_RELTYPE;
20 typedef enum {
21 /* absolute address in a 64-bit location */
22 RC_ABSOLUTE_CELL,
23 /* absolute address in a 32-bit location */
24 RC_ABSOLUTE,
25 /* relative address in a 32-bit location */
26 RC_RELATIVE,
27 /* relative address in a PowerPC LIS/ORI sequence */
28 RC_ABSOLUTE_PPC_2_2,
29 /* relative address in a PowerPC LWZ/STW/BC instruction */
30 RC_RELATIVE_PPC_2,
31 /* relative address in a PowerPC B/BL instruction */
32 RC_RELATIVE_PPC_3,
33 /* relative address in an ARM B/BL instruction */
34 RC_RELATIVE_ARM_3,
35 /* pointer to address in an ARM LDR/STR instruction */
36 RC_INDIRECT_ARM,
37 /* pointer to address in an ARM LDR/STR instruction offset by 8 bytes */
38 RC_INDIRECT_ARM_PC
39 } F_RELCLASS;
41 #define REL_RELATIVE_PPC_2_MASK 0xfffc
42 #define REL_RELATIVE_PPC_3_MASK 0x3fffffc
43 #define REL_INDIRECT_ARM_MASK 0xfff
44 #define REL_RELATIVE_ARM_3_MASK 0xffffff
46 /* the rel type is built like a cell to avoid endian-specific code in
47 the compiler */
48 #define REL_TYPE(r) ((r)->type & 0x000000ff)
49 #define REL_CLASS(r) (((r)->type & 0x0000ff00) >> 8)
50 #define REL_ARGUMENT(r) (((r)->type & 0xffff0000) >> 16)
52 /* code relocation consists of a table of entries for each fixup */
53 typedef struct {
54 unsigned int type;
55 unsigned int offset;
56 } F_REL;
58 void flush_icache_for(F_CODE_BLOCK *compiled);
60 typedef void (*RELOCATION_ITERATOR)(F_REL *rel, F_CODE_BLOCK *compiled);
62 void iterate_relocations(F_CODE_BLOCK *compiled, RELOCATION_ITERATOR iter);
64 void store_address_in_code_block(CELL class, CELL offset, F_FIXNUM absolute_value);
66 void relocate_code_block(F_CODE_BLOCK *compiled);
68 void update_literal_references(F_CODE_BLOCK *compiled);
70 void copy_literal_references(F_CODE_BLOCK *compiled);
72 void update_word_references(F_CODE_BLOCK *compiled);
74 void mark_code_block(F_CODE_BLOCK *compiled);
76 void relocate_code_block(F_CODE_BLOCK *relocating);
78 CELL compiled_code_format(void);
80 bool stack_traces_p(void);
82 F_CODE_BLOCK *add_compiled_block(
83 CELL type,
84 F_ARRAY *code,
85 F_ARRAY *labels,
86 CELL relocation,
87 CELL literals);