From 2b99e634b0dd9a29b4a1a017574d0b20321ad5b7 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 19 Dec 2013 09:20:35 -0800 Subject: [PATCH] Bug 920322 - Enable XDR of CompileAndGo scripts. r=luke --- js/src/jsfun.cpp | 2 -- js/src/jsscript.cpp | 19 +++++++++++++++---- js/src/vm/Xdr.cpp | 16 ++-------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 2eb8d021ae7..9e5843a63a0 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -427,8 +427,6 @@ js::XDRInterpretedFunction(XDRState *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); } diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 30c7feebe25..ebdfd541c8f 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -413,7 +413,8 @@ js::XDRScript(XDRState *xdr, HandleObject enclosingScope, HandleScript enc IsStarGenerator, OwnSource, ExplicitUseStrict, - SelfHosted + SelfHosted, + IsCompileAndGo }; uint32_t length, lineno, nslots; @@ -507,8 +508,8 @@ js::XDRScript(XDRState *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 *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 *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; } diff --git a/js/src/vm/Xdr.cpp b/js/src/vm/Xdr.cpp index 62dd6b8c68d..de320400665 100644 --- a/js/src/vm/Xdr.cpp +++ b/js/src/vm/Xdr.cpp @@ -102,27 +102,15 @@ template bool XDRState::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; }