Add debug hook to the threaded interpreter to trace instruction stream (476128, r=shaver).
Add debug hook to the threaded interpreter to trace instruction stream (476128, r=shaver).
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -2517,17 +2517,26 @@ js_Interpret(JSContext *cx)
JS_EXTENSION_(goto *jumpTable[op]); \
JS_END_MACRO
# define DO_NEXT_OP(n) JS_BEGIN_MACRO \
METER_OP_PAIR(op, regs.pc[n]); \
op = (JSOp) *(regs.pc += (n)); \
DO_OP(); \
JS_END_MACRO
-# define BEGIN_CASE(OP) L_##OP: CHECK_RECORDER();
+# ifdef DEBUG
+# define TRACE_OPCODE(OP) JS_BEGIN_MACRO \
+ if (cx->tracefp) \
+ js_TraceOpcode(cx, len); \
+ JS_END_MACRO
+# else
+# define TRACE_OPCODE(OP) (void)0
+# endif
+
+# define BEGIN_CASE(OP) L_##OP: TRACE_OPCODE(OP); CHECK_RECORDER();
# define END_CASE(OP) DO_NEXT_OP(OP##_LENGTH);
# define END_VARLEN_CASE DO_NEXT_OP(len);
# define ADD_EMPTY_CASE(OP) BEGIN_CASE(OP) \
JS_ASSERT(js_CodeSpec[OP].length == 1); \
op = (JSOp) *++regs.pc; \
DO_OP();
# define END_EMPTY_CASES