summaryrefslogtreecommitdiff
path: root/rts/ProfHeap.c
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2016-05-18 06:33:03 +1000
committerErik de Castro Lopo <erikd@mega-nerd.com>2016-05-18 06:33:03 +1000
commit33c029dd77888ee5f9b1c7ce8884c982e0428adf (patch)
tree6c38a3f4c4dcc2fb20a8ce4a1c9d1dc520ec6f9d /rts/ProfHeap.c
parent5d80d14196ef048ffe037b2d92af2e9af0cb9e19 (diff)
downloadhaskell-33c029dd77888ee5f9b1c7ce8884c982e0428adf.tar.gz
rts: More const correct-ness fixes
In addition to more const-correctness fixes this patch fixes an infelicity of the previous const-correctness patch (995cf0f356) which left `UNTAG_CLOSURE` taking a `const StgClosure` pointer parameter but returning a non-const pointer. Here we restore the original type signature of `UNTAG_CLOSURE` and add a new function `UNTAG_CONST_CLOSURE` which takes and returns a const `StgClosure` pointer and uses that wherever possible. Test Plan: Validate on Linux, OS X and Windows Reviewers: Phyx, hsyl20, bgamari, austin, simonmar, trofi Reviewed By: simonmar, trofi Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2231
Diffstat (limited to 'rts/ProfHeap.c')
-rw-r--r--rts/ProfHeap.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index e98704d513..9557648fcc 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -48,7 +48,7 @@ static uint32_t max_era;
* lag/drag/void counters for each identity.
* -------------------------------------------------------------------------- */
typedef struct _counter {
- void *identity;
+ const void *identity;
union {
ssize_t resid;
struct {
@@ -103,7 +103,7 @@ static rtsBool closureSatisfiesConstraints( const StgClosure* p );
* the band to which this closure's heap space is attributed in the
* heap profile.
* ------------------------------------------------------------------------- */
-static void *
+static const void *
closureIdentity( const StgClosure *p )
{
switch (RtsFlags.ProfFlags.doHeapProfile) {
@@ -128,7 +128,7 @@ closureIdentity( const StgClosure *p )
#else
case HEAP_BY_CLOSURE_TYPE:
{
- StgInfoTable *info;
+ const StgInfoTable *info;
info = get_itbl(p);
switch (info->type) {
case CONSTR:
@@ -183,7 +183,7 @@ doingRetainerProfiling( void )
void
LDV_recordDead( const StgClosure *c, uint32_t size )
{
- void *id;
+ const void *id;
uint32_t t;
counter *ctr;
@@ -221,7 +221,7 @@ LDV_recordDead( const StgClosure *c, uint32_t size )
censuses[t+1].drag_total += size;
censuses[era].drag_total -= size;
} else {
- void *id;
+ const void *id;
id = closureIdentity(c);
ctr = lookupHashTable(censuses[t+1].hash, (StgWord)id);
ASSERT( ctr != NULL );
@@ -843,7 +843,7 @@ static void heapProfObject(Census *census, StgClosure *p, size_t size,
#endif
)
{
- void *identity;
+ const void *identity;
size_t real_size;
counter *ctr;
@@ -871,7 +871,7 @@ static void heapProfObject(Census *census, StgClosure *p, size_t size,
identity = closureIdentity((StgClosure *)p);
if (identity != NULL) {
- ctr = lookupHashTable( census->hash, (StgWord)identity );
+ ctr = lookupHashTable(census->hash, (StgWord)identity);
if (ctr != NULL) {
#ifdef PROFILING
if (RtsFlags.ProfFlags.bioSelector != NULL) {
@@ -920,7 +920,7 @@ static void
heapCensusChain( Census *census, bdescr *bd )
{
StgPtr p;
- StgInfoTable *info;
+ const StgInfoTable *info;
size_t size;
rtsBool prim;
@@ -953,7 +953,7 @@ heapCensusChain( Census *census, bdescr *bd )
}
while (p < bd->free) {
- info = get_itbl((StgClosure *)p);
+ info = get_itbl((const StgClosure *)p);
prim = rtsFalse;
switch (info->type) {