]> gitweb.factorcode.org Git - factor.git/blob - vm/image.h
Merge branch 'master' into experimental (untested!)
[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;
30         CELL ds_size, rs_size;
31         CELL gen_count, young_size, aging_size, tenured_size;
32         CELL code_size;
33         bool secure_gc;
34         bool fep;
35         bool console;
36         bool stack_traces;
37 } F_PARAMETERS;
38
39 void load_image(F_PARAMETERS *p);
40 void init_objects(F_HEADER *h);
41 bool save_image(const F_CHAR *file);
42
43 void primitive_save_image(void);
44 void primitive_save_image_and_exit(void);
45
46 /* relocation base of currently loaded image's data heap */
47 CELL data_relocation_base;
48
49 INLINE void data_fixup(CELL *cell)
50 {
51         if(immediate_p(*cell))
52                 return;
53
54         F_ZONE *tenured = &data_heap->generations[TENURED];
55         *cell += (tenured->start - data_relocation_base);
56 }
57
58 CELL code_relocation_base;
59
60 INLINE void code_fixup(CELL cell)
61 {
62         CELL value = get(cell);
63         put(cell,value + (code_heap.segment->start - code_relocation_base));
64 }
65
66 void relocate_data();
67 void relocate_code();