inline static int create_blank_owner_set(NewGC *gc) { int i; unsigned int curr_size = gc->owner_table_size; OTEntry **owner_table = gc->owner_table; unsigned int old_size; OTEntry **naya; for (i = 1; i < curr_size; i++) { if (!owner_table[i]) { owner_table[i] = ofm_malloc(sizeof(OTEntry)); bzero(owner_table[i], sizeof(OTEntry)); return i; } } old_size = curr_size; if (!curr_size) { curr_size = OWNER_TABLE_INIT_AMT; } else { curr_size *= 2; } gc->owner_table_size = curr_size; naya = (OTEntry **)ofm_malloc(curr_size * sizeof(OTEntry*)); memcpy(naya, owner_table, old_size*sizeof(OTEntry*)); gc->owner_table = owner_table = naya; bzero(((char*)owner_table) + (sizeof(OTEntry*) * old_size), (curr_size - old_size) * sizeof(OTEntry*)); return create_blank_owner_set(gc); }
static VM *vm_create() { VM *vm = ofm_malloc(sizeof(VM)); memset(vm, 0, sizeof(VM)); #if !( defined(_WIN32) || defined(OSKIT) ) #define BLOCKFREE_CACHE_SIZE 96 vm->freeblocks = ofm_malloc(sizeof(FreeBlock) * BLOCKFREE_CACHE_SIZE); memset(vm->freeblocks, 0, sizeof(FreeBlock) * BLOCKFREE_CACHE_SIZE); #endif return vm; }
static Page_Range *page_range_create() { Page_Range *pr = ofm_malloc_zero(sizeof(Page_Range)); pr->range_root = NULL; pr->range_start = NULL; pr->range_alloc_block = ofm_malloc(APAGE_SIZE); pr->range_alloc_size = APAGE_SIZE; pr->range_alloc_used = 0; return pr; }
inline static void BTC_register_new_thread(void *t, void *c) { NewGC *gc = GC_get_GC(); GC_Thread_Info *work; work = (GC_Thread_Info *)ofm_malloc(sizeof(GC_Thread_Info)); ((Scheme_Thread *)t)->gc_info = work; work->owner = current_owner(gc, (Scheme_Custodian *)c); work->thread = t; work->next = gc->thread_infos; gc->thread_infos = work; }
static void grow_roots(Roots *roots) { uintptr_t *new_roots; roots->size = roots->size ? ( 2 * roots->size ) : 500; new_roots = (uintptr_t *)ofm_malloc(sizeof(uintptr_t) * (roots->size + 1)); if (roots->count) memcpy((void *)new_roots, (void *)roots->roots, sizeof(uintptr_t) * roots->count); if (roots->roots) free(roots->roots); roots->roots = new_roots; }
inline static void BTC_add_account_hook(int type,void *c1,void *c2,uintptr_t b) { NewGC *gc = GC_get_GC(); AccountHook *work; if(!gc->really_doing_accounting) { if (!gc->avoid_collection) { CHECK_PARK_UNUSED(gc); gc->park[0] = c1; gc->park[1] = c2; gc->really_doing_accounting = 1; garbage_collect(gc, 1, 0, 0, NULL); c1 = gc->park[0]; gc->park[0] = NULL; c2 = gc->park[1]; gc->park[1] = NULL; } } if (type == MZACCT_LIMIT) gc->reset_limits = 1; if (type == MZACCT_REQUIRE) gc->reset_required = 1; for(work = gc->hooks; work; work = work->next) { if((work->type == type) && (work->c2 == c2) && (work->c1 == c1)) { if(type == MZACCT_REQUIRE) { if(b > work->amount) work->amount = b; } else { /* (type == MZACCT_LIMIT) */ if(b < work->amount) work->amount = b; } break; } } if(!work) { work = ofm_malloc(sizeof(AccountHook)); work->type = type; work->c1 = c1; work->c2 = c2; work->amount = b; /* push work onto hooks */ work->next = gc->hooks; gc->hooks = work; } }