Bug 1151326 - Don't inline yields in legacy generators in Baseline. r=shu

This commit is contained in:
Jan de Mooij 2015-04-10 11:39:00 +02:00
parent eefac7a6c1
commit 96c9b59939
2 changed files with 21 additions and 17 deletions

View File

@ -0,0 +1,16 @@
// |jit-test| error: closing generator
var finally3;
function gen() {
try {
try {
yield 1;
} finally {
finally3();
}
} catch (e) {
yield finally3 === parseInt;
}
}
iter = gen();
iter.next();
iter.close();

View File

@ -3485,23 +3485,11 @@ BaselineCompiler::emit_JSOP_YIELD()
MOZ_ASSERT(frame.stackDepth() >= 1);
if (frame.stackDepth() == 1) {
// If the expression stack is empty, we can inline the YIELD. For legacy
// generators we normally check if we're in the closing state and throw
// an exception, but we don't have to do anything here as the expression
// stack is never empty in finally blocks. In debug builds, we assert
// we're not in the closing state.
#ifdef DEBUG
if (script->isLegacyGenerator()) {
Label ok;
masm.unboxInt32(Address(genObj, GeneratorObject::offsetOfYieldIndexSlot()),
R0.scratchReg());
masm.branch32(Assembler::NotEqual, R0.scratchReg(),
Imm32(GeneratorObject::YIELD_INDEX_CLOSING), &ok);
masm.assumeUnreachable("Inline yield with closing generator");
masm.bind(&ok);
}
#endif
if (frame.stackDepth() == 1 && !script->isLegacyGenerator()) {
// If the expression stack is empty, we can inline the YIELD. Don't do
// this for legacy generators: we have to throw an exception if the
// generator is in the closing state, see GeneratorObject::suspend.
masm.storeValue(Int32Value(GET_UINT24(pc)),
Address(genObj, GeneratorObject::offsetOfYieldIndexSlot()));