Bigger cards and decks

db4
Slava Pestov 2008-05-09 00:09:12 -05:00
parent fb605aadad
commit a233349c1f
3 changed files with 15 additions and 16 deletions

View File

@ -4,8 +4,8 @@ USING: math kernel layouts system ;
IN: compiler.constants IN: compiler.constants
! These constants must match vm/memory.h ! These constants must match vm/memory.h
: card-bits 6 ; : card-bits 8 ;
: deck-bits 12 ; : deck-bits 18 ;
: card-mark HEX: 40 HEX: 80 bitor ; : card-mark HEX: 40 HEX: 80 bitor ;
! These constants must match vm/layouts.h ! These constants must match vm/layouts.h

View File

@ -59,6 +59,8 @@ F_DATA_HEAP *alloc_data_heap(CELL gens,
return NULL; /* can't happen */ return NULL; /* can't happen */
} }
total_size += DECK_SIZE;
data_heap->segment = alloc_segment(total_size); data_heap->segment = alloc_segment(total_size);
data_heap->generations = safe_malloc(sizeof(F_ZONE) * data_heap->gen_count); data_heap->generations = safe_malloc(sizeof(F_ZONE) * data_heap->gen_count);
@ -75,7 +77,7 @@ F_DATA_HEAP *alloc_data_heap(CELL gens,
data_heap->decks = safe_malloc(decks_size); data_heap->decks = safe_malloc(decks_size);
data_heap->decks_end = data_heap->decks + decks_size; data_heap->decks_end = data_heap->decks + decks_size;
CELL alloter = data_heap->segment->start; CELL alloter = (data_heap->segment->start + DECK_SIZE - 1) & ~(DECK_SIZE - 1);
alloter = init_zone(&data_heap->generations[TENURED],tenured_size,alloter); alloter = init_zone(&data_heap->generations[TENURED],tenured_size,alloter);
alloter = init_zone(&data_heap->semispaces[TENURED],tenured_size,alloter); alloter = init_zone(&data_heap->semispaces[TENURED],tenured_size,alloter);
@ -92,7 +94,7 @@ F_DATA_HEAP *alloc_data_heap(CELL gens,
alloter = init_zone(&data_heap->semispaces[NURSERY],0,alloter); alloter = init_zone(&data_heap->semispaces[NURSERY],0,alloter);
} }
if(alloter != data_heap->segment->end) if(data_heap->segment->end - alloter > DECK_SIZE)
critical_error("Bug in alloc_data_heap",alloter); critical_error("Bug in alloc_data_heap",alloter);
return data_heap; return data_heap;
@ -163,6 +165,10 @@ void gc_reset(void)
int i; int i;
for(i = 0; i < MAX_GEN_COUNT; i++) for(i = 0; i < MAX_GEN_COUNT; i++)
memset(&gc_stats[i],0,sizeof(F_GC_STATS)); memset(&gc_stats[i],0,sizeof(F_GC_STATS));
cards_scanned = 0;
decks_scanned = 0;
code_heap_scans = 0;
} }
void init_data_heap(CELL gens, void init_data_heap(CELL gens,
@ -182,10 +188,6 @@ void init_data_heap(CELL gens,
secure_gc = secure_gc_; secure_gc = secure_gc_;
gc_reset(); gc_reset();
cards_scanned = 0;
decks_scanned = 0;
code_heap_scans = 0;
} }
/* Size of the object pointed to by a tagged pointer */ /* Size of the object pointed to by a tagged pointer */

View File

@ -68,13 +68,11 @@ the offset of the first object is set by the allocator. */
#define CARD_POINTS_TO_NURSERY 0x80 #define CARD_POINTS_TO_NURSERY 0x80
#define CARD_POINTS_TO_AGING 0x40 #define CARD_POINTS_TO_AGING 0x40
#define CARD_MARK_MASK (CARD_POINTS_TO_NURSERY | CARD_POINTS_TO_AGING) #define CARD_MARK_MASK (CARD_POINTS_TO_NURSERY | CARD_POINTS_TO_AGING)
#define CARD_BASE_MASK 0x3f #define CARD_BASE_MASK 0xff
typedef u8 F_CARD; typedef u8 F_CARD;
/* A card is 64 bytes. 6 bits is sufficient to represent every #define CARD_BITS 8
offset within the card */ #define CARD_SIZE (1<<CARD_BITS)
#define CARD_SIZE 64
#define CARD_BITS 6
#define ADDR_CARD_MASK (CARD_SIZE-1) #define ADDR_CARD_MASK (CARD_SIZE-1)
DLLEXPORT CELL cards_offset; DLLEXPORT CELL cards_offset;
@ -83,11 +81,10 @@ DLLEXPORT CELL allot_markers_offset;
#define ADDR_TO_CARD(a) (F_CARD*)(((CELL)(a) >> CARD_BITS) + cards_offset) #define ADDR_TO_CARD(a) (F_CARD*)(((CELL)(a) >> CARD_BITS) + cards_offset)
#define CARD_TO_ADDR(c) (CELL*)(((CELL)(c) - cards_offset)<<CARD_BITS) #define CARD_TO_ADDR(c) (CELL*)(((CELL)(c) - cards_offset)<<CARD_BITS)
/* A deck is 4 kilobytes or 64 cards. */
typedef u8 F_DECK; typedef u8 F_DECK;
#define DECK_SIZE (4 * 1024) #define DECK_BITS (CARD_BITS + 10)
#define DECK_BITS 12 #define DECK_SIZE (1<<DECK_BITS)
#define ADDR_DECK_MASK (DECK_SIZE-1) #define ADDR_DECK_MASK (DECK_SIZE-1)
DLLEXPORT CELL decks_offset; DLLEXPORT CELL decks_offset;