]> gitweb.factorcode.org Git - factor.git/commitdiff
Image save doesn't write the large free block at the end
authorslava <slava@factorcode.org>
Tue, 26 Sep 2006 21:22:04 +0000 (21:22 +0000)
committerslava <slava@factorcode.org>
Tue, 26 Sep 2006 21:22:04 +0000 (21:22 +0000)
TODO.FACTOR.txt
vm/debug.c
vm/heap.c
vm/heap.h
vm/image.c
vm/memory.c
vm/memory.h

index 0f53d72efe64941f4dd8c2f02c95116c6e5a2b3c..6768f4ec4e4d19beea1a2ad5eaa7e97a53c5f7ef 100644 (file)
@@ -4,8 +4,7 @@
 - test alien-indirect
 - code GC:
   - discard the free block at the end of the code heap on save
-  - minor GC takes too long now
-  - icache slowdown
+  - minor GC takes too long now, card mark
 
 + ui:
 
index 880cbbb8a9d7d66dcff082a5ebd763e0da61e88b..6dbeee7857cf31b1c29b3a5e993205b757683377 100644 (file)
@@ -94,7 +94,7 @@ void dump_cell(CELL cell)
                        fprintf(stderr," -- F");
                else if(cell < TYPE_COUNT<<TAG_BITS)
                        fprintf(stderr," -- header: %ld",cell>>TAG_BITS);
-               else if(cell >= heap_start && cell < heap_end)
+               else if(cell >= data_heap_start && cell < data_heap_end)
                {
                        CELL header = get(UNTAG(cell));
                        CELL type = header>>TAG_BITS;
index e07ddeead3547ea6276f7cbe7981ab67de5c5e2f..d12cc74612dec20ece7e9d5a3fb80da7b037c25d 100644 (file)
--- a/vm/heap.c
+++ b/vm/heap.c
@@ -147,3 +147,12 @@ CELL heap_free_space(HEAP *heap)
 
        return size;
 }
+
+CELL heap_size(HEAP *heap)
+{
+       CELL start = heap->base;
+       F_BLOCK *scan = (F_BLOCK *)start;
+       while(next_block(heap,scan))
+               scan = next_block(heap,scan);
+       return (CELL)scan - (CELL)start;
+}
index 06dc330739ab2ab34411f8f6a1ec9bd8d4329480..cabea8d5fbe630e6799417928f2eb90d035abc51 100644 (file)
--- a/vm/heap.h
+++ b/vm/heap.h
@@ -23,6 +23,7 @@ void build_free_list(HEAP *heap, CELL size);
 CELL heap_allot(HEAP *heap, CELL size);
 void free_unmarked(HEAP *heap);
 CELL heap_free_space(HEAP *heap);
+CELL heap_size(HEAP *heap);
 
 INLINE F_BLOCK *next_block(HEAP *heap, F_BLOCK *block)
 {
index 3965bad1b16b5ae411364e11e382e2babce427dd..0518d8bd84dd423a70c10dd977baa999581b6e2c 100644 (file)
@@ -100,7 +100,7 @@ bool save_image(const char* filename)
        h.bignum_zero = bignum_zero;
        h.bignum_pos_one = bignum_pos_one;
        h.bignum_neg_one = bignum_neg_one;
-       h.code_size = compiling.limit - compiling.base;
+       h.code_size = heap_size(&compiling);
        h.code_relocation_base = compiling.base;
        fwrite(&h,sizeof(HEADER),1,file);
 
index f9fa21d905b9eb109633a2411590b56da8370d4e..129546ce684feb39f0fb4831770b220a16eb8926 100644 (file)
@@ -293,7 +293,7 @@ we need to save its contents and re-initialize it when entering a callback,
 and restore its contents when leaving the callback. see stack.c */
 void update_cards_offset(void)
 {
-       cards_offset = (CELL)cards - (heap_start >> CARD_BITS);
+       cards_offset = (CELL)cards - (data_heap_start >> CARD_BITS);
 }
 
 /* input parameters must be 8 byte aligned */
@@ -316,14 +316,14 @@ void init_arena(CELL gens, CELL young_size, CELL aging_size)
        gen_count = gens;
        generations = safe_malloc(sizeof(ZONE) * gen_count);
 
-       heap_start = (CELL)(alloc_bounded_block(total_size)->start);
-       heap_end = heap_start + total_size;
+       data_heap_start = (CELL)(alloc_bounded_block(total_size)->start);
+       data_heap_end = data_heap_start + total_size;
 
        cards = safe_malloc(cards_size);
        cards_end = cards + cards_size;
        update_cards_offset();
 
-       alloter = heap_start;
+       alloter = data_heap_start;
 
        alloter = init_zone(&tenured,aging_size,alloter);
        alloter = init_zone(&prior,aging_size,alloter);
@@ -333,7 +333,7 @@ void init_arena(CELL gens, CELL young_size, CELL aging_size)
 
        clear_cards(NURSERY,TENURED);
 
-       if(alloter != heap_start + total_size)
+       if(alloter != data_heap_start + total_size)
                fatal_error("Oops",alloter);
 
        heap_scan = false;
index 18fbf6988f2b72ae21de08fb412ef0119ea6b1c9..0554e283737c0a784130c76026e018db7d0c3f3d 100644 (file)
@@ -101,8 +101,8 @@ void primitive_begin_scan(void);
 void primitive_next_object(void);
 void primitive_end_scan(void);
 
-CELL heap_start;
-CELL heap_end;
+CELL data_heap_start;
+CELL data_heap_end;
 
 /* card marking write barrier. a card is a byte storing a mark flag,
 and the offset (in cells) of the first object in the card.