]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/image.h
Initial import
[factor.git] / vm / image.h
index b4366864b2330ade9cac9d55b507ab2efbf00cd1..a15f850bb3a732dad694fd8abbc7baa82519991a 100644 (file)
@@ -1,5 +1,5 @@
 #define IMAGE_MAGIC 0x0f0e0d0c
-#define IMAGE_VERSION 2
+#define IMAGE_VERSION 4
 
 typedef struct {
        CELL magic;
@@ -7,10 +7,12 @@ typedef struct {
        /* all pointers in the image file are relocated from
           relocation_base to here when the image is loaded */
        CELL data_relocation_base;
-       /* tagged pointer to bootstrap quotation */
-       CELL boot;
-       /* tagged pointer to global namespace */
-       CELL global;
+       /* size of heap */
+       CELL data_size;
+       /* code relocation base */
+       CELL code_relocation_base;
+       /* size of code heap */
+       CELL code_size;
        /* tagged pointer to t singleton */
        CELL t;
        /* tagged pointer to bignum 0 */
@@ -19,33 +21,44 @@ typedef struct {
        CELL bignum_pos_one;
        /* tagged pointer to bignum -1 */
        CELL bignum_neg_one;
-       /* size of heap */
-       CELL data_size;
-       /* size of code heap */
-       CELL code_size;
-       /* code relocation base */
-       CELL code_relocation_base;
+       /* Initial user environment */
+       CELL userenv[USER_ENV];
 } F_HEADER;
 
+typedef struct {
+       const F_CHAR* image;
+       CELL ds_size, rs_size;
+       CELL gen_count, young_size, aging_size;
+       CELL code_size;
+       bool secure_gc;
+} F_PARAMETERS;
+
+void load_image(F_PARAMETERS *p);
 void init_objects(F_HEADER *h);
-void load_image(const char* file);
-bool save_image(const char* file);
-void primitive_save_image(void);
+bool save_image(const F_CHAR *file);
+
+DECLARE_PRIMITIVE(save_image);
+DECLARE_PRIMITIVE(save_image_and_exit);
 
 /* relocation base of currently loaded image's data heap */
 CELL data_relocation_base;
 
 INLINE void data_fixup(CELL *cell)
 {
-       if(TAG(*cell) != FIXNUM_TYPE && *cell != F)
-               *cell += (tenured.base - data_relocation_base);
+       if(immediate_p(*cell))
+               return;
+
+       F_ZONE *tenured = &data_heap->generations[TENURED];
+       *cell += (tenured->start - data_relocation_base);
 }
 
 CELL code_relocation_base;
 
-INLINE void code_fixup(CELL *cell)
+INLINE void code_fixup(XT *cell)
 {
-       *cell += (compiling.base - code_relocation_base);
+       CELL value = (CELL)*cell;
+       value += (code_heap.segment->start - code_relocation_base);
+       *cell = (XT)value;
 }
 
 void relocate_data();