Skip to content

Commit

Permalink
Accumulate NYIs and print them only at the end.
Browse files Browse the repository at this point in the history
NYIs ("Not Yet Implemented" warnings) were previously printed on the
fly.  Since printing is incredibly slow in C++ and some NYIs are very
frequent, it's better to just increment a counter and print the final
counters at the end.
  • Loading branch information
nominolo committed Sep 20, 2012
1 parent 3b79b98 commit 66cee8a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
23 changes: 23 additions & 0 deletions vm/common.hh
Expand Up @@ -332,6 +332,29 @@ typedef Word BloomFilter;
#define bloomset(b, x) ((b) |= bloombit((x)))
#define bloomtest(b, x) ((b) & bloombit((x)))

/*
* Features not yet implemented.
*/
#define NYIDEF(_) \
_(GROW_IRBUFFER, "Growing IR Buffer") \
_(RECORD_MOV_RES_EXT, "Recording of MOV_RES with out-of-trace input.") \
_(RECORD_UPDATE_CAF, "Recording of UPDATE with a CAF argument.") \
_(RECORD_EVAL_IND, "Recording of EVAL of an indirection.") \
_(TRACE_TRUNCATE, "Trace truncation due to inner loop.") \
_(RECORD_CREATE_PAP, "Recording of call which creates a PAP.") \
_(RECORD_CALL_PAP, "Recording of a call of a PAP.") \
_(RECORD_CALL_THUNK, "Recording of call of a thunk/CAF.")

enum {
#define NYIENUM(name, descr) NYI_##name,
NYIDEF(NYIENUM)
#undef NYIENUM
NYI__MAX
};

void logNYI(uint32_t nyi_id);
void printLoggedNYIs(FILE *);

_END_LAMBDACHINE_NAMESPACE

#endif /* LAMBDACHINE_COMMON_H */
45 changes: 35 additions & 10 deletions vm/jit.cc
Expand Up @@ -232,19 +232,19 @@ bool Jit::recordGenericApply(uint32_t call_info, Word *base,
uint32_t pointer_mask = call_info >> 8;
switch (fnode->info()->type()) {
case PAP:
cerr << "NYI: Calling of PAPs." << endl;
logNYI(NYI_RECORD_CALL_PAP);
return false;
case THUNK:
case CAF:
cerr << "NYI: Calling of THUNK/CAFs." << endl;
logNYI(NYI_RECORD_CALL_THUNK);
return false;
case FUN: {
const CodeInfoTable *info = (CodeInfoTable *)fnode->info();
uint32_t arity = info->code()->arity;
if (arity == given_args)
return true;
if (arity > given_args) {
cerr << "NYI: Partial applications." << endl;
logNYI(NYI_RECORD_CREATE_PAP);
return false;
}

Expand Down Expand Up @@ -325,7 +325,7 @@ bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
return true;
} else {
DBG(cerr << COL_GREEN << "REC: Inner loop. " << buf_.pc_ << COL_RESET);
cerr << "NYI: Trace truncation due to inner loop.\n";
logNYI(NYI_TRACE_TRUNCATE);
goto abort_recording;
}
}
Expand Down Expand Up @@ -469,7 +469,7 @@ bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
case BcIns::kEVAL: {
Closure *tnode = (Closure *)base[ins->a()];
if (tnode->isIndirection()) {
cerr << "NYI: EVAL of indirections" << endl;
logNYI(NYI_RECORD_EVAL_IND);
goto abort_recording;
}
TRef noderef = buf_.slot(ins->a());
Expand Down Expand Up @@ -549,7 +549,7 @@ bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
case BcIns::kMOV_RES: {
if (!(IRRef)lastResult_) {
#if !defined(NDEBUG)
cerr << "NYI: MOV_RES with out-of trace input." << endl;
logNYI(NYI_RECORD_MOV_RES_EXT);
#endif
goto abort_recording;
}
Expand All @@ -566,11 +566,10 @@ bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
InfoTable *info = oldnode->info();

if (info->type() == CAF) {
cerr << "NYI: UPDATE of a CAF." << endl;
logNYI(NYI_RECORD_UPDATE_CAF);
goto abort_recording;
}


TRef oldref = buf_.slot(ins->a());
TRef newref = buf_.slot(ins->d());

Expand Down Expand Up @@ -704,8 +703,6 @@ bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
F->traceId());
finishRecording();
return true;
cerr << "NYI: Trace through JFUNC?\n";
goto abort_recording;
}
}

Expand Down Expand Up @@ -1009,4 +1006,32 @@ debugTrace(ExitState *ex) {
traceDebugLastHp = (Word *)ex->gpr[RID_HP];
}

static const char *nyiDescription[NYI__MAX] = {
#define NYIDESCR(name, descr) descr,
NYIDEF(NYIDESCR)
#undef NYIDESCR
};

static uint64_t nyiCount[NYI__MAX] = {
#define NYICOUNT(name, descr) 0,
NYIDEF(NYICOUNT)
#undef NYICOUNT
};

void
logNYI(uint32_t nyi_id)
{
LC_ASSERT(nyi_id < NYI__MAX);
++nyiCount[nyi_id];
}

void
printLoggedNYIs(FILE *out)
{
for (uint32_t i = 0; i < NYI__MAX; ++i) {
if (nyiCount[i] > 0)
fprintf(out, "%3lu x NYI: %s\n", nyiCount[i], nyiDescription[i]);
}
}

_END_LAMBDACHINE_NAMESPACE
3 changes: 3 additions & 0 deletions vm/main.cc
Expand Up @@ -84,6 +84,9 @@ int main(int argc, char *argv[]) {

delete T;

printf("\n\n");
printLoggedNYIs(stdout);

printf("\n\n");
printGCStats(stdout, &mm, mut_time);

Expand Down

0 comments on commit 66cee8a

Please sign in to comment.