[commit: ghc] wip/nonmoving-gc: rts: Factor out large bitmap walking (cfc0004)
git at git.haskell.org
git at git.haskell.org
Wed Feb 6 14:09:49 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nonmoving-gc
Link : http://ghc.haskell.org/trac/ghc/changeset/cfc000402c98f6c8775c0d5d66b7f2953c61eb98/ghc
>---------------------------------------------------------------
commit cfc000402c98f6c8775c0d5d66b7f2953c61eb98
Author: Ben Gamari <ben at well-typed.com>
Date: Tue Feb 5 10:59:32 2019 -0500
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.
>---------------------------------------------------------------
cfc000402c98f6c8775c0d5d66b7f2953c61eb98
rts/sm/HeapUtils.h | 33 +++++++++++++++++++++++++++++++++
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 0000000..2e9ca34
--- /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 8bc7029..36592af 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);
}
More information about the ghc-commits
mailing list