Image save doesn't write the large free block at the end

slava 2006-09-26 21:22:04 +00:00
parent 003d7cc91b
commit f55cfd918a
7 changed files with 20 additions and 11 deletions

View File

@ -4,8 +4,7 @@
- test alien-indirect - test alien-indirect
- code GC: - code GC:
- discard the free block at the end of the code heap on save - discard the free block at the end of the code heap on save
- minor GC takes too long now - minor GC takes too long now, card mark
- icache slowdown
+ ui: + ui:

View File

@ -94,7 +94,7 @@ void dump_cell(CELL cell)
fprintf(stderr," -- F"); fprintf(stderr," -- F");
else if(cell < TYPE_COUNT<<TAG_BITS) else if(cell < TYPE_COUNT<<TAG_BITS)
fprintf(stderr," -- header: %ld",cell>>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 header = get(UNTAG(cell));
CELL type = header>>TAG_BITS; CELL type = header>>TAG_BITS;

View File

@ -147,3 +147,12 @@ CELL heap_free_space(HEAP *heap)
return size; 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;
}

View File

@ -23,6 +23,7 @@ void build_free_list(HEAP *heap, CELL size);
CELL heap_allot(HEAP *heap, CELL size); CELL heap_allot(HEAP *heap, CELL size);
void free_unmarked(HEAP *heap); void free_unmarked(HEAP *heap);
CELL heap_free_space(HEAP *heap); CELL heap_free_space(HEAP *heap);
CELL heap_size(HEAP *heap);
INLINE F_BLOCK *next_block(HEAP *heap, F_BLOCK *block) INLINE F_BLOCK *next_block(HEAP *heap, F_BLOCK *block)
{ {

View File

@ -100,7 +100,7 @@ bool save_image(const char* filename)
h.bignum_zero = bignum_zero; h.bignum_zero = bignum_zero;
h.bignum_pos_one = bignum_pos_one; h.bignum_pos_one = bignum_pos_one;
h.bignum_neg_one = bignum_neg_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; h.code_relocation_base = compiling.base;
fwrite(&h,sizeof(HEADER),1,file); fwrite(&h,sizeof(HEADER),1,file);

View 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 */ and restore its contents when leaving the callback. see stack.c */
void update_cards_offset(void) 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 */ /* 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; gen_count = gens;
generations = safe_malloc(sizeof(ZONE) * gen_count); generations = safe_malloc(sizeof(ZONE) * gen_count);
heap_start = (CELL)(alloc_bounded_block(total_size)->start); data_heap_start = (CELL)(alloc_bounded_block(total_size)->start);
heap_end = heap_start + total_size; data_heap_end = data_heap_start + total_size;
cards = safe_malloc(cards_size); cards = safe_malloc(cards_size);
cards_end = cards + cards_size; cards_end = cards + cards_size;
update_cards_offset(); update_cards_offset();
alloter = heap_start; alloter = data_heap_start;
alloter = init_zone(&tenured,aging_size,alloter); alloter = init_zone(&tenured,aging_size,alloter);
alloter = init_zone(&prior,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); clear_cards(NURSERY,TENURED);
if(alloter != heap_start + total_size) if(alloter != data_heap_start + total_size)
fatal_error("Oops",alloter); fatal_error("Oops",alloter);
heap_scan = false; heap_scan = false;

View File

@ -101,8 +101,8 @@ void primitive_begin_scan(void);
void primitive_next_object(void); void primitive_next_object(void);
void primitive_end_scan(void); void primitive_end_scan(void);
CELL heap_start; CELL data_heap_start;
CELL heap_end; CELL data_heap_end;
/* card marking write barrier. a card is a byte storing a mark flag, /* 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. and the offset (in cells) of the first object in the card.