Bug 528644: do not generate JSOP_GETUPVAR in a generator called from eval, r=mrbkap

This commit is contained in:
David Mandelin 2010-01-06 14:33:52 -08:00
parent 52a7627592
commit 43a35e57bc
2 changed files with 24 additions and 0 deletions

View File

@ -2098,6 +2098,14 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (op != JSOP_NAME)
return JS_TRUE;
/*
* Generator functions may be resumed from any call stack, which
* defeats the display optimization to static link searching used
* by JSOP_{GET,CALL}UPVAR.
*/
if (cg->flags & TCF_FUN_IS_GENERATOR)
return JS_TRUE;
return MakeUpvarForEval(pn, cg);
}
return JS_TRUE;

View File

@ -0,0 +1,16 @@
// Don't crash
function g(foo) {
for (a in foo) {
}
}
var makegen = eval("\n\
function(b) {\n\
var h = \n\
eval(\"new function() { yield print(b) }\" ); \n\
return h\n\
}\n\
");
g(makegen());