static void enlargeStablePtrTable(void) { uint32_t old_SPT_size = SPT_size; spEntry *new_stable_ptr_table; // 2nd and subsequent times SPT_size *= 2; /* We temporarily retain the old version instead of freeing it; see Note * [Enlarging the stable pointer table]. */ new_stable_ptr_table = stgMallocBytes(SPT_size * sizeof *stable_ptr_table, "enlargeStablePtrTable"); memcpy(new_stable_ptr_table, stable_ptr_table, old_SPT_size * sizeof *stable_ptr_table); ASSERT(n_old_SPTs < MAX_N_OLD_SPTS); old_SPTs[n_old_SPTs++] = stable_ptr_table; /* When using the threaded RTS, the update of stable_ptr_table is assumed to * be atomic, so that another thread simultaneously dereferencing a stable * pointer will always read a valid address. */ stable_ptr_table = new_stable_ptr_table; initSpEntryFreeList(stable_ptr_table + old_SPT_size, old_SPT_size, NULL); }
void initStablePtrTable(void) { if (SPT_size > 0) return; SPT_size = INIT_SPT_SIZE; stable_ptr_table = stgMallocBytes(SPT_size * sizeof(spEntry), "initStablePtrTable"); initSpEntryFreeList(stable_ptr_table,INIT_SPT_SIZE,NULL); #if defined(THREADED_RTS) initMutex(&stable_ptr_mutex); #endif }
static void enlargeStablePtrTable(void) { nat old_SPT_size = SPT_size; // 2nd and subsequent times SPT_size *= 2; stable_ptr_table = stgReallocBytes(stable_ptr_table, SPT_size * sizeof *stable_ptr_table, "enlargeStablePtrTable"); initSpEntryFreeList(stable_ptr_table + old_SPT_size, old_SPT_size, NULL); }
void initStableTables(void) { if (SNT_size > 0) return; SNT_size = INIT_SNT_SIZE; stable_name_table = stgMallocBytes(SNT_size * sizeof *stable_name_table, "initStableNameTable"); /* we don't use index 0 in the stable name table, because that * would conflict with the hash table lookup operations which * return NULL if an entry isn't found in the hash table. */ initSnEntryFreeList(stable_name_table + 1,INIT_SNT_SIZE-1,NULL); addrToStableHash = allocHashTable(); if (SPT_size > 0) return; SPT_size = INIT_SPT_SIZE; stable_ptr_table = stgMallocBytes(SPT_size * sizeof *stable_ptr_table, "initStablePtrTable"); initSpEntryFreeList(stable_ptr_table,INIT_SPT_SIZE,NULL); #ifdef THREADED_RTS initMutex(&stable_mutex); #endif }