void storageAddCapabilities (nat from, nat to) { nat n, g, i; if (from > 0) { nurseries = stgReallocBytes(nurseries, to * sizeof(struct nursery_), "storageAddCapabilities"); } else { nurseries = stgMallocBytes(to * sizeof(struct nursery_), "storageAddCapabilities"); } // we've moved the nurseries, so we have to update the rNursery // pointers from the Capabilities. for (i = 0; i < to; i++) { capabilities[i].r.rNursery = &nurseries[i]; } /* The allocation area. Policy: keep the allocation area * small to begin with, even if we have a large suggested heap * size. Reason: we're going to do a major collection first, and we * don't want it to be a big one. This vague idea is borne out by * rigorous experimental evidence. */ allocNurseries(from, to); // allocate a block for each mut list for (n = from; n < to; n++) { for (g = 1; g < RtsFlags.GcFlags.generations; g++) { capabilities[n].mut_lists[g] = allocBlock(); } } initGcThreads(from, to); }
void storageAddCapabilities (uint32_t from, uint32_t to) { uint32_t n, g, i, new_n_nurseries; if (RtsFlags.GcFlags.nurseryChunkSize == 0) { new_n_nurseries = to; } else { memcount total_alloc = to * RtsFlags.GcFlags.minAllocAreaSize; new_n_nurseries = stg_max(to, total_alloc / RtsFlags.GcFlags.nurseryChunkSize); } if (from > 0) { nurseries = stgReallocBytes(nurseries, new_n_nurseries * sizeof(struct nursery_), "storageAddCapabilities"); } else { nurseries = stgMallocBytes(new_n_nurseries * sizeof(struct nursery_), "storageAddCapabilities"); } // we've moved the nurseries, so we have to update the rNursery // pointers from the Capabilities. for (i = 0; i < to; i++) { capabilities[i]->r.rNursery = &nurseries[i]; } /* The allocation area. Policy: keep the allocation area * small to begin with, even if we have a large suggested heap * size. Reason: we're going to do a major collection first, and we * don't want it to be a big one. This vague idea is borne out by * rigorous experimental evidence. */ allocNurseries(n_nurseries, new_n_nurseries); n_nurseries = new_n_nurseries; /* * Assign each of the new capabilities a nursery. Remember to start from * next_nursery, because we may have already consumed some of the earlier * nurseries. */ assignNurseriesToCapabilities(from,to); // allocate a block for each mut list for (n = from; n < to; n++) { for (g = 1; g < RtsFlags.GcFlags.generations; g++) { capabilities[n]->mut_lists[g] = allocBlockOnNode(capNoToNumaNode(n)); } } #if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR) && (CC_SUPPORTS_TLS == 0) newThreadLocalKey(&gctKey); #endif initGcThreads(from, to); }
static void enlargeStableNameTable(void) { uint32_t old_SNT_size = SNT_size; // 2nd and subsequent times SNT_size *= 2; stable_name_table = stgReallocBytes(stable_name_table, SNT_size * sizeof *stable_name_table, "enlargeStableNameTable"); initSnEntryFreeList(stable_name_table + old_SNT_size, old_SNT_size, NULL); }
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(snEntry), "enlargeStablePtrTable"); initFreeList(stable_ptr_table + old_SPT_size, old_SPT_size, NULL); }
static void more_handlers(int sig) { StgInt i; if (sig < nHandlers) return; if (signal_handlers == NULL) signal_handlers = (StgInt *)stgMallocBytes((sig + 1) * sizeof(StgInt), "more_handlers"); else signal_handlers = (StgInt *)stgReallocBytes(signal_handlers, (sig + 1) * sizeof(StgInt), "more_handlers"); for(i = nHandlers; i <= sig; i++) // Fill in the new slots with default actions signal_handlers[i] = STG_SIG_DFL; nHandlers = sig + 1; }