Bug 1213574 - Fix up static scopes inside scripts wrt the static global lexical scope when merging parse task compartments. (r=jandem)

This commit is contained in:
Shu-yu Guo 2015-10-12 23:09:42 -07:00
parent b26c1f0454
commit 38300c53dc
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,15 @@
if (helperThreadCount() === 0)
quit(0);
var lfGlobal = newGlobal();
lfGlobal.offThreadCompileScript(`let (x) { throw 42; }`);
try {
lfGlobal.runOffThreadScript();
} catch (e) {
}
lfGlobal.offThreadCompileScript(`function f() { { let x = 42; return x; } }`);
try {
lfGlobal.runOffThreadScript();
} catch (e) {
}

View File

@ -6740,6 +6740,11 @@ gc::MergeCompartments(JSCompartment* source, JSCompartment* target)
// Fixup compartment pointers in source to refer to target, and make sure
// type information generations are in sync.
// Get the static global lexical scope of the target compartment. Static
// scopes need to be fixed up below.
RootedObject targetStaticGlobalLexicalScope(rt);
targetStaticGlobalLexicalScope = &target->maybeGlobal()->lexicalScope().staticBlock();
for (ZoneCellIter iter(source->zone(), AllocKind::SCRIPT); !iter.done(); iter.next()) {
JSScript* script = iter.get<JSScript>();
MOZ_ASSERT(script->compartment() == source);
@ -6753,6 +6758,20 @@ gc::MergeCompartments(JSCompartment* source, JSCompartment* target)
if (IsStaticGlobalLexicalScope(enclosing))
script->fixEnclosingStaticGlobalLexicalScope();
}
if (script->hasBlockScopes()) {
BlockScopeArray* scopes = script->blockScopes();
for (uint32_t i = 0; i < scopes->length; i++) {
uint32_t scopeIndex = scopes->vector[i].index;
if (scopeIndex != BlockScopeNote::NoBlockScopeIndex) {
ScopeObject* scope = &script->getObject(scopeIndex)->as<ScopeObject>();
MOZ_ASSERT(!IsStaticGlobalLexicalScope(scope));
JSObject* enclosing = &scope->enclosingScope();
if (IsStaticGlobalLexicalScope(enclosing))
scope->setEnclosingScope(targetStaticGlobalLexicalScope);
}
}
}
}
for (ZoneCellIter iter(source->zone(), AllocKind::BASE_SHAPE); !iter.done(); iter.next()) {