diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-11-10 20:15:09 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-12-16 16:12:45 -0500 |
commit | e0affaa9fc3e6dc0e65808afa383426b7fe9420a (patch) | |
tree | b8315fa018b69b61cb15b71f8da856d0dd61d704 /rts/sm/GC.c | |
parent | f8e901dcc090ef81723fb9f3d8ea0a1baac4cbc3 (diff) | |
download | haskell-e0affaa9fc3e6dc0e65808afa383426b7fe9420a.tar.gz |
rts: Encapsulate access to capabilities array
Diffstat (limited to 'rts/sm/GC.c')
-rw-r--r-- | rts/sm/GC.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c index 8776f80b51..2c1b680864 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -341,8 +341,8 @@ GarbageCollect (uint32_t collect_gen, // attribute any costs to CCS_GC #if defined(PROFILING) for (n = 0; n < getNumCapabilities(); n++) { - save_CCS[n] = capabilities[n]->r.rCCCS; - capabilities[n]->r.rCCCS = CCS_GC; + save_CCS[n] = getCapability(n)->r.rCCCS; + getCapability(n)->r.rCCCS = CCS_GC; } #endif @@ -506,18 +506,18 @@ GarbageCollect (uint32_t collect_gen, if (!is_par_gc()) { for (n = 0; n < getNumCapabilities(); n++) { #if defined(THREADED_RTS) - scavenge_capability_mut_Lists1(capabilities[n]); + scavenge_capability_mut_Lists1(getCapability(n)); #else - scavenge_capability_mut_lists(capabilities[n]); + scavenge_capability_mut_lists(getCapability(n)); #endif } } else { scavenge_capability_mut_lists(gct->cap); for (n = 0; n < getNumCapabilities(); n++) { if (idle_cap[n]) { - markCapability(mark_root, gct, capabilities[n], + markCapability(mark_root, gct, getCapability(n), true/*don't mark sparks*/); - scavenge_capability_mut_lists(capabilities[n]); + scavenge_capability_mut_lists(getCapability(n)); } } } @@ -530,7 +530,7 @@ GarbageCollect (uint32_t collect_gen, gct->evac_gen_no = 0; if (!is_par_gc()) { for (n = 0; n < getNumCapabilities(); n++) { - markCapability(mark_root, gct, capabilities[n], + markCapability(mark_root, gct, getCapability(n), true/*don't mark sparks*/); } } else { @@ -573,12 +573,12 @@ GarbageCollect (uint32_t collect_gen, #if defined(THREADED_RTS) if (!is_par_gc()) { for (n = 0; n < getNumCapabilities(); n++) { - pruneSparkQueue(false, capabilities[n]); + pruneSparkQueue(false, getCapability(n)); } } else { for (n = 0; n < getNumCapabilities(); n++) { if (n == cap->no || idle_cap[n]) { - pruneSparkQueue(false, capabilities[n]); + pruneSparkQueue(false, getCapability(n)); } } } @@ -683,7 +683,7 @@ GarbageCollect (uint32_t collect_gen, if (g > 0) { W_ mut_list_size = 0; for (n = 0; n < getNumCapabilities(); n++) { - mut_list_size += countOccupied(capabilities[n]->mut_lists[g]); + mut_list_size += countOccupied(getCapability(n)->mut_lists[g]); } copied += mut_list_size; @@ -847,7 +847,7 @@ GarbageCollect (uint32_t collect_gen, if (RtsFlags.GcFlags.useNonmoving) { RELEASE_SM_LOCK; for (n = 0; n < getNumCapabilities(); n++) { - nonmovingAddUpdRemSetBlocks(&capabilities[n]->upd_rem_set.queue); + nonmovingAddUpdRemSetBlocks(&getCapability(n)->upd_rem_set.queue); } ACQUIRE_SM_LOCK; } @@ -1079,7 +1079,7 @@ GarbageCollect (uint32_t collect_gen, // restore enclosing cost centre #if defined(PROFILING) for (n = 0; n < getNumCapabilities(); n++) { - capabilities[n]->r.rCCCS = save_CCS[n]; + getCapability(n)->r.rCCCS = save_CCS[n]; } #endif @@ -1128,7 +1128,7 @@ new_gc_thread (uint32_t n, gc_thread *t) uint32_t g; gen_workspace *ws; - t->cap = capabilities[n]; + t->cap = getCapability(n); #if defined(THREADED_RTS) t->id = 0; @@ -1479,9 +1479,9 @@ waitForGcThreads (Capability *cap, bool idle_cap[]) for(i = 0; i < getNumCapabilities(); ++i) { if (i == me || idle_cap[i]) { continue; } if (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_STANDING_BY) { - prodCapability(capabilities[i], cap->running_task); + prodCapability(getCapability(i), cap->running_task); write_barrier(); - interruptCapability(capabilities[i]); + interruptCapability(getCapability(i)); } } // this 1ms timeout is not well justified. It's the shortest timeout we @@ -1632,18 +1632,18 @@ prepare_collected_gen (generation *gen) if (RtsFlags.GcFlags.useNonmoving && g == oldest_gen->no) { // Nonmoving heap's mutable list is always a root. for (i = 0; i < getNumCapabilities(); i++) { - stash_mut_list(capabilities[i], g); + stash_mut_list(getCapability(i), g); } } else if (g != 0) { // Otherwise throw away the current mutable list. Invariant: the // mutable list always has at least one block; this means we can avoid // a check for NULL in recordMutable(). for (i = 0; i < getNumCapabilities(); i++) { - bdescr *old = RELAXED_LOAD(&capabilities[i]->mut_lists[g]); + bdescr *old = RELAXED_LOAD(&getCapability(i)->mut_lists[g]); freeChain(old); bdescr *new = allocBlockOnNode(capNoToNumaNode(i)); - RELAXED_STORE(&capabilities[i]->mut_lists[g], new); + RELAXED_STORE(&getCapability(i)->mut_lists[g], new); } } @@ -1775,7 +1775,7 @@ prepare_uncollected_gen (generation *gen) // allocate a fresh block for each one. We'll traverse these // mutable lists as roots early on in the GC. for (i = 0; i < getNumCapabilities(); i++) { - stash_mut_list(capabilities[i], gen->no); + stash_mut_list(getCapability(i), gen->no); } ASSERT(gen->scavenged_large_objects == NULL); @@ -1852,7 +1852,7 @@ collect_pinned_object_blocks (void) bdescr *last = NULL; if (use_nonmoving && gen == oldest_gen) { // Mark objects as belonging to the nonmoving heap - for (bdescr *bd = RELAXED_LOAD(&capabilities[n]->pinned_object_blocks); bd != NULL; bd = bd->link) { + for (bdescr *bd = RELAXED_LOAD(&getCapability(n)->pinned_object_blocks); bd != NULL; bd = bd->link) { bd->flags |= BF_NONMOVING; bd->gen = oldest_gen; bd->gen_no = oldest_gen->no; @@ -1861,7 +1861,7 @@ collect_pinned_object_blocks (void) last = bd; } } else { - for (bdescr *bd = capabilities[n]->pinned_object_blocks; bd != NULL; bd = bd->link) { + for (bdescr *bd = getCapability(n)->pinned_object_blocks; bd != NULL; bd = bd->link) { last = bd; } } @@ -1871,8 +1871,8 @@ collect_pinned_object_blocks (void) if (gen->large_objects != NULL) { gen->large_objects->u.back = last; } - gen->large_objects = RELAXED_LOAD(&capabilities[n]->pinned_object_blocks); - RELAXED_STORE(&capabilities[n]->pinned_object_blocks, NULL); + gen->large_objects = RELAXED_LOAD(&getCapability(n)->pinned_object_blocks); + RELAXED_STORE(&getCapability(n)->pinned_object_blocks, NULL); } } } |