Fix bug where lightweight function expression-statement result would contaminate caller result via js_Interpret's *result pigeon-hole, via better JSOP_POP vs. JSOP_POPV instruction selection (176125, r=shaver, a=dbaron).

This commit is contained in:
brendan%mozilla.org 2002-10-24 21:57:40 +00:00
Родитель b7279c9efc
Коммит 96d61b1511
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -1954,7 +1954,7 @@ UpdateLinenoNotes(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JSBool
js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
{
JSBool ok, useful;
JSBool ok, useful, wantval;
JSStmtInfo *stmt, stmtInfo;
ptrdiff_t top, off, tmp, beq, jmp;
JSParseNode *pn2, *pn3, *pn4;
@ -3305,9 +3305,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
* expression statement as the script's result, despite the fact
* that it appears useless to the compiler.
*/
useful = !cx->fp->fun ||
cx->fp->fun->native ||
(cx->fp->flags & JSFRAME_SPECIAL);
useful = wantval = !cx->fp->fun ||
cx->fp->fun->native ||
(cx->fp->flags & JSFRAME_SPECIAL);
if (!useful) {
if (!CheckSideEffects(cx, &cg->treeContext, pn2, &useful))
return JS_FALSE;
@ -3323,7 +3323,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
} else {
if (!js_EmitTree(cx, cg, pn2))
return JS_FALSE;
if (js_Emit1(cx, cg, JSOP_POPV) < 0)
if (js_Emit1(cx, cg, wantval ? JSOP_POPV : JSOP_POP) < 0)
return JS_FALSE;
}
}