Bug 758509 (part 2) - Initialize JSScript::noScriptVal in Create(). r=luke.

--HG--
extra : rebase_source : 8c2a827bd4f110f9f1b1ded32a8af970581686d7
This commit is contained in:
Nicholas Nethercote 2012-05-31 00:05:08 -07:00
Родитель 809cbd1532
Коммит cb4a1e7394
6 изменённых файлов: 20 добавлений и 27 удалений

Просмотреть файл

@ -113,11 +113,11 @@ frontend::CompileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
return NULL;
Rooted<JSScript*> script(cx);
script = JSScript::Create(cx);
script = JSScript::Create(cx, noScriptRval);
if (!script)
return NULL;
BytecodeEmitter bce(&parser, &sc, script, lineno, noScriptRval, needScriptGlobal);
BytecodeEmitter bce(&parser, &sc, script, lineno, needScriptGlobal);
if (!bce.init())
return NULL;
@ -280,12 +280,11 @@ frontend::CompileFunctionBody(JSContext *cx, JSFunction *fun,
return false;
Rooted<JSScript*> script(cx);
script = JSScript::Create(cx);
script = JSScript::Create(cx, /* noScriptRval = */ false);
if (!script)
return false;
BytecodeEmitter funbce(&parser, &funsc, script, lineno,
/* noScriptRval = */ false, /* needsScriptGlobal = */ false);
BytecodeEmitter funbce(&parser, &funsc, script, lineno, /* needsScriptGlobal = */ false);
if (!funbce.init())
return false;

Просмотреть файл

@ -66,7 +66,7 @@ static JSBool
SetSrcNoteOffset(JSContext *cx, BytecodeEmitter *bce, unsigned index, unsigned which, ptrdiff_t offset);
BytecodeEmitter::BytecodeEmitter(Parser *parser, SharedContext *sc, Handle<JSScript*> script,
unsigned lineno, bool noScriptRval, bool needScriptGlobal)
unsigned lineno, bool needScriptGlobal)
: sc(sc),
parent(NULL),
script(sc->context, script),
@ -82,7 +82,6 @@ BytecodeEmitter::BytecodeEmitter(Parser *parser, SharedContext *sc, Handle<JSScr
closedArgs(sc->context),
closedVars(sc->context),
typesetCount(0),
noScriptRval(noScriptRval),
needScriptGlobal(needScriptGlobal),
hasSingletons(false),
inForInit(false)
@ -4863,12 +4862,12 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
sc.bindings.transfer(cx, &funbox->bindings);
Rooted<JSScript*> script(cx);
script = JSScript::Create(cx);
script = JSScript::Create(cx, /* noScriptRval = */ false);
if (!script)
return false;
BytecodeEmitter bce2(bce->parser, &sc, script, pn->pn_pos.begin.lineno,
/* noScriptRval = */ false, /* needsScriptGlobal = */ false);
/* needsScriptGlobal = */ false);
if (!bce2.init())
return false;
bce2.parent = bce;
@ -5186,9 +5185,9 @@ EmitStatement(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
bool wantval = false;
JSBool useful = JS_FALSE;
if (bce->sc->inFunction()) {
JS_ASSERT(!bce->noScriptRval);
JS_ASSERT(!bce->script->noScriptRval);
} else {
useful = wantval = !bce->noScriptRval;
useful = wantval = !bce->script->noScriptRval;
}
/* Don't eliminate expressions with side effects. */

Просмотреть файл

@ -123,8 +123,7 @@ struct BytecodeEmitter
uint16_t typesetCount; /* Number of JOF_TYPESET opcodes generated */
/* These two should only be true if sc->inFunction() is false. */
const bool noScriptRval:1; /* The caller is JS_Compile*Script*. */
/* This should only be true if sc->inFunction() is false. */
const bool needScriptGlobal:1; /* API caller does not want result value
from global script. */
@ -133,7 +132,7 @@ struct BytecodeEmitter
bool inForInit:1; /* emitting init expr of for; exclude 'in' */
BytecodeEmitter(Parser *parser, SharedContext *sc, Handle<JSScript*> script, unsigned lineno,
bool noScriptRval, bool needScriptGlobal);
bool needScriptGlobal);
bool init();
/*

Просмотреть файл

@ -582,7 +582,7 @@ js::XDRScript(XDRState<mode> *xdr, JSScript **scriptp, JSScript *parentScript)
/* Note: version is packed into the 32b space with another 16b value. */
JSVersion version_ = JSVersion(version & JS_BITMASK(16));
JS_ASSERT((version_ & VersionFlags::FULL_MASK) == unsigned(version_));
script = JSScript::Create(cx);
script = JSScript::Create(cx, !!(scriptBits & (1 << NoScriptRval)));
if (!script || !script->partiallyInit(cx, length, nsrcnotes, natoms, nobjects,
nregexps, ntrynotes, nconsts, nClosedArgs,
nClosedVars, nTypeSets, version_))
@ -597,8 +597,6 @@ js::XDRScript(XDRState<mode> *xdr, JSScript **scriptp, JSScript *parentScript)
notes = script->notes();
*scriptp = script;
if (scriptBits & (1 << NoScriptRval))
script->noScriptRval = true;
if (scriptBits & (1 << SavedCallerFun))
script->savedCallerFun = true;
if (scriptBits & (1 << StrictModeCode))
@ -1093,13 +1091,16 @@ ScriptDataSize(uint32_t length, uint32_t nsrcnotes, uint32_t natoms,
}
JSScript *
JSScript::Create(JSContext *cx)
JSScript::Create(JSContext *cx, bool noScriptRval)
{
JSScript *script = js_NewGCScript(cx);
if (!script)
return NULL;
PodZero(script);
script->noScriptRval = noScriptRval;
return script;
}
@ -1226,8 +1227,6 @@ JSScript::fullyInitTrivial(JSContext *cx, JSVersion version)
version))
return false;
script->noScriptRval = true;
script->code[0] = JSOP_STOP;
script->notes()[0] = SRC_NULL;
@ -1361,7 +1360,7 @@ JSScript::fullyInitFromEmitter(JSContext *cx, BytecodeEmitter *bce)
JSFunction *fun = NULL;
if (bce->sc->inFunction()) {
JS_ASSERT(!bce->noScriptRval);
JS_ASSERT(!bce->script->noScriptRval);
JS_ASSERT(!bce->needScriptGlobal);
script->isGenerator = bce->sc->funIsGenerator();
@ -1397,8 +1396,6 @@ JSScript::fullyInitFromEmitter(JSContext *cx, BytecodeEmitter *bce)
*/
if (bce->needScriptGlobal)
script->globalObject = GetCurrentGlobal(cx);
script->noScriptRval = bce->noScriptRval;
}
/* Tell the debugger about this compiled script. */
@ -1794,7 +1791,7 @@ js::CloneScript(JSContext *cx, HandleScript src)
/* Now that all fallible allocation is complete, create the GC thing. */
JSScript *dst = JSScript::Create(cx);
JSScript *dst = JSScript::Create(cx, src->noScriptRval);
if (!dst) {
Foreground::free_(data);
return NULL;
@ -1842,7 +1839,6 @@ js::CloneScript(JSContext *cx, HandleScript src)
dst->setNeedsArgsObj(src->needsArgsObj());
}
dst->cloneHasArray(src);
dst->noScriptRval = src->noScriptRval;
dst->savedCallerFun = src->savedCallerFun;
dst->strictModeCode = src->strictModeCode;
dst->compileAndGo = src->compileAndGo;

Просмотреть файл

@ -565,7 +565,7 @@ struct JSScript : public js::gc::Cell
//
public:
static JSScript *Create(JSContext *cx);
static JSScript *Create(JSContext *cx, bool noScriptRval);
// Three ways ways to initialize a JSScript. Callers of partiallyInit()
// and fullyInitTrivial() are responsible for notifying the debugger after

Просмотреть файл

@ -112,7 +112,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
functionProto->flags |= JSFUN_PROTOTYPE;
Rooted<JSScript*> script(cx);
script = JSScript::Create(cx);
script = JSScript::Create(cx, /* noScriptRval = */ true);
if (!script || !script->fullyInitTrivial(cx, JSVERSION_DEFAULT))
return NULL;