diff --git a/mozilla/js/src/jsopcode.c b/mozilla/js/src/jsopcode.c index c78cd92b559..74bf2ccb5b0 100644 --- a/mozilla/js/src/jsopcode.c +++ b/mozilla/js/src/jsopcode.c @@ -1606,8 +1606,18 @@ InitSprintStack(JSContext *cx, SprintStack *ss, JSPrinter *jp, uintN depth) return JS_TRUE; } -static JS_INLINE jsbytecode * -DecompileBytecode(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) +/* + * If nb is non-negative, decompile nb bytecodes starting at pc. Otherwise + * the decompiler starts at pc and continues until it reaches an opcode for + * which decompiling would result in the stack depth equaling -(nb + 1). + * + * The nextop parameter is either JSOP_NOP or the "next" opcode in order of + * abstract interpretation (not necessarily physically next in a bytecode + * vector). So nextop is JSOP_POP for the last operand in a comma expression, + * or JSOP_AND for the right operand of &&. + */ +static jsbytecode * +Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) { JSContext *cx; JSPrinter *jp, *jp2; @@ -1714,6 +1724,7 @@ DecompileBytecode(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) JS_END_MACRO cx = ss->sprinter.context; + JS_CHECK_RECURSION(cx, return NULL); jp = ss->printer; startpc = pc; @@ -4546,46 +4557,6 @@ DecompileBytecode(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) return pc; } -/* - * If nb is non-negative, decompile nb bytecodes starting at pc. Otherwise - * the decompiler starts at pc and continues until it reaches an opcode for - * which decompiling would result in the stack depth equaling -(nb + 1). - * - * The nextop parameter is either JSOP_NOP or the "next" opcode in order of - * abstract interpretation (not necessarily physically next in a bytecode - * vector). So nextop is JSOP_POP for the last operand in a comma expression, - * or JSOP_AND for the right operand of &&. - */ -static jsbytecode * -Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) -{ - JSContext *cx; - JSPrinter *jp; - jsbytecode *oldcode, *oldmain, *code; - - cx = ss->sprinter.context; - JS_CHECK_RECURSION(cx, return NULL); - - jp = ss->printer; - oldcode = jp->script->code; - oldmain = jp->script->main; - code = js_UntrapScriptCode(cx, jp->script); - if (code != oldcode) { - jp->script->code = code; - jp->script->main = code + (oldmain - jp->script->code); - pc = code + (pc - oldcode); - } - - pc = DecompileBytecode(ss, pc, nb, nextop); - - if (code != oldcode) { - JS_free(cx, jp->script->code); - jp->script->code = oldcode; - jp->script->main = oldmain; - } - return (pc ? pc - code + oldcode : NULL); -} - static JSBool DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len, uintN pcdepth) @@ -4596,6 +4567,7 @@ DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len, void *mark; JSBool ok; JSScript *oldscript; + jsbytecode *oldcode, *oldmain, *code; char *last; depth = script->depth; @@ -4630,7 +4602,21 @@ DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len, /* Call recursive subroutine to do the hard work. */ oldscript = jp->script; jp->script = script; + oldcode = jp->script->code; + oldmain = jp->script->main; + code = js_UntrapScriptCode(cx, jp->script); + if (code != oldcode) { + jp->script->code = code; + jp->script->main = code + (oldmain - jp->script->code); + pc = code + (pc - oldcode); + } + ok = Decompile(&ss, pc, len, JSOP_NOP) != NULL; + if (code != oldcode) { + JS_free(cx, jp->script->code); + jp->script->code = oldcode; + jp->script->main = oldmain; + } jp->script = oldscript; /* If the given code didn't empty the stack, do it now. */