From cf76f7bcd144a8dfcb970ab937fede4422dfe762 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 25 Jun 2009 15:32:50 -0700 Subject: [PATCH] Print exit names instead of numbers (bug 500522, r=gal). --- js/src/jstracer.cpp | 25 +++++++++++--- js/src/jstracer.h | 81 +++++++++++++++++++++++---------------------- 2 files changed, 61 insertions(+), 45 deletions(-) diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 232c1d3288eb..1749e88a8955 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -366,6 +366,21 @@ js_InitJITLogController ( void ) } #endif +static const char* +js_ExitName(ExitType type) +{ + static const char* exitNames[] = + { + #define MAKE_EXIT_STRING(x) #x, + JS_TM_EXITCODES(MAKE_EXIT_STRING) + #undef MAKE_EXIT_STRING + }; + + JS_ASSERT(unsigned(type) < JS_ARRAY_LENGTH(exitNames)); + + return exitNames[type]; +} + /* The entire VM shares one oracle. Collisions and concurrent updates are tolerated and worst case cause performance regressions. */ static Oracle oracle; @@ -2949,8 +2964,8 @@ TraceRecorder::guard(bool expected, LIns* cond, VMSideExit* exit) { debug_only_printf(LC_TMRecorder, " About to try emitting guard code for " - "SideExit=%p exitType=%d\n", - (void*)exit, exit->exitType); + "SideExit=%p exitType=%s\n", + (void*)exit, js_ExitName(exit->exitType)); LIns* guardRec = createGuardRecord(exit); @@ -4765,7 +4780,7 @@ js_RecordLoopEdge(JSContext* cx, TraceRecorder* r, uintN& inlineCallCount) js_AbortRecording(cx, "Inner tree is trying to grow, abort outer recording"); return js_AttemptToExtendTree(cx, lr, NULL, outer); default: - debug_only_printf(LC_TMTracer, "exit_type=%d\n", lr->exitType); + debug_only_printf(LC_TMTracer, "exit_type=%s\n", js_ExitName(lr->exitType)); js_AbortRecording(cx, "Inner tree not suitable for calling"); return false; } @@ -5312,14 +5327,14 @@ LeaveTree(InterpState& state, VMSideExit* lr) #endif debug_only_printf(LC_TMTracer, - "leaving trace at %s:%u@%u, op=%s, lr=%p, exitType=%d, sp=%d, " + "leaving trace at %s:%u@%u, op=%s, lr=%p, exitType=%s, sp=%d, " "calldepth=%d, cycles=%llu\n", fp->script->filename, js_FramePCToLineNumber(cx, fp), FramePCOffset(fp), js_CodeName[fp->imacpc ? *fp->imacpc : *fp->regs->pc], (void*)lr, - lr->exitType, + js_ExitName(lr->exitType), fp->regs->sp - StackBase(fp), calldepth, cycles); diff --git a/js/src/jstracer.h b/js/src/jstracer.h index 2e56254c174d..bd3f945d1fd0 100644 --- a/js/src/jstracer.h +++ b/js/src/jstracer.h @@ -228,47 +228,48 @@ public: bool matches(TypeMap& other) const; }; +#define JS_TM_EXITCODES(_) \ + /* \ + * An exit at a possible branch-point in the trace at which to attach a \ + * future secondary trace. Therefore the recorder must generate different \ + * code to handle the other outcome of the branch condition from the \ + * primary trace's outcome. \ + */ \ + _(BRANCH) \ + /* \ + * Exit at a tableswitch via a numbered case. \ + */ \ + _(CASE) \ + /* \ + * Exit at a tableswitch via the default case. \ + */ \ + _(DEFAULT) \ + _(LOOP) \ + _(NESTED) \ + /* \ + * An exit from a trace because a condition relied upon at recording time \ + * no longer holds, where the alternate path of execution is so rare or \ + * difficult to address in native code that it is not traced at all, e.g. \ + * negative array index accesses, which differ from positive indexes in \ + * that they require a string-based property lookup rather than a simple \ + * memory access. \ + */ \ + _(MISMATCH) \ + /* \ + * A specialization of MISMATCH_EXIT to handle allocation failures. \ + */ \ + _(OOM) \ + _(OVERFLOW) \ + _(UNSTABLE_LOOP) \ + _(TIMEOUT) \ + _(DEEP_BAIL) \ + _(STATUS) + + enum ExitType { - /* - * An exit at a possible branch-point in the trace at which to attach a - * future secondary trace. Therefore the recorder must generate different - * code to handle the other outcome of the branch condition from the - * primary trace's outcome. - */ - BRANCH_EXIT, - - /* - * Exit at a tableswitch via a numbered case. - */ - CASE_EXIT, - - /* - * Exit at a tableswitch via the default case. - */ - DEFAULT_EXIT, - - LOOP_EXIT, - NESTED_EXIT, - - /* - * An exit from a trace because a condition relied upon at recording time - * no longer holds, where the alternate path of execution is so rare or - * difficult to address in native code that it is not traced at all, e.g. - * negative array index accesses, which differ from positive indexes in - * that they require a string-based property lookup rather than a simple - * memory access. - */ - MISMATCH_EXIT, - - /* - * A specialization of MISMATCH_EXIT to handle allocation failures. - */ - OOM_EXIT, - OVERFLOW_EXIT, - UNSTABLE_LOOP_EXIT, - TIMEOUT_EXIT, - DEEP_BAIL_EXIT, - STATUS_EXIT + #define MAKE_EXIT_CODE(x) x##_EXIT, + JS_TM_EXITCODES(MAKE_EXIT_CODE) + #undef MAKE_EXIT_CODE }; struct VMSideExit : public nanojit::SideExit