Changed all mallocs to ofm_mallocs that report a nice error message and abort
svn: r12309
This commit is contained in:
parent
1f7e962fe6
commit
49fa1ab8ed
|
@ -15,7 +15,7 @@ inline static void BTC_register_new_thread(void *t, void *c)
|
||||||
NewGC *gc = GC_get_GC();
|
NewGC *gc = GC_get_GC();
|
||||||
GC_Thread_Info *work;
|
GC_Thread_Info *work;
|
||||||
|
|
||||||
work = (GC_Thread_Info *)malloc(sizeof(GC_Thread_Info));
|
work = (GC_Thread_Info *)ofm_malloc(sizeof(GC_Thread_Info));
|
||||||
((Scheme_Thread *)t)->gc_info = work;
|
((Scheme_Thread *)t)->gc_info = work;
|
||||||
work->owner = current_owner(gc, (Scheme_Custodian *)c);
|
work->owner = current_owner(gc, (Scheme_Custodian *)c);
|
||||||
work->thread = t;
|
work->thread = t;
|
||||||
|
@ -86,7 +86,7 @@ inline static int create_blank_owner_set(NewGC *gc)
|
||||||
|
|
||||||
for (i = 1; i < curr_size; i++) {
|
for (i = 1; i < curr_size; i++) {
|
||||||
if (!owner_table[i]) {
|
if (!owner_table[i]) {
|
||||||
owner_table[i] = malloc(sizeof(OTEntry));
|
owner_table[i] = ofm_malloc(sizeof(OTEntry));
|
||||||
bzero(owner_table[i], sizeof(OTEntry));
|
bzero(owner_table[i], sizeof(OTEntry));
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ inline static int create_blank_owner_set(NewGC *gc)
|
||||||
}
|
}
|
||||||
gc->owner_table_size = curr_size;
|
gc->owner_table_size = curr_size;
|
||||||
|
|
||||||
naya = (OTEntry **)malloc(curr_size * sizeof(OTEntry*));
|
naya = (OTEntry **)ofm_malloc(curr_size * sizeof(OTEntry*));
|
||||||
memcpy(naya, owner_table, old_size*sizeof(OTEntry*));
|
memcpy(naya, owner_table, old_size*sizeof(OTEntry*));
|
||||||
gc->owner_table = owner_table = naya;
|
gc->owner_table = owner_table = naya;
|
||||||
bzero(((char*)owner_table) + (sizeof(OTEntry*) * old_size),
|
bzero(((char*)owner_table) + (sizeof(OTEntry*) * old_size),
|
||||||
|
@ -471,7 +471,7 @@ inline static void BTC_add_account_hook(int type,void *c1,void *c2,unsigned long
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!work) {
|
if(!work) {
|
||||||
work = malloc(sizeof(AccountHook));
|
work = ofm_malloc(sizeof(AccountHook));
|
||||||
work->type = type;
|
work->type = type;
|
||||||
work->c1 = c1;
|
work->c1 = c1;
|
||||||
work->c2 = c2;
|
work->c2 = c2;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
static THREAD_LOCAL CompactGC *GC;
|
static THREAD_LOCAL CompactGC *GC;
|
||||||
#define GCTYPE CompactGC
|
#define GCTYPE CompactGC
|
||||||
#define GC_get_GC() (GC)
|
#define GC_get_GC() (GC)
|
||||||
|
#define ofm_malloc malloc
|
||||||
|
|
||||||
/**************** Configuration ****************/
|
/**************** Configuration ****************/
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
void **GC_malloc_immobile_box(void *p)
|
void **GC_malloc_immobile_box(void *p)
|
||||||
{
|
{
|
||||||
GCTYPE *gc = GC_get_GC();
|
GCTYPE *gc = GC_get_GC();
|
||||||
GC_Immobile_Box *ib = malloc(sizeof(GC_Immobile_Box));
|
GC_Immobile_Box *ib = ofm_malloc(sizeof(GC_Immobile_Box));
|
||||||
if(!ib) GCERR((GCOUTF, "Couldn't allocate space for immobile box!\n"));
|
if(!ib) GCERR((GCOUTF, "Couldn't allocate space for immobile box!\n"));
|
||||||
ib->p = p;
|
ib->p = p;
|
||||||
ib->next = gc->immobile_boxes;
|
ib->next = gc->immobile_boxes;
|
||||||
|
|
|
@ -154,6 +154,12 @@ static void out_of_memory()
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *ofm_malloc(size_t size) {
|
||||||
|
void *ptr = malloc(size);
|
||||||
|
if (!ptr) out_of_memory();
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
inline static void check_used_against_max(NewGC *gc, size_t len)
|
inline static void check_used_against_max(NewGC *gc, size_t len)
|
||||||
{
|
{
|
||||||
gc->used_pages += (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
gc->used_pages += (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
||||||
|
@ -186,14 +192,20 @@ inline static void check_used_against_max(NewGC *gc, size_t len)
|
||||||
|
|
||||||
static void *malloc_pages(NewGC *gc, size_t len, size_t alignment)
|
static void *malloc_pages(NewGC *gc, size_t len, size_t alignment)
|
||||||
{
|
{
|
||||||
|
void *ptr;
|
||||||
check_used_against_max(gc, len);
|
check_used_against_max(gc, len);
|
||||||
return vm_malloc_pages(gc->vm, len, alignment, 0);
|
ptr = vm_malloc_pages(gc->vm, len, alignment, 0);
|
||||||
|
if (!ptr) out_of_memory();
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *malloc_dirty_pages(NewGC *gc, size_t len, size_t alignment)
|
static void *malloc_dirty_pages(NewGC *gc, size_t len, size_t alignment)
|
||||||
{
|
{
|
||||||
|
void *ptr;
|
||||||
check_used_against_max(gc, len);
|
check_used_against_max(gc, len);
|
||||||
return vm_malloc_pages(gc->vm, len, alignment, 1);
|
ptr = vm_malloc_pages(gc->vm, len, alignment, 1);
|
||||||
|
if (!ptr) out_of_memory();
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_pages(NewGC *gc, void *p, size_t len)
|
static void free_pages(NewGC *gc, void *p, size_t len)
|
||||||
|
@ -381,8 +393,7 @@ static size_t round_to_apage_size(size_t sizeb)
|
||||||
static struct mpage *malloc_mpage()
|
static struct mpage *malloc_mpage()
|
||||||
{
|
{
|
||||||
struct mpage *page;
|
struct mpage *page;
|
||||||
page = malloc(sizeof(struct mpage));
|
page = ofm_malloc(sizeof(struct mpage));
|
||||||
if (!page) out_of_memory();
|
|
||||||
memset(page, 0, sizeof(struct mpage));
|
memset(page, 0, sizeof(struct mpage));
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +617,7 @@ void *GC_malloc_one_tagged(size_t s) { return allocate(s, PAGE_TAGG
|
||||||
void *GC_malloc_one_xtagged(size_t s) { return allocate(s, PAGE_XTAGGED); }
|
void *GC_malloc_one_xtagged(size_t s) { return allocate(s, PAGE_XTAGGED); }
|
||||||
void *GC_malloc_array_tagged(size_t s) { return allocate(s, PAGE_TARRAY); }
|
void *GC_malloc_array_tagged(size_t s) { return allocate(s, PAGE_TARRAY); }
|
||||||
void *GC_malloc_atomic(size_t s) { return allocate(s, PAGE_ATOMIC); }
|
void *GC_malloc_atomic(size_t s) { return allocate(s, PAGE_ATOMIC); }
|
||||||
void *GC_malloc_atomic_uncollectable(size_t s) { void *p = malloc(s); memset(p, 0, s); return p; }
|
void *GC_malloc_atomic_uncollectable(size_t s) { void *p = ofm_malloc(s); memset(p, 0, s); return p; }
|
||||||
void *GC_malloc_allow_interior(size_t s) { return allocate_big(s, PAGE_ARRAY); }
|
void *GC_malloc_allow_interior(size_t s) { return allocate_big(s, PAGE_ARRAY); }
|
||||||
void *GC_malloc_atomic_allow_interior(size_t s) { return allocate_big(s, PAGE_ATOMIC); }
|
void *GC_malloc_atomic_allow_interior(size_t s) { return allocate_big(s, PAGE_ATOMIC); }
|
||||||
void *GC_malloc_tagged_allow_interior(size_t s) { return allocate_big(s, PAGE_TAGGED); }
|
void *GC_malloc_tagged_allow_interior(size_t s) { return allocate_big(s, PAGE_TAGGED); }
|
||||||
|
@ -737,7 +748,7 @@ static void init_debug_file(void)
|
||||||
collections += 1;
|
collections += 1;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *filename = malloc(8 * sizeof(char));
|
char *filename = ofm_malloc(8 * sizeof(char));
|
||||||
|
|
||||||
filename[0] = 'g'; filename[1] = 'c'; filename[2] = 'l';
|
filename[0] = 'g'; filename[1] = 'c'; filename[2] = 'l';
|
||||||
filename[3] = 'o'; filename[4] = 'g';
|
filename[3] = 'o'; filename[4] = 'g';
|
||||||
|
@ -1172,7 +1183,7 @@ typedef struct MarkSegment {
|
||||||
static THREAD_LOCAL MarkSegment *mark_stack = NULL;
|
static THREAD_LOCAL MarkSegment *mark_stack = NULL;
|
||||||
|
|
||||||
inline static MarkSegment* mark_stack_create_frame() {
|
inline static MarkSegment* mark_stack_create_frame() {
|
||||||
MarkSegment *mark_frame = (MarkSegment*)malloc(STACK_PART_SIZE);
|
MarkSegment *mark_frame = (MarkSegment*)ofm_malloc(STACK_PART_SIZE);
|
||||||
mark_frame->next = NULL;
|
mark_frame->next = NULL;
|
||||||
mark_frame->top = PPTR(&(mark_frame->stop_here));
|
mark_frame->top = PPTR(&(mark_frame->stop_here));
|
||||||
mark_frame->end = PPTR(NUM(mark_frame) + STACK_PART_SIZE);
|
mark_frame->end = PPTR(NUM(mark_frame) + STACK_PART_SIZE);
|
||||||
|
@ -1332,15 +1343,15 @@ void GC_write_barrier(void *p)
|
||||||
|
|
||||||
void NewGC_initialize(NewGC *newgc) {
|
void NewGC_initialize(NewGC *newgc) {
|
||||||
memset(newgc, 0, sizeof(NewGC));
|
memset(newgc, 0, sizeof(NewGC));
|
||||||
newgc->mark_table = malloc(NUMBER_OF_TAGS * sizeof (Mark_Proc));
|
newgc->mark_table = ofm_malloc(NUMBER_OF_TAGS * sizeof (Mark_Proc));
|
||||||
newgc->fixup_table = malloc(NUMBER_OF_TAGS * sizeof (Fixup_Proc));
|
newgc->fixup_table = ofm_malloc(NUMBER_OF_TAGS * sizeof (Fixup_Proc));
|
||||||
#ifdef SIXTY_FOUR_BIT_INTEGERS
|
#ifdef SIXTY_FOUR_BIT_INTEGERS
|
||||||
newgc->page_maps = malloc(PAGEMAP64_LEVEL1_SIZE * sizeof (mpage***));
|
newgc->page_maps = ofm_malloc(PAGEMAP64_LEVEL1_SIZE * sizeof (mpage***));
|
||||||
#else
|
#else
|
||||||
newgc->page_maps = malloc(PAGEMAP32_SIZE * sizeof (mpage*));
|
newgc->page_maps = ofm_malloc(PAGEMAP32_SIZE * sizeof (mpage*));
|
||||||
#endif
|
#endif
|
||||||
newgc->vm = vm_create();
|
newgc->vm = vm_create();
|
||||||
newgc->protect_range = malloc(sizeof(Page_Range));
|
newgc->protect_range = ofm_malloc(sizeof(Page_Range));
|
||||||
|
|
||||||
newgc->generations_available = 1;
|
newgc->generations_available = 1;
|
||||||
newgc->last_full_mem_use = (20 * 1024 * 1024);
|
newgc->last_full_mem_use = (20 * 1024 * 1024);
|
||||||
|
@ -1355,7 +1366,7 @@ void GC_init_type_tags(int count, int pair, int mutable_pair, int weakbox, int e
|
||||||
NewGC *gc;
|
NewGC *gc;
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
|
|
||||||
gc = malloc(sizeof(NewGC));
|
gc = ofm_malloc(sizeof(NewGC));
|
||||||
GC = gc;
|
GC = gc;
|
||||||
NewGC_initialize(gc);
|
NewGC_initialize(gc);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ static void grow_roots(Roots *roots) {
|
||||||
unsigned long *new_roots;
|
unsigned long *new_roots;
|
||||||
|
|
||||||
roots->size = roots->size ? ( 2 * roots->size ) : 500;
|
roots->size = roots->size ? ( 2 * roots->size ) : 500;
|
||||||
new_roots = (unsigned long *)malloc(sizeof(unsigned long) * (roots->size + 1));
|
new_roots = (unsigned long *)ofm_malloc(sizeof(unsigned long) * (roots->size + 1));
|
||||||
|
|
||||||
memcpy((void *)new_roots, (void *)roots->roots, sizeof(unsigned long) * roots->count);
|
memcpy((void *)new_roots, (void *)roots->roots, sizeof(unsigned long) * roots->count);
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ typedef struct VM {
|
||||||
} VM;
|
} VM;
|
||||||
|
|
||||||
static VM *vm_create() {
|
static VM *vm_create() {
|
||||||
VM *vm = malloc(sizeof(VM));
|
VM *vm = ofm_malloc(sizeof(VM));
|
||||||
memset(vm, 0, sizeof(VM));
|
memset(vm, 0, sizeof(VM));
|
||||||
#if !( defined(_WIN32) || defined(OSKIT) )
|
#if !( defined(_WIN32) || defined(OSKIT) )
|
||||||
#define BLOCKFREE_CACHE_SIZE 96
|
#define BLOCKFREE_CACHE_SIZE 96
|
||||||
vm->freeblocks = malloc(sizeof(FreeBlock) * BLOCKFREE_CACHE_SIZE);
|
vm->freeblocks = ofm_malloc(sizeof(FreeBlock) * BLOCKFREE_CACHE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user