Fix useless expression elimination to work with native-function-called JS_EvaluateScript (87271, r=rogerl, sr=jband).

This commit is contained in:
brendan%mozilla.org 2001-08-10 07:55:17 +00:00
Родитель f736866828
Коммит 6abf5d1dd4
1 изменённых файлов: 5 добавлений и 4 удалений

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

@ -2141,11 +2141,12 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
pn2 = pn->pn_kid;
if (pn2) {
/*
* Top-level JS_Execute/EvaluateScript, debugger, and eval frames
* may need the last expression statement's value as the script's
* result, even though it appears useless otherwise.
* Top-level or called-from-a-native JS_Execute/EvaluateScript,
* debugger, and eval frames may need the value of the ultimate
* expression statement as the script's result, despite the fact
* that it appears useless to the compiler.
*/
useful = !cx->fp->fun || cx->fp->special;
useful = !cx->fp->fun || cx->fp->fun->native || cx->fp->special;
if (!useful) {
if (!CheckSideEffects(cx, &cg->treeContext, pn2, &useful))
return JS_FALSE;