Commit f3bb7397 authored by Daniel Gröber (dxld)'s avatar Daniel Gröber (dxld)

rts: RetainerSet: Remove obsolete fist/second-approach choice

In the old code when DEBUG_RETAINER was set, FIRST_APPROACH is
implied. However ProfHeap.c now depends on printRetainerSetShort which is
only available with SECOND_APPROACH. This is because with FIRST_APPROACH
retainerProfile() will free all retainer sets before returning so by the
time ProfHeap calls dumpCensus the retainer set pointers are segfaulty.

Since all of this debugging code obviously hasn't been compiled in ages
anyways I'm taking the liberty of just removing it.

Remember guys: Dead code is a liability not an asset :)
parent b92ed68a
......@@ -1038,9 +1038,7 @@ initRetainerProfiling( void )
void
endRetainerProfiling( void )
{
#if defined(SECOND_APPROACH)
outputAllRetainerSet(prof_file);
#endif
}
/* -----------------------------------------------------------------------------
......@@ -1191,14 +1189,6 @@ isRetainer( StgClosure *c )
* This function does NOT return the retainer(s) of *c.
* Invariants:
* *c must be a retainer.
* Note:
* Depending on the definition of this function, the maintenance of retainer
* sets can be made easier. If most retainer sets are likely to be created
* again across garbage collections, refreshAllRetainerSet() in
* RetainerSet.c can simply do nothing.
* If this is not the case, we can free all the retainer sets and
* re-initialize the hash table.
* See refreshAllRetainerSet() in RetainerSet.c.
* -------------------------------------------------------------------------- */
static INLINE retainer
getRetainerFrom( StgClosure *c )
......@@ -1996,11 +1986,7 @@ retainerProfile(void)
retainer sets.
*/
initializeTraverseStack(&g_retainerTraverseState);
#if defined(DEBUG_RETAINER)
initializeAllRetainerSet();
#else
refreshAllRetainerSet();
#endif
computeRetainerSet(&g_retainerTraverseState);
#if defined(DEBUG_RETAINER)
......@@ -2044,11 +2030,6 @@ retainerProfile(void)
// post-processing
closeTraverseStack(&g_retainerTraverseState);
#if defined(DEBUG_RETAINER)
closeAllRetainerSet();
#else
// Note that there is no post-processing for the retainer sets.
#endif
retainerGeneration++;
stat_endRP(
......
......@@ -73,25 +73,6 @@ initializeAllRetainerSet(void)
nextId = 2; // Initial value must be positive, 2 is MANY.
}
/* -----------------------------------------------------------------------------
* Refreshes all pools for reuse and initializes hashTable[].
* -------------------------------------------------------------------------- */
void
refreshAllRetainerSet(void)
{
#if defined(FIRST_APPROACH)
int i;
// first approach: completely refresh
arenaFree(arena);
arena = newArena();
for (i = 0; i < HASH_TABLE_SIZE; i++)
hashTable[i] = NULL;
nextId = 2;
#endif /* FIRST_APPROACH */
}
/* -----------------------------------------------------------------------------
* Frees all pools.
* -------------------------------------------------------------------------- */
......@@ -229,7 +210,6 @@ printRetainer(FILE *f, retainer ccs)
* printRetainerSetShort() should always display the same output for
* a given retainer set regardless of the time of invocation.
* -------------------------------------------------------------------------- */
#if defined(SECOND_APPROACH)
void
printRetainerSetShort(FILE *f, RetainerSet *rs, W_ total_size, uint32_t max_length)
{
......@@ -265,14 +245,12 @@ printRetainerSetShort(FILE *f, RetainerSet *rs, W_ total_size, uint32_t max_leng
fputs(tmp, f);
traceHeapProfSampleString(0, tmp, total_size);
}
#endif /* SECOND_APPROACH */
/* -----------------------------------------------------------------------------
* Dump the contents of each retainer set into the log file at the end
* of the run, so the user can find out for a given retainer set ID
* the full contents of that set.
* -------------------------------------------------------------------------- */
#if defined(SECOND_APPROACH)
void
outputAllRetainerSet(FILE *prof_file)
{
......@@ -333,6 +311,5 @@ outputAllRetainerSet(FILE *prof_file)
stgFree(rsArray);
}
#endif /* SECOND_APPROACH */
#endif /* PROFILING */
......@@ -52,31 +52,10 @@ typedef struct _RetainerSet {
// do not put anything below here!
} RetainerSet;
/*
Note:
There are two ways of maintaining all retainer sets. The first is simply by
freeing all the retainer sets and re-initialize the hash table at each
retainer profiling. The second is by setting the cost field of each
retainer set. The second is preferred to the first if most retainer sets
are likely to be observed again during the next retainer profiling. Note
that in the first approach, we do not free the memory allocated for
retainer sets; we just invalidate all retainer sets.
*/
#if defined(DEBUG_RETAINER)
// In thise case, FIRST_APPROACH must be turned on because the memory pool
// for retainer sets is freed each time.
#define FIRST_APPROACH
#else
// #define FIRST_APPROACH
#define SECOND_APPROACH
#endif
// Creates the first pool and initializes a hash table. Frees all pools if any.
void initializeAllRetainerSet(void);
// Refreshes all pools for reuse and initializes a hash table.
void refreshAllRetainerSet(void);
// Frees all pools.
void closeAllRetainerSet(void);
......@@ -138,25 +117,21 @@ isMember(retainer r, RetainerSet *rs)
// Finds or creates a retainer set augmented with a new retainer.
RetainerSet *addElement(retainer, RetainerSet *);
#if defined(SECOND_APPROACH)
// Prints a single retainer set.
void printRetainerSetShort(FILE *, RetainerSet *, W_, uint32_t);
#endif
// Print the statistics on all the retainer sets.
// store the sum of all costs and the number of all retainer sets.
void outputRetainerSet(FILE *, uint32_t *, uint32_t *);
#if defined(SECOND_APPROACH)
// Print all retainer sets at the exit of the program.
void outputAllRetainerSet(FILE *);
#endif
// Hashing functions
/*
Invariants:
Once either initializeAllRetainerSet() or refreshAllRetainerSet()
is called, there exists only one copy of any retainer set created
Once initializeAllRetainerSet() is called,
there exists only one copy of any retainer set created
through singleton() and addElement(). The pool (the storage for
retainer sets) is consumed linearly. All the retainer sets of the
same hash function value are linked together from an element in
......
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