summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-07-16 13:49:16 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-17 11:21:10 -0500
commitd7bbaf5d45fd7b88ce331659abe29d16d086684b (patch)
tree9e3dd30895822ba3f01972008d6313803d6852aa
parenteecdb0531d98d59d5734828356e65f0d4b9b2977 (diff)
downloadhaskell-d7bbaf5d45fd7b88ce331659abe29d16d086684b.tar.gz
rts: TraverseHeap: Make trav. data macros into functions
This allows the global 'flip' variable not to be exported. This allows a future commit to also make it part of the traversalState struct.
-rw-r--r--rts/RetainerProfile.c9
-rw-r--r--rts/RetainerProfile.h12
-rw-r--r--rts/TraverseHeap.c21
-rw-r--r--rts/TraverseHeap.h10
4 files changed, 30 insertions, 22 deletions
diff --git a/rts/RetainerProfile.c b/rts/RetainerProfile.c
index a996e8d2e2..7222bed0ad 100644
--- a/rts/RetainerProfile.c
+++ b/rts/RetainerProfile.c
@@ -251,7 +251,14 @@ associate( StgClosure *c, RetainerSet *s )
{
// StgWord has the same size as pointers, so the following type
// casting is okay.
- RSET(c) = ((StgWord)s | flip);
+ setTravData(c, (StgWord)s);
+}
+
+inline RetainerSet*
+retainerSetOf( const StgClosure *c )
+{
+ ASSERT(isTravDataValid(c));
+ return (RetainerSet*)getTravData(c);
}
static bool
diff --git a/rts/RetainerProfile.h b/rts/RetainerProfile.h
index e7a280fa5d..6a2dc5e846 100644
--- a/rts/RetainerProfile.h
+++ b/rts/RetainerProfile.h
@@ -20,17 +20,7 @@ void initRetainerProfiling ( void );
void endRetainerProfiling ( void );
void retainerProfile ( void );
-// extract the retainer set field from c
-#define RSET(c) ((c)->header.prof.hp.trav)
-
-static inline RetainerSet *
-retainerSetOf( const StgClosure *c )
-{
- ASSERT( isTravDataValid(c) );
- // StgWord has the same size as pointers, so the following type
- // casting is okay.
- return (RetainerSet *)((StgWord)RSET(c) ^ flip);
-}
+RetainerSet* retainerSetOf( const StgClosure *c );
// Used by GC.c
W_ retainerStackBlocks(void);
diff --git a/rts/TraverseHeap.c b/rts/TraverseHeap.c
index 4873f27c8b..110cae3b34 100644
--- a/rts/TraverseHeap.c
+++ b/rts/TraverseHeap.c
@@ -46,10 +46,23 @@
* mutable data. There we do just go over all existing objects to reset the bit
* manually. See 'resetStaticObjectForProfiling' and 'resetMutableObjects'.
*/
-StgWord flip = 0;
+static StgWord flip = 0;
-#define setTravDataToZero(c) \
- (c)->header.prof.hp.trav = flip
+StgWord getTravData(const StgClosure *c)
+{
+ const StgWord hp_hdr = c->header.prof.hp.trav;
+ return hp_hdr & (STG_WORD_MAX ^ 1);
+}
+
+void setTravData(StgClosure *c, StgWord w)
+{
+ c->header.prof.hp.trav = w | flip;
+}
+
+bool isTravDataValid(const StgClosure *c)
+{
+ return ((c->header.prof.hp.trav & 1) ^ flip) == 0;
+}
typedef enum {
// Object with fixed layout. Keeps an information about that
@@ -949,7 +962,7 @@ bool
traverseMaybeInitClosureData(StgClosure *c)
{
if (!isTravDataValid(c)) {
- setTravDataToZero(c);
+ setTravData(c, 0);
return true;
}
return false;
diff --git a/rts/TraverseHeap.h b/rts/TraverseHeap.h
index cc217a8858..3855123323 100644
--- a/rts/TraverseHeap.h
+++ b/rts/TraverseHeap.h
@@ -18,12 +18,6 @@
void resetStaticObjectForProfiling(StgClosure *static_objects);
-/* See Note [Profiling heap traversal visited bit]. */
-extern StgWord flip;
-
-#define isTravDataValid(c) \
- ((((StgWord)(c)->header.prof.hp.trav & 1) ^ flip) == 0)
-
typedef struct traverseState_ traverseState;
typedef union stackData_ {
@@ -128,6 +122,10 @@ typedef bool (*visitClosure_cb) (
stackAccum *accum,
stackData *child_data);
+StgWord getTravData(const StgClosure *c);
+void setTravData(StgClosure *c, StgWord w);
+bool isTravDataValid(const StgClosure *c);
+
void traverseWorkStack(traverseState *ts, visitClosure_cb visit_cb);
void traversePushRoot(traverseState *ts, StgClosure *c, StgClosure *cp, stackData data);
bool traverseMaybeInitClosureData(StgClosure *c);