Bug 776314 - Add a script flag indicating if the script is a generator expression. r=luke

This commit is contained in:
Benjamin Peterson 2012-07-24 11:19:08 -07:00
parent 045def7da0
commit da8f1d7883
3 changed files with 9 additions and 1 deletions

View File

@ -357,6 +357,7 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
OwnFilename,
ParentFilename,
IsGenerator,
IsGeneratorExp,
HaveSource,
OwnSource,
ExplicitUseStrict
@ -525,6 +526,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
}
if (script->isGenerator)
scriptBits |= (1 << IsGenerator);
if (script->isGeneratorExp)
scriptBits |= (1 << IsGeneratorExp);
JS_ASSERT(!script->compileAndGo);
JS_ASSERT(!script->hasSingletons);
@ -606,6 +609,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
script->setNeedsArgsObj(true);
if (scriptBits & (1 << IsGenerator))
script->isGenerator = true;
if (scriptBits & (1 << IsGeneratorExp))
script->isGeneratorExp = true;
}
JS_STATIC_ASSERT(sizeof(jsbytecode) == 1);
@ -1814,6 +1819,7 @@ JSScript::fullyInitFromEmitter(JSContext *cx, Handle<JSScript*> script, Bytecode
if (bce->sc->inFunction()) {
JS_ASSERT(!bce->script->noScriptRval);
script->isGenerator = bce->sc->funIsGenerator();
script->isGeneratorExp = bce->sc->funbox() && bce->sc->funbox()->inGenexpLambda;
script->setFunction(bce->sc->fun());
}
@ -2289,6 +2295,7 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
dst->funHasExtensibleScope = src->funHasExtensibleScope;
dst->hasSingletons = src->hasSingletons;
dst->isGenerator = src->isGenerator;
dst->isGeneratorExp = src->isGeneratorExp;
/*
* initScriptCounts updates scriptCountsMap if necessary. The other script

View File

@ -540,6 +540,7 @@ struct JSScript : public js::gc::Cell
#endif
bool callDestroyHook:1;/* need to call destroy hook */
bool isGenerator:1; /* is a generator */
bool isGeneratorExp:1; /* is a generator expression */
bool hasScriptCounts:1;/* script has an entry in
JSCompartment::scriptCountsMap */
bool hasSourceMap:1; /* script has an entry in

View File

@ -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 - 123);
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 124);
class XDRBuffer {
public: