Bug 836515 - Allow source compression to run while executing the script. r=jorendorff

This commit is contained in:
Benjamin Peterson
2013-02-07 09:29:22 -05:00
parent 4b909c9902
commit 6865354b1b
4 changed files with 18 additions and 11 deletions

View File

@@ -51,7 +51,8 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, AbstractFramePtr
const CompileOptions &options,
StableCharPtr chars, size_t length,
JSString *source_ /* = NULL */,
unsigned staticLevel /* = 0 */)
unsigned staticLevel /* = 0 */,
SourceCompressionToken *extraSct /* = NULL */)
{
RootedString source(cx, source_);
@@ -82,10 +83,11 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, AbstractFramePtr
if (!ss)
return UnrootedScript(NULL);
ScriptSourceHolder ssh(ss);
SourceCompressionToken sct(cx);
SourceCompressionToken mysct(cx);
SourceCompressionToken *sct = (extraSct) ? extraSct : &mysct;
switch (options.sourcePolicy) {
case CompileOptions::SAVE_SOURCE:
if (!ss->setSourceCopy(cx, chars, length, false, &sct))
if (!ss->setSourceCopy(cx, chars, length, false, sct))
return UnrootedScript(NULL);
break;
case CompileOptions::LAZY_SOURCE:
@@ -98,7 +100,7 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, AbstractFramePtr
Parser parser(cx, options, chars, length, /* foldConstants = */ true);
if (!parser.init())
return UnrootedScript(NULL);
parser.sct = &sct;
parser.sct = sct;
GlobalSharedContext globalsc(cx, scopeChain, StrictModeFromContext(cx));
@@ -215,7 +217,7 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, AbstractFramePtr
bce.tellDebuggerAboutCompiledScript(cx);
if (!sct.complete())
if (sct == &mysct && !sct->complete())
return UnrootedScript(NULL);
return script;