Bug 836515 - Allow source compression to run while executing the script. r=jorendorff
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user