summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-07-16 13:39:57 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-17 11:21:10 -0500
commiteecdb0531d98d59d5734828356e65f0d4b9b2977 (patch)
tree553f70bfe8e102143f62e1aa246792a0d147bcfc
parent7bca0e545998f737c6f6eff08b2c2c38d7558976 (diff)
downloadhaskell-eecdb0531d98d59d5734828356e65f0d4b9b2977.tar.gz
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.
-rw-r--r--includes/rts/storage/Closures.h19
-rw-r--r--rts/RetainerProfile.c2
-rw-r--r--rts/RetainerProfile.h2
-rw-r--r--rts/TraverseHeap.c20
-rw-r--r--rts/TraverseHeap.h2
5 files changed, 18 insertions, 27 deletions
diff --git a/includes/rts/storage/Closures.h b/includes/rts/storage/Closures.h
index 0fff039cc6..ebb836bca2 100644
--- a/includes/rts/storage/Closures.h
+++ b/includes/rts/storage/Closures.h
@@ -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;
/* -----------------------------------------------------------------------------
diff --git a/rts/RetainerProfile.c b/rts/RetainerProfile.c
index b89519b05d..a996e8d2e2 100644
--- a/rts/RetainerProfile.c
+++ b/rts/RetainerProfile.c
@@ -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
diff --git a/rts/RetainerProfile.h b/rts/RetainerProfile.h
index ba0161c98d..e7a280fa5d 100644
--- a/rts/RetainerProfile.h
+++ b/rts/RetainerProfile.h
@@ -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 )
diff --git a/rts/TraverseHeap.c b/rts/TraverseHeap.c
index 55334e4104..4873f27c8b 100644
--- a/rts/TraverseHeap.c
+++ b/rts/TraverseHeap.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
diff --git a/rts/TraverseHeap.h b/rts/TraverseHeap.h
index a06a7d2f18..cc217a8858 100644
--- a/rts/TraverseHeap.h
+++ b/rts/TraverseHeap.h
@@ -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;