Moved freeblock to NewGC struct
svn: r12299
This commit is contained in:
parent
af34446ec3
commit
397e42ae06
|
@ -42,16 +42,7 @@ static void *malloc_dirty_pages(size_t len, size_t alignment)
|
|||
return do_malloc_pages(len, alignment, 1);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
void *start;
|
||||
long len;
|
||||
short age;
|
||||
short zeroed;
|
||||
} Free_Block;
|
||||
|
||||
#define BLOCKFREE_UNMAP_AGE 1
|
||||
#define BLOCKFREE_CACHE_SIZE 96
|
||||
static Free_Block blockfree[BLOCKFREE_CACHE_SIZE];
|
||||
|
||||
static int compare_free_block(const void *a, const void *b)
|
||||
{
|
||||
|
@ -64,6 +55,7 @@ static int compare_free_block(const void *a, const void *b)
|
|||
static void collapse_adjacent_pages(void)
|
||||
{
|
||||
int i, j;
|
||||
Free_Block *blockfree = GC->blockfree;
|
||||
|
||||
/* collapse adjacent: */
|
||||
my_qsort(blockfree, BLOCKFREE_CACHE_SIZE, sizeof(Free_Block), compare_free_block);
|
||||
|
@ -84,6 +76,7 @@ inline static void *find_cached_pages(size_t len, size_t alignment, int dirty_ok
|
|||
{
|
||||
int i;
|
||||
void *r;
|
||||
Free_Block *blockfree = GC->blockfree;
|
||||
|
||||
/* Try an exact fit: */
|
||||
for (i = 0; i < BLOCKFREE_CACHE_SIZE; i++) {
|
||||
|
@ -136,6 +129,7 @@ inline static void *find_cached_pages(size_t len, size_t alignment, int dirty_ok
|
|||
static void return_mem_to_cache(void *p, size_t len, int zeroed)
|
||||
{
|
||||
int i;
|
||||
Free_Block *blockfree = GC->blockfree;
|
||||
|
||||
/* Round up to nearest page: */
|
||||
if (len & (page_size - 1))
|
||||
|
@ -187,6 +181,7 @@ static void free_pages(void *p, size_t len)
|
|||
static void flush_freed_pages(void)
|
||||
{
|
||||
int i;
|
||||
Free_Block *blockfree = GC->blockfree;
|
||||
|
||||
collapse_adjacent_pages();
|
||||
|
||||
|
|
|
@ -67,3 +67,12 @@ typedef struct finalizer {
|
|||
struct finalizer *right;
|
||||
} Fnl;
|
||||
|
||||
typedef struct {
|
||||
void *start;
|
||||
long len;
|
||||
short age;
|
||||
short zeroed;
|
||||
} Free_Block;
|
||||
|
||||
|
||||
#define BLOCKFREE_CACHE_SIZE 96
|
||||
|
|
|
@ -19,8 +19,10 @@ typedef struct CompactGC {
|
|||
GC_Weak_Box *weak_boxes;
|
||||
GC_Ephemeron *ephemerons;
|
||||
int num_last_seen_ephemerons;
|
||||
Free_Block *blockfree;
|
||||
} CompactGC;
|
||||
|
||||
void CompactGC_initialize(CompactGC *newgc) {
|
||||
memset(newgc, 0, sizeof(CompactGC));
|
||||
void CompactGC_initialize(CompactGC *gc) {
|
||||
memset(gc, 0, sizeof(CompactGC));
|
||||
gc->blockfree = malloc(sizeof(Free_Block) *BLOCKFREE_CACHE_SIZE);
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ typedef struct NewGC {
|
|||
GC_Weak_Box *weak_boxes;
|
||||
GC_Ephemeron *ephemerons;
|
||||
int num_last_seen_ephemerons;
|
||||
Free_Block *blockfree;
|
||||
} NewGC;
|
||||
|
||||
void NewGC_initialize(NewGC *newgc) {
|
||||
|
@ -169,6 +170,7 @@ void NewGC_initialize(NewGC *newgc) {
|
|||
#else
|
||||
newgc->page_maps = malloc(PAGEMAP32_SIZE * sizeof (mpage*));
|
||||
#endif
|
||||
newgc->blockfree = malloc(sizeof(Free_Block) * BLOCKFREE_CACHE_SIZE);
|
||||
|
||||
newgc->generations_available = 1;
|
||||
newgc->last_full_mem_use = (20 * 1024 * 1024);
|
||||
|
|
Loading…
Reference in New Issue
Block a user