Commit cb89ba88 authored by Simon Jakobi's avatar Simon Jakobi Committed by Ben Gamari

RTS: Remove unused retainer schemes

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #11777

Differential Revision: https://phabricator.haskell.org/D4427
parent be498a24
......@@ -1143,16 +1143,7 @@ getRetainerFrom( StgClosure *c )
{
ASSERT(isRetainer(c));
#if defined(RETAINER_SCHEME_INFO)
// Retainer scheme 1: retainer = info table
return get_itbl(c);
#elif defined(RETAINER_SCHEME_CCS)
// Retainer scheme 2: retainer = cost centre stack
return c->header.prof.ccs;
#elif defined(RETAINER_SCHEME_CC)
// Retainer scheme 3: retainer = cost centre
return c->header.prof.ccs->cc;
#endif
}
/* -----------------------------------------------------------------------------
......
......@@ -218,82 +218,17 @@ addElement(retainer r, RetainerSet *rs)
* printRetainer() prints the full information on a given retainer,
* not a retainer set.
* -------------------------------------------------------------------------- */
#if defined(RETAINER_SCHEME_INFO)
// Retainer scheme 1: retainer = info table
static void
printRetainer(FILE *f, retainer itbl)
{
fprintf(f, "%s[%s]", GET_PROF_DESC(itbl), itbl->prof.closure_type);
}
#elif defined(RETAINER_SCHEME_CCS)
// Retainer scheme 2: retainer = cost centre stack
static void
printRetainer(FILE *f, retainer ccs)
{
fprintCCS(f, ccs);
}
#elif defined(RETAINER_SCHEME_CC)
// Retainer scheme 3: retainer = cost centre
static void
printRetainer(FILE *f, retainer cc)
{
fprintf(f,"%s.%s", cc->module, cc->label);
}
#endif
/* -----------------------------------------------------------------------------
* printRetainerSetShort() should always display the same output for
* a given retainer set regardless of the time of invocation.
* -------------------------------------------------------------------------- */
#if defined(SECOND_APPROACH)
#if defined(RETAINER_SCHEME_INFO)
// Retainer scheme 1: retainer = info table
void
printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length)
{
char tmp[max_length + 1];
int size;
uint32_t j;
ASSERT(rs->id < 0);
tmp[max_length] = '\0';
// No blank characters are allowed.
sprintf(tmp + 0, "(%d)", -(rs->id));
size = strlen(tmp);
ASSERT(size < max_length);
for (j = 0; j < rs->num; j++) {
if (j < rs->num - 1) {
strncpy(tmp + size, GET_PROF_DESC(rs->element[j]), max_length - size);
size = strlen(tmp);
if (size == max_length)
break;
strncpy(tmp + size, ",", max_length - size);
size = strlen(tmp);
if (size == max_length)
break;
}
else {
strncpy(tmp + size, GET_PROF_DESC(rs->element[j]), max_length - size);
// size = strlen(tmp);
}
}
fprintf(f, tmp);
}
#elif defined(RETAINER_SCHEME_CC)
// Retainer scheme 3: retainer = cost centre
void
printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length)
{
char tmp[max_length + 1];
int size;
uint32_t j;
}
#elif defined(RETAINER_SCHEME_CCS)
// Retainer scheme 2: retainer = cost centre stack
void
printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length)
{
......@@ -328,82 +263,6 @@ printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length)
}
fputs(tmp, f);
}
#elif defined(RETAINER_SCHEME_CC)
// Retainer scheme 3: retainer = cost centre
static void
printRetainerSetShort(FILE *f, retainerSet *rs, uint32_t max_length)
{
char tmp[max_length + 1];
int size;
uint32_t j;
ASSERT(rs->id < 0);
tmp[max_length] = '\0';
// No blank characters are allowed.
sprintf(tmp + 0, "(%d)", -(rs->id));
size = strlen(tmp);
ASSERT(size < max_length);
for (j = 0; j < rs->num; j++) {
if (j < rs->num - 1) {
strncpy(tmp + size, rs->element[j]->label,
max_length - size);
size = strlen(tmp);
if (size == max_length)
break;
strncpy(tmp + size, ",", max_length - size);
size = strlen(tmp);
if (size == max_length)
break;
}
else {
strncpy(tmp + size, rs->element[j]->label,
max_length - size);
// size = strlen(tmp);
}
}
fprintf(f, tmp);
/*
#define DOT_NUMBER 3
// 1. 32 > max_length + 1 (1 for '\0')
// 2. (max_length - DOT_NUMBER ) characters should be enough for
// printing one natural number (plus '(' and ')').
char tmp[32];
int size, ts;
uint32_t j;
ASSERT(rs->id < 0);
// No blank characters are allowed.
sprintf(tmp + 0, "(%d)", -(rs->id));
size = strlen(tmp);
ASSERT(size < max_length - DOT_NUMBER);
for (j = 0; j < rs->num; j++) {
ts = strlen(rs->element[j]->label);
if (j < rs->num - 1) {
if (size + ts + 1 > max_length - DOT_NUMBER) {
sprintf(tmp + size, "...");
break;
}
sprintf(tmp + size, "%s,", rs->element[j]->label);
size += ts + 1;
}
else {
if (size + ts > max_length - DOT_NUMBER) {
sprintf(tmp + size, "...");
break;
}
sprintf(tmp + size, "%s", rs->element[j]->label);
size += ts;
}
}
fprintf(f, tmp);
*/
}
#endif /* RETAINER_SCHEME_CC */
#endif /* SECOND_APPROACH */
/* -----------------------------------------------------------------------------
......
......@@ -25,34 +25,13 @@
its retainer identity because its location may change during garbage
collections.
2. Type 'retainer' must come with comparison operations as well as
an equality operation. That it, <, >, and == must be supported -
an equality operation. That is, <, >, and == must be supported -
this is necessary to store retainers in a sorted order in retainer sets.
Therefore, you cannot use a huge structure type as 'retainer', for instance.
We illustrate three possibilities of defining 'retainer identity'.
Choose one of the following three compiler directives:
Retainer scheme 1 (RETAINER_SCHEME_INFO) : retainer = info table
Retainer scheme 2 (RETAINER_SCHEME_CCS) : retainer = cost centre stack
Retainer scheme 3 (RETAINER_SCHEME_CC) : retainer = cost centre
*/
// #define RETAINER_SCHEME_INFO
#define RETAINER_SCHEME_CCS
// #define RETAINER_SCHEME_CC
#if defined(RETAINER_SCHEME_INFO)
struct _StgInfoTable;
typedef struct _StgInfoTable *retainer;
#endif
#if defined(RETAINER_SCHEME_CCS)
typedef CostCentreStack *retainer;
#endif
#if defined(RETAINER_SCHEME_CC)
typedef CostCentre *retainer;
#endif
/*
Type 'retainerSet' defines an abstract datatype for sets of retainers.
......
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