Bug 920322 - Enable XDR of CompileAndGo scripts. r=luke

This commit is contained in:
Nicolas B. Pierron 2013-12-19 09:20:35 -08:00
parent a7d96f6225
commit 2b99e634b0
3 changed files with 17 additions and 20 deletions

View File

@ -427,8 +427,6 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
if (!JSFunction::setTypeForScriptedFunction(cx, fun))
return false;
JS_ASSERT(fun->nargs() == fun->nonLazyScript()->bindings.numArgs());
RootedScript script(cx, fun->nonLazyScript());
CallNewScriptHook(cx, script, fun);
objp.set(fun);
}

View File

@ -413,7 +413,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
IsStarGenerator,
OwnSource,
ExplicitUseStrict,
SelfHosted
SelfHosted,
IsCompileAndGo
};
uint32_t length, lineno, nslots;
@ -507,8 +508,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
scriptBits |= (1 << IsLegacyGenerator);
if (script->isStarGenerator())
scriptBits |= (1 << IsStarGenerator);
JS_ASSERT(!script->compileAndGo());
if (script->compileAndGo())
scriptBits |= (1 << IsCompileAndGo);
JS_ASSERT(!script->hasSingletons());
}
@ -616,6 +617,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
script->setNeedsArgsObj(true);
if (scriptBits & (1 << IsGeneratorExp))
script->isGeneratorExp_ = true;
if (scriptBits & (1 << IsCompileAndGo))
script->compileAndGo_ = true;
if (scriptBits & (1 << IsLegacyGenerator)) {
JS_ASSERT(!(scriptBits & (1 << IsStarGenerator)));
@ -814,9 +817,17 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
}
}
if (mode == XDR_DECODE)
if (mode == XDR_DECODE) {
scriptp.set(script);
/* see BytecodeEmitter::tellDebuggerAboutCompiledScript */
CallNewScriptHook(cx, script, fun);
if (!fun) {
RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : NULL);
Debugger::onNewScript(cx, script, global);
}
}
return true;
}

View File

@ -102,27 +102,15 @@ template<XDRMode mode>
bool
XDRState<mode>::codeScript(MutableHandleScript scriptp)
{
RootedScript script(cx());
if (mode == XDR_DECODE) {
script = nullptr;
if (mode == XDR_DECODE)
scriptp.set(nullptr);
} else {
script = scriptp.get();
}
if (!VersionCheck(this))
return false;
if (!XDRScript(this, NullPtr(), NullPtr(), NullPtr(), &script))
if (!XDRScript(this, NullPtr(), NullPtr(), NullPtr(), scriptp))
return false;
if (mode == XDR_DECODE) {
JS_ASSERT(!script->compileAndGo());
CallNewScriptHook(cx(), script, NullPtr());
Debugger::onNewScript(cx(), script, nullptr);
scriptp.set(script);
}
return true;
}