Moved protect_range to NewGC struct

svn: r12301
This commit is contained in:
Kevin Tew 2008-11-05 21:09:43 +00:00
parent 6c3555f2a2
commit a714ab06f8
4 changed files with 35 additions and 31 deletions

View File

@ -1347,7 +1347,7 @@ void GC_init_type_tags(int count, int pair, int mutable_pair, int weakbox, int e
GC_add_roots(&GC->park, (char *)&GC->park + sizeof(GC->park) + 1);
GC_add_roots(&GC->park_save, (char *)&GC->park_save + sizeof(GC->park_save) + 1);
initialize_protect_page_ranges(malloc_dirty_pages(APAGE_SIZE, APAGE_SIZE), APAGE_SIZE);
initialize_protect_page_ranges(GC->protect_range, malloc_dirty_pages(APAGE_SIZE, APAGE_SIZE), APAGE_SIZE);
}
else {
GCPRINT(GCOUTF, "HEY WHATS UP.\n");
@ -1832,6 +1832,7 @@ void *GC_next_tagged_start(void *p)
static void prepare_pages_for_collection(void)
{
Page_Range *protect_range = GC->protect_range;
struct mpage *work;
int i;
@ -1844,10 +1845,10 @@ static void prepare_pages_for_collection(void)
for(work = GC->gen1_pages[i]; work; work = work->next) {
if (work->mprotected) {
work->mprotected = 0;
add_protect_page_range(work->addr, work->big_page ? round_to_apage_size(work->size) : APAGE_SIZE, APAGE_SIZE, 1);
add_protect_page_range(protect_range, work->addr, work->big_page ? round_to_apage_size(work->size) : APAGE_SIZE, APAGE_SIZE, 1);
}
}
flush_protect_page_ranges(1);
flush_protect_page_ranges(protect_range, 1);
}
for(i = 0; i < PAGE_TYPES; i++)
for(work = GC->gen1_pages[i]; work; work = work->next) {
@ -1864,13 +1865,13 @@ static void prepare_pages_for_collection(void)
if (work->back_pointers) {
if (work->mprotected) {
work->mprotected = 0;
add_protect_page_range(work->addr, work->big_page ? round_to_apage_size(work->size) : APAGE_SIZE, APAGE_SIZE, 1);
add_protect_page_range(protect_range, work->addr, work->big_page ? round_to_apage_size(work->size) : APAGE_SIZE, APAGE_SIZE, 1);
}
}
}
pagemap_remove(pagemap, work);
}
flush_protect_page_ranges(1);
flush_protect_page_ranges(protect_range, 1);
}
}
@ -2236,6 +2237,7 @@ static void clean_up_heap(void)
static void protect_old_pages(void)
{
Page_Range *protect_range = GC->protect_range;
struct mpage *page;
int i;
@ -2245,11 +2247,11 @@ static void protect_old_pages(void)
if(page->page_type != PAGE_ATOMIC) {
if (!page->mprotected) {
page->mprotected = 1;
add_protect_page_range(page->addr, page->size, APAGE_SIZE, 0);
add_protect_page_range(protect_range, page->addr, page->size, APAGE_SIZE, 0);
}
}
flush_protect_page_ranges(0);
flush_protect_page_ranges(protect_range, 0);
}
#if 0

View File

@ -65,6 +65,20 @@ typedef struct OTEntry {
char required_set;
} OTEntry;
typedef struct Range {
unsigned long start, len;
struct Range *left, *right, *prev, *next;
} Range;
typedef struct Page_Range {
Range *range_root;
Range *range_start;
void *range_alloc_block;
unsigned long range_alloc_size;
unsigned long range_alloc_used;
} Page_Range;
#ifdef SIXTY_FOUR_BIT_INTEGERS
typedef mpage ****PageMap;
#else
@ -78,6 +92,7 @@ typedef struct NewGC {
PageMap page_maps;
/* All non-gen0 pages are held in the following structure. */
struct mpage *gen1_pages[PAGE_TYPES];
Page_Range *protect_range;
/* Finalization */
@ -169,6 +184,7 @@ void NewGC_initialize(NewGC *newgc) {
newgc->page_maps = malloc(PAGEMAP32_SIZE * sizeof (mpage*));
#endif
newgc->blockfree = malloc(sizeof(Free_Block) * BLOCKFREE_CACHE_SIZE);
newgc->protect_range = malloc(sizeof(Page_Range));
newgc->generations_available = 1;
newgc->last_full_mem_use = (20 * 1024 * 1024);

View File

@ -6,11 +6,6 @@
add_page_range
*/
typedef struct Range {
unsigned long start, len;
struct Range *left, *right, *prev, *next;
} Range;
#define Tree Range
#define Splay_Item(t) (t)->start
#define Set_Splay_Item(t, v) (t)->start = (v)
@ -25,13 +20,6 @@ typedef struct Range {
#undef Splay_Item
#undef Set_Splay_Item
typedef struct Page_Range {
Range *range_root, *range_start;
void *range_alloc_block;
unsigned long range_alloc_size;
unsigned long range_alloc_used;
} Page_Range;
static void initialize_page_ranges(Page_Range *pr, void *block, unsigned long size)
{
pr->range_root = NULL;

View File

@ -16,31 +16,29 @@
#else
static Page_Range protect_range;
static void initialize_protect_page_ranges(void *block, unsigned long size)
static void initialize_protect_page_ranges(Page_Range *protect_range, void *block, unsigned long size)
{
initialize_page_ranges(&protect_range, block, size);
initialize_page_ranges(protect_range, block, size);
}
static void flush_protect_page_ranges(int writeable)
static void flush_protect_page_ranges(Page_Range *protect_range, int writeable)
{
Range *work;
compact_page_ranges(&protect_range);
compact_page_ranges(protect_range);
for (work = protect_range.range_start; work; work = work->next) {
for (work = protect_range->range_start; work; work = work->next) {
protect_pages((void *)work->start, work->len, writeable);
}
reset_page_ranges(&protect_range);
reset_page_ranges(protect_range);
}
static void add_protect_page_range(void *_start, unsigned long len, unsigned long alignment, int writeable)
static void add_protect_page_range(Page_Range *protect_range, void *_start, unsigned long len, unsigned long alignment, int writeable)
{
if (!add_page_range(&protect_range, _start, len, alignment)) {
flush_protect_page_ranges(writeable);
add_page_range(&protect_range, _start, len, alignment);
if (!add_page_range(protect_range, _start, len, alignment)) {
flush_protect_page_ranges(protect_range, writeable);
add_page_range(protect_range, _start, len, alignment);
}
}