diff options
author | Ben Gamari <ben@well-typed.com> | 2019-02-05 10:59:32 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-03-09 07:30:17 -0500 |
commit | e76ee67510be951cea13636a763daae53108197c (patch) | |
tree | bea9fcb84d6efd7039121be67d07f90c87b29251 /rts | |
parent | 08ad38a93cb7037bbafcd3e12b27c876d714c5c0 (diff) | |
download | haskell-e76ee67510be951cea13636a763daae53108197c.tar.gz |
rts: Factor out large bitmap walking
This will be needed by the mark phase of the non-moving collector
so let's factor it out.
Diffstat (limited to 'rts')
-rw-r--r-- | rts/sm/HeapUtils.h | 33 | ||||
-rw-r--r-- | rts/sm/Scav.c | 23 |
2 files changed, 40 insertions, 16 deletions
diff --git a/rts/sm/HeapUtils.h b/rts/sm/HeapUtils.h new file mode 100644 index 0000000000..2e9ca34f73 --- /dev/null +++ b/rts/sm/HeapUtils.h @@ -0,0 +1,33 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team 1998-2008 + * + * General utilities for walking the heap + * + * ---------------------------------------------------------------------------*/ + +#pragma once + +typedef void (walk_closures_cb)(StgClosure **, void *); + +INLINE_HEADER void +walk_large_bitmap(walk_closures_cb *cb, + StgClosure **p, + StgLargeBitmap *large_bitmap, + StgWord size, + void *user) +{ + uint32_t b = 0; + + for (uint32_t i = 0; i < size; b++) { + StgWord bitmap = large_bitmap->bitmap[b]; + uint32_t j = stg_min(size-i, BITS_IN(W_)); + i += j; + for (; j > 0; j--, p++) { + if ((bitmap & 1) == 0) { + cb(p, user); + } + bitmap = bitmap >> 1; + } + } +} diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 8bc702900b..36592af887 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -58,6 +58,7 @@ #include "Sanity.h" #include "Capability.h" #include "LdvProfile.h" +#include "HeapUtils.h" #include "Hash.h" #include "sm/MarkWeak.h" @@ -77,6 +78,11 @@ static void scavenge_large_bitmap (StgPtr p, # define scavenge_capability_mut_lists(cap) scavenge_capability_mut_Lists1(cap) #endif +static void do_evacuate(StgClosure **p, void *user STG_UNUSED) +{ + evacuate(p); +} + /* ----------------------------------------------------------------------------- Scavenge a TSO. -------------------------------------------------------------------------- */ @@ -1777,22 +1783,7 @@ scavenge_static(void) static void scavenge_large_bitmap( StgPtr p, StgLargeBitmap *large_bitmap, StgWord size ) { - uint32_t i, j, b; - StgWord bitmap; - - b = 0; - - for (i = 0; i < size; b++) { - bitmap = large_bitmap->bitmap[b]; - j = stg_min(size-i, BITS_IN(W_)); - i += j; - for (; j > 0; j--, p++) { - if ((bitmap & 1) == 0) { - evacuate((StgClosure **)p); - } - bitmap = bitmap >> 1; - } - } + walk_large_bitmap(do_evacuate, (StgClosure **) p, large_bitmap, size, NULL); } |