mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 761723 - Add a context option to only save source for compileAndGo and function body scripts. r=jornedorff
--HG-- extra : rebase_source : d4637dfe967c0ea398bb4b08fa6f9955b14ff528
This commit is contained in:
parent
310dccbb29
commit
3e366b4012
@ -83,10 +83,13 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, StackFrame *call
|
||||
return NULL;
|
||||
AutoAttachToRuntime attacher(cx->runtime);
|
||||
SourceCompressionToken sct(cx->runtime);
|
||||
ScriptSource *ss = ScriptSource::createFromSource(cx, chars, length, false, &sct);
|
||||
ScriptSource *ss = NULL;
|
||||
if (!cx->hasRunOption(JSOPTION_ONLY_CNG_SOURCE) || compileAndGo) {
|
||||
ss = ScriptSource::createFromSource(cx, chars, length, false, &sct);
|
||||
if (!ss)
|
||||
return NULL;
|
||||
attacher.ss = ss;
|
||||
}
|
||||
|
||||
Parser parser(cx, principals, originPrincipals, chars, length, filename, lineno, version,
|
||||
/* foldConstants = */ true, compileAndGo);
|
||||
|
@ -3066,11 +3066,12 @@ JS_StringToVersion(const char *string);
|
||||
strict mode for all code
|
||||
without requiring
|
||||
"use strict" annotations. */
|
||||
/* JS_BIT(20) is taken in jsfriendapi.h! */
|
||||
|
||||
/* Options which reflect compile-time properties of scripts. */
|
||||
#define JSCOMPILEOPTION_MASK (JSOPTION_ALLOW_XML | JSOPTION_MOAR_XML)
|
||||
|
||||
#define JSRUNOPTION_MASK (JS_BITMASK(20) & ~JSCOMPILEOPTION_MASK)
|
||||
#define JSRUNOPTION_MASK (JS_BITMASK(21) & ~JSCOMPILEOPTION_MASK)
|
||||
#define JSALLOPTION_MASK (JSCOMPILEOPTION_MASK | JSRUNOPTION_MASK)
|
||||
|
||||
extern JS_PUBLIC_API(uint32_t)
|
||||
|
@ -15,6 +15,12 @@
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* Only save the source of scripts that are compileAndGo or are created with
|
||||
* JS_CompileFunction*.
|
||||
*/
|
||||
#define JSOPTION_ONLY_CNG_SOURCE JS_BIT(20)
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
JS_SetGrayGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data);
|
||||
|
||||
|
@ -590,7 +590,7 @@ JSFunction::toString(JSContext *cx, bool bodyOnly, bool lambdaParen)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (isInterpreted()) {
|
||||
if (isInterpreted() && script()->source) {
|
||||
RootedString src(cx, script()->sourceData(cx));
|
||||
if (!src)
|
||||
return NULL;
|
||||
|
@ -357,8 +357,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
OwnFilename,
|
||||
ParentFilename,
|
||||
IsGenerator,
|
||||
HaveSource,
|
||||
OwnSource,
|
||||
ParentSource,
|
||||
ExplicitUseStrict
|
||||
};
|
||||
|
||||
@ -518,9 +518,11 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
? (1 << ParentFilename)
|
||||
: (1 << OwnFilename);
|
||||
}
|
||||
scriptBits |= (enclosingScript && enclosingScript->source == script->source)
|
||||
? (1 << ParentSource)
|
||||
: (1 << OwnSource);
|
||||
if (script->source) {
|
||||
scriptBits |= (1 << HaveSource);
|
||||
if (!enclosingScript || enclosingScript->source != script->source)
|
||||
scriptBits |= (1 << OwnSource);
|
||||
}
|
||||
if (script->isGenerator)
|
||||
scriptBits |= (1 << IsGenerator);
|
||||
|
||||
@ -632,14 +634,19 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
script->filename = enclosingScript->filename;
|
||||
}
|
||||
|
||||
if (scriptBits & (1 << HaveSource)) {
|
||||
if (scriptBits & (1 << OwnSource)) {
|
||||
if (!ScriptSource::performXDR<mode>(xdr, &script->source))
|
||||
return false;
|
||||
} else if (scriptBits & (1 << ParentSource)) {
|
||||
} else {
|
||||
JS_ASSERT(enclosingScript);
|
||||
if (mode == XDR_DECODE)
|
||||
script->source = enclosingScript->source;
|
||||
}
|
||||
} else if (mode == XDR_DECODE) {
|
||||
script->source = NULL;
|
||||
JS_ASSERT_IF(enclosingScript, !enclosingScript->source);
|
||||
}
|
||||
if (!xdr->codeUint32(&script->sourceStart))
|
||||
return false;
|
||||
if (!xdr->codeUint32(&script->sourceEnd))
|
||||
@ -1066,6 +1073,7 @@ SourceCompressorThread::waitOnCompression(SourceCompressionToken *userTok)
|
||||
JSFixedString *
|
||||
JSScript::sourceData(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(source);
|
||||
return source->substring(cx, sourceStart, sourceEnd);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace js {
|
||||
* and saved versions. If deserialization fails, the data should be
|
||||
* invalidated if possible.
|
||||
*/
|
||||
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 122);
|
||||
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 123);
|
||||
|
||||
class XDRBuffer {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user