Commit e76ee675 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

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.
parent 08ad38a9
Pipeline #3297 passed with stages
in 380 minutes and 49 seconds
/* -----------------------------------------------------------------------------
*
* (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;
}
}
}
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment