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

rts: TraverseHeap: Simplify profiling header

Having a union in the closure profiling header really just complicates
things so get back to basics, we just have a single StgWord there for now.
parent 7bca0e54
......@@ -20,22 +20,13 @@
typedef struct {
CostCentreStack *ccs;
union {
union {
/* Accessor for the least significant bit of the entire union. Invariant:
* This must be at least as large as the largest field in this union for
* this to work. If you add more fields make sure you maintain this.
*
* See Note [Profiling heap traversal visited bit].
*/
StgWord lsb;
/* Retainer Set */
struct _RetainerSet *rs;
} trav;
StgWord trav; /* Heap traversal */
StgWord ldvw; /* Lag/Drag/Void Word */
} hp;
// Heap profiling header. This field is shared among the various heap
// profiling modes. Currently it is used by ProfHeap.c for Lag/Drag/Void
// profiling and by the heap traversal modes using TraverseHeap.c such as
// the retainer profiler.
} StgProfHeader;
/* -----------------------------------------------------------------------------
......
......@@ -251,7 +251,7 @@ associate( StgClosure *c, RetainerSet *s )
{
// StgWord has the same size as pointers, so the following type
// casting is okay.
RSET(c) = (RetainerSet *)((StgWord)s | flip);
RSET(c) = ((StgWord)s | flip);
}
static bool
......
......@@ -21,7 +21,7 @@ void endRetainerProfiling ( void );
void retainerProfile ( void );
// extract the retainer set field from c
#define RSET(c) ((c)->header.prof.hp.trav.rs)
#define RSET(c) ((c)->header.prof.hp.trav)
static inline RetainerSet *
retainerSetOf( const StgClosure *c )
......
......@@ -19,18 +19,18 @@
/** Note [Profiling heap traversal visited bit]
*
* If the RTS is compiled with profiling enabled StgProfHeader can be used by
* profiling code to store per-heap object information.
* profiling code to store per-heap object information. Specifically the
* 'hp_hdr' field is used to store heap profiling information.
*
* The generic heap traversal code reserves the least significant bit of the
* largest members of the 'trav' union to decide whether we've already visited a
* given closure in the current pass or not. The rest of the field is free to be
* used by the calling profiler.
* heap profiling word to decide whether we've already visited a given closure
* in the current pass or not. The rest of the field is free to be used by the
* calling profiler.
*
* By doing things this way we implicitly assume that the LSB of the largest
* field in the 'trav' union is insignificant. This is true at least for the
* word aligned pointers which the retainer profiler currently stores there and
* should be maintained by new users of the 'trav' union for example by shifting
* the real data up by one bit.
* By doing things this way we implicitly assume that the LSB is not used by the
* user. This is true at least for the word aligned pointers which the retainer
* profiler currently stores there and should be maintained by new users for
* example by shifting the real data up by one bit.
*
* Since we don't want to have to scan the entire heap a second time just to
* reset the per-object visitied bit before/after the real traversal we make the
......@@ -49,7 +49,7 @@
StgWord flip = 0;
#define setTravDataToZero(c) \
(c)->header.prof.hp.trav.lsb = flip
(c)->header.prof.hp.trav = flip
typedef enum {
// Object with fixed layout. Keeps an information about that
......
......@@ -22,7 +22,7 @@ void resetStaticObjectForProfiling(StgClosure *static_objects);
extern StgWord flip;
#define isTravDataValid(c) \
((((StgWord)(c)->header.prof.hp.trav.lsb & 1) ^ flip) == 0)
((((StgWord)(c)->header.prof.hp.trav & 1) ^ flip) == 0)
typedef struct traverseState_ traverseState;
......
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