]> gitweb.factorcode.org Git - factor.git/blob - vm/image.h
Merge branch 'master' into experimental
[factor.git] / vm / image.h
1 #define IMAGE_MAGIC 0x0f0e0d0c
2 #define IMAGE_VERSION 4
3
4 typedef struct {
5         CELL magic;
6         CELL version;
7         /* all pointers in the image file are relocated from
8            relocation_base to here when the image is loaded */
9         CELL data_relocation_base;
10         /* size of heap */
11         CELL data_size;
12         /* code relocation base */
13         CELL code_relocation_base;
14         /* size of code heap */
15         CELL code_size;
16         /* tagged pointer to t singleton */
17         CELL t;
18         /* tagged pointer to bignum 0 */
19         CELL bignum_zero;
20         /* tagged pointer to bignum 1 */
21         CELL bignum_pos_one;
22         /* tagged pointer to bignum -1 */
23         CELL bignum_neg_one;
24         /* Initial user environment */
25         CELL userenv[USER_ENV];
26 } F_HEADER;
27
28 typedef struct {
29         const F_CHAR *image_path;
30         const F_CHAR *executable_path;
31         CELL ds_size, rs_size;
32         CELL gen_count, young_size, aging_size, tenured_size;
33         CELL code_size;
34         bool secure_gc;
35         bool fep;
36         bool console;
37         bool stack_traces;
38 } F_PARAMETERS;
39
40 void load_image(F_PARAMETERS *p);
41 void init_objects(F_HEADER *h);
42 bool save_image(const F_CHAR *file);
43
44 void primitive_save_image(void);
45 void primitive_save_image_and_exit(void);
46
47 /* relocation base of currently loaded image's data heap */
48 CELL data_relocation_base;
49
50 INLINE void data_fixup(CELL *cell)
51 {
52         if(immediate_p(*cell))
53                 return;
54
55         F_ZONE *tenured = &data_heap->generations[TENURED];
56         *cell += (tenured->start - data_relocation_base);
57 }
58
59 CELL code_relocation_base;
60
61 INLINE void code_fixup(CELL cell)
62 {
63         CELL value = get(cell);
64         put(cell,value + (code_heap.segment->start - code_relocation_base));
65 }
66
67 void relocate_data();
68 void relocate_code();