Commit d7bbaf5d authored by Daniel Gröber (dxld)'s avatar Daniel Gröber (dxld) Committed by Marge Bot

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.
parent eecdb053
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
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