mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 788957 (part 3) - Change SharedContext::inFunction() to SharedContext::isFunction. r=benjamin.
--HG-- extra : rebase_source : ce3e88a0d9da9d6946783e86188ae80cdae7dabc
This commit is contained in:
parent
e58297be27
commit
170e2935ae
@ -697,7 +697,7 @@ EnclosingStaticScope(BytecodeEmitter *bce)
|
||||
if (bce->blockChain)
|
||||
return bce->blockChain;
|
||||
|
||||
if (!bce->sc->inFunction()) {
|
||||
if (!bce->sc->isFunction) {
|
||||
JS_ASSERT(!bce->parent);
|
||||
return NULL;
|
||||
}
|
||||
@ -1084,7 +1084,7 @@ static int
|
||||
AdjustBlockSlot(JSContext *cx, BytecodeEmitter *bce, int slot)
|
||||
{
|
||||
JS_ASSERT((unsigned) slot < bce->maxStackDepth);
|
||||
if (bce->sc->inFunction()) {
|
||||
if (bce->sc->isFunction) {
|
||||
slot += bce->script->bindings.numVars();
|
||||
if ((unsigned) slot >= SLOTNO_LIMIT) {
|
||||
bce->reportError(NULL, JSMSG_TOO_MANY_LOCALS);
|
||||
@ -1178,7 +1178,7 @@ TryConvertToGname(BytecodeEmitter *bce, ParseNode *pn, JSOp *op)
|
||||
}
|
||||
if (bce->script->compileAndGo &&
|
||||
bce->hasGlobalScope &&
|
||||
!(bce->sc->inFunction() && bce->sc->funbox()->mightAliasLocals()) &&
|
||||
!(bce->sc->isFunction && bce->sc->funbox()->mightAliasLocals()) &&
|
||||
!pn->isDeoptimized() &&
|
||||
!bce->sc->inStrictMode())
|
||||
{
|
||||
@ -1439,7 +1439,7 @@ BindNameToSlot(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
BytecodeEmitter *bceSkipped = bce;
|
||||
for (unsigned i = 0; i < skip; i++)
|
||||
bceSkipped = bceSkipped->parent;
|
||||
if (!bceSkipped->sc->inFunction())
|
||||
if (!bceSkipped->sc->isFunction)
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1651,7 +1651,7 @@ CheckSideEffects(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn, bool *answe
|
||||
bool
|
||||
BytecodeEmitter::checkSingletonContext()
|
||||
{
|
||||
if (!script->compileAndGo || sc->inFunction())
|
||||
if (!script->compileAndGo || sc->isFunction)
|
||||
return false;
|
||||
for (StmtInfoBCE *stmt = topStmt; stmt; stmt = stmt->down) {
|
||||
if (stmt->isLoop())
|
||||
@ -1667,7 +1667,7 @@ BytecodeEmitter::needsImplicitThis()
|
||||
if (!script->compileAndGo)
|
||||
return true;
|
||||
|
||||
if (sc->inFunction()) {
|
||||
if (sc->isFunction) {
|
||||
if (sc->funbox()->inWith)
|
||||
return true;
|
||||
} else {
|
||||
@ -2689,7 +2689,7 @@ MaybeEmitVarDecl(JSContext *cx, BytecodeEmitter *bce, JSOp prologOp, ParseNode *
|
||||
}
|
||||
|
||||
if (JOF_OPTYPE(pn->getOp()) == JOF_ATOM &&
|
||||
(!bce->sc->inFunction() || bce->sc->funbox()->fun()->isHeavyweight()))
|
||||
(!bce->sc->isFunction || bce->sc->funbox()->fun()->isHeavyweight()))
|
||||
{
|
||||
bce->switchToProlog();
|
||||
if (!UpdateSourceCoordNotes(cx, bce, pn->pn_pos.begin))
|
||||
@ -4448,7 +4448,7 @@ EmitLexicalScope(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
(stmtInfo.down
|
||||
? stmtInfo.down->type == STMT_BLOCK &&
|
||||
(!stmtInfo.down->down || stmtInfo.down->down->type != STMT_FOR_IN_LOOP)
|
||||
: !bce->sc->inFunction()))
|
||||
: !bce->sc->isFunction))
|
||||
{
|
||||
/* There must be no source note already output for the next op. */
|
||||
JS_ASSERT(bce->noteCount() == 0 ||
|
||||
@ -4840,7 +4840,7 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
* comments in EmitStatementList.
|
||||
*/
|
||||
JS_ASSERT(pn->functionIsHoisted());
|
||||
JS_ASSERT(bce->sc->inFunction());
|
||||
JS_ASSERT(bce->sc->isFunction);
|
||||
return EmitFunctionDefNop(cx, bce, pn->pn_index);
|
||||
}
|
||||
|
||||
@ -4848,7 +4848,7 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
FunctionBox *funbox = pn->pn_funbox;
|
||||
SharedContext sc(cx, /* scopeChain = */ NULL, funbox, funbox->strictModeState);
|
||||
sc.anyCxFlags = funbox->anyCxFlags; // copy the non-func-specific flags
|
||||
if (bce->sc->inFunction() && bce->sc->funbox()->mightAliasLocals())
|
||||
if (bce->sc->isFunction && bce->sc->funbox()->mightAliasLocals())
|
||||
funbox->setMightAliasLocals(); // inherit mightAliasLocals from parent
|
||||
JS_ASSERT_IF(bce->sc->inStrictMode(), sc.inStrictMode());
|
||||
|
||||
@ -4900,7 +4900,7 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
* invocation of the emitter and calls to EmitTree for function
|
||||
* definitions can be scheduled before generating the rest of code.
|
||||
*/
|
||||
if (!bce->sc->inFunction()) {
|
||||
if (!bce->sc->isFunction) {
|
||||
JS_ASSERT(pn->pn_cookie.isFree());
|
||||
JS_ASSERT(pn->getOp() == JSOP_NOP);
|
||||
JS_ASSERT(!bce->topStmt);
|
||||
@ -5193,7 +5193,7 @@ EmitStatement(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
*/
|
||||
bool wantval = false;
|
||||
bool useful = false;
|
||||
if (bce->sc->inFunction()) {
|
||||
if (bce->sc->isFunction) {
|
||||
JS_ASSERT(!bce->script->noScriptRval);
|
||||
} else {
|
||||
useful = wantval = !bce->script->noScriptRval;
|
||||
@ -6203,7 +6203,7 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
|
||||
#if JS_HAS_GENERATORS
|
||||
case PNK_YIELD:
|
||||
JS_ASSERT(bce->sc->inFunction());
|
||||
JS_ASSERT(bce->sc->isFunction);
|
||||
if (pn->pn_kid) {
|
||||
if (!EmitTree(cx, bce, pn->pn_kid))
|
||||
return false;
|
||||
|
@ -167,7 +167,7 @@ ParseContext::define(JSContext *cx, PropertyName *name, ParseNode *pn, Definitio
|
||||
Definition *dn = (Definition *)pn;
|
||||
switch (kind) {
|
||||
case Definition::ARG:
|
||||
JS_ASSERT(sc->inFunction());
|
||||
JS_ASSERT(sc->isFunction);
|
||||
dn->setOp(JSOP_GETARG);
|
||||
dn->pn_dflags |= PND_BOUND;
|
||||
if (!dn->pn_cookie.set(cx, staticLevel, args_.length()))
|
||||
@ -182,7 +182,7 @@ ParseContext::define(JSContext *cx, PropertyName *name, ParseNode *pn, Definitio
|
||||
|
||||
case Definition::CONST:
|
||||
case Definition::VAR:
|
||||
if (sc->inFunction()) {
|
||||
if (sc->isFunction) {
|
||||
dn->setOp(JSOP_GETLOCAL);
|
||||
dn->pn_dflags |= PND_BOUND;
|
||||
if (!dn->pn_cookie.set(cx, staticLevel, vars_.length()))
|
||||
@ -229,7 +229,7 @@ ParseContext::updateDecl(JSAtom *atom, ParseNode *pn)
|
||||
Definition *newDecl = (Definition *)pn;
|
||||
decls_.updateFirst(atom, newDecl);
|
||||
|
||||
if (!sc->inFunction()) {
|
||||
if (!sc->isFunction) {
|
||||
JS_ASSERT(newDecl->isFreeVar());
|
||||
return;
|
||||
}
|
||||
@ -298,7 +298,7 @@ AppendPackedBindings(const ParseContext *pc, const DeclVector &vec, Binding *dst
|
||||
bool
|
||||
ParseContext::generateFunctionBindings(JSContext *cx, InternalHandle<Bindings*> bindings) const
|
||||
{
|
||||
JS_ASSERT(sc->inFunction());
|
||||
JS_ASSERT(sc->isFunction);
|
||||
|
||||
unsigned count = args_.length() + vars_.length();
|
||||
Binding *packedBindings = cx->tempLifoAlloc().newArrayUninitialized<Binding>(count);
|
||||
@ -425,7 +425,7 @@ FunctionBox::FunctionBox(ObjectBox *traceListHead, JSFunction *fun, ParseContext
|
||||
// outerpc->parsingWith is true.
|
||||
inWith = true;
|
||||
|
||||
} else if (!outerpc->sc->inFunction()) {
|
||||
} else if (!outerpc->sc->isFunction) {
|
||||
// This covers the case where a function is nested within an eval()
|
||||
// within a |with| statement.
|
||||
//
|
||||
@ -681,7 +681,7 @@ ReportBadReturn(JSContext *cx, Parser *parser, ParseNode *pn, Parser::Reporter r
|
||||
static bool
|
||||
CheckFinalReturn(JSContext *cx, Parser *parser, ParseNode *pn)
|
||||
{
|
||||
JS_ASSERT(parser->pc->sc->inFunction());
|
||||
JS_ASSERT(parser->pc->sc->isFunction);
|
||||
return HasFinalReturn(pn) == ENDS_IN_RETURN ||
|
||||
ReportBadReturn(cx, parser, pn, &Parser::reportStrictWarning,
|
||||
JSMSG_NO_RETURN_VALUE, JSMSG_ANON_NO_RETURN_VALUE);
|
||||
@ -738,7 +738,7 @@ CheckStrictBinding(JSContext *cx, Parser *parser, HandlePropertyName name, Parse
|
||||
ParseNode *
|
||||
Parser::functionBody(FunctionBodyType type)
|
||||
{
|
||||
JS_ASSERT(pc->sc->inFunction());
|
||||
JS_ASSERT(pc->sc->isFunction);
|
||||
|
||||
StmtInfoPC stmtInfo(context);
|
||||
PushStatementPC(pc, &stmtInfo, STMT_BLOCK);
|
||||
@ -1088,7 +1088,7 @@ Parser::newFunction(ParseContext *pc, JSAtom *atom, FunctionSyntaxKind kind)
|
||||
pc = pc->parent;
|
||||
|
||||
RootedObject parent(context);
|
||||
parent = pc->sc->inFunction() ? NULL : pc->sc->scopeChain();
|
||||
parent = pc->sc->isFunction ? NULL : pc->sc->scopeChain();
|
||||
|
||||
RootedFunction fun(context);
|
||||
uint32_t flags = JSFUN_INTERPRETED | (kind == Expression ? JSFUN_LAMBDA : 0);
|
||||
@ -1342,7 +1342,7 @@ static bool
|
||||
BindDestructuringArg(JSContext *cx, BindData *data, HandlePropertyName name, Parser *parser)
|
||||
{
|
||||
ParseContext *pc = parser->pc;
|
||||
JS_ASSERT(pc->sc->inFunction());
|
||||
JS_ASSERT(pc->sc->isFunction);
|
||||
|
||||
if (pc->decls().lookupFirst(name)) {
|
||||
parser->reportError(NULL, JSMSG_BAD_DUP_ARGS);
|
||||
@ -1594,12 +1594,12 @@ Parser::functionDef(HandlePropertyName funName, FunctionType type, FunctionSynta
|
||||
*/
|
||||
if (bodyLevel) {
|
||||
JS_ASSERT(pn->functionIsHoisted());
|
||||
JS_ASSERT_IF(pc->sc->inFunction(), !pn->pn_cookie.isFree());
|
||||
JS_ASSERT_IF(!pc->sc->inFunction(), pn->pn_cookie.isFree());
|
||||
JS_ASSERT_IF(pc->sc->isFunction, !pn->pn_cookie.isFree());
|
||||
JS_ASSERT_IF(!pc->sc->isFunction, pn->pn_cookie.isFree());
|
||||
} else {
|
||||
JS_ASSERT(pc->sc->strictModeState != StrictMode::STRICT);
|
||||
JS_ASSERT(pn->pn_cookie.isFree());
|
||||
if (pc->sc->inFunction()) {
|
||||
if (pc->sc->isFunction) {
|
||||
FunctionBox *funbox = pc->sc->funbox();
|
||||
funbox->setMightAliasLocals();
|
||||
funbox->setHasExtensibleScope();
|
||||
@ -1821,7 +1821,7 @@ Parser::setStrictMode(bool strictMode)
|
||||
if (pc->sc->strictModeState != StrictMode::UNKNOWN) {
|
||||
// Strict mode was inherited.
|
||||
JS_ASSERT(pc->sc->strictModeState == StrictMode::STRICT);
|
||||
if (pc->sc->inFunction()) {
|
||||
if (pc->sc->isFunction) {
|
||||
JS_ASSERT(pc->sc->funbox()->strictModeState == pc->sc->strictModeState);
|
||||
JS_ASSERT(pc->parent->sc->strictModeState == StrictMode::STRICT);
|
||||
} else {
|
||||
@ -1848,8 +1848,8 @@ Parser::setStrictMode(bool strictMode)
|
||||
pc->queuedStrictModeError->throwError();
|
||||
}
|
||||
}
|
||||
JS_ASSERT_IF(!pc->sc->inFunction(), !pc->functionList);
|
||||
if (pc->sc->strictModeState != StrictMode::UNKNOWN && pc->sc->inFunction()) {
|
||||
JS_ASSERT_IF(!pc->sc->isFunction, !pc->functionList);
|
||||
if (pc->sc->strictModeState != StrictMode::UNKNOWN && pc->sc->isFunction) {
|
||||
// We changed the strict mode state. Retroactively recursively set
|
||||
// strict mode status on all the function children we've seen so far
|
||||
// children (That is, functions in default expressions).
|
||||
@ -1997,7 +1997,7 @@ Parser::statements(bool *hasFunctionStmt)
|
||||
* General deoptimization was done in functionDef, here we just
|
||||
* need to tell TOK_LC in Parser::statement to add braces.
|
||||
*/
|
||||
JS_ASSERT_IF(pc->sc->inFunction(), pc->sc->funbox()->hasExtensibleScope());
|
||||
JS_ASSERT_IF(pc->sc->isFunction, pc->sc->funbox()->hasExtensibleScope());
|
||||
if (hasFunctionStmt)
|
||||
*hasFunctionStmt = true;
|
||||
}
|
||||
@ -2197,7 +2197,7 @@ BindVarOrConst(JSContext *cx, BindData *data, HandlePropertyName name, Parser *p
|
||||
|
||||
if (stmt && stmt->type == STMT_WITH) {
|
||||
pn->pn_dflags |= PND_DEOPTIMIZED;
|
||||
if (pc->sc->inFunction())
|
||||
if (pc->sc->isFunction)
|
||||
pc->sc->funbox()->setMightAliasLocals();
|
||||
return true;
|
||||
}
|
||||
@ -2568,7 +2568,7 @@ ParseNode *
|
||||
Parser::returnOrYield(bool useAssignExpr)
|
||||
{
|
||||
TokenKind tt = tokenStream.currentToken().type;
|
||||
if (!pc->sc->inFunction()) {
|
||||
if (!pc->sc->isFunction) {
|
||||
reportError(NULL, JSMSG_BAD_RETURN_OR_YIELD,
|
||||
(tt == TOK_RETURN) ? js_return_str : js_yield_str);
|
||||
return NULL;
|
||||
@ -4858,7 +4858,7 @@ GenexpGuard::maybeNoteGenerator(ParseNode *pn)
|
||||
{
|
||||
ParseContext *pc = parser->pc;
|
||||
if (pc->yieldCount > 0) {
|
||||
if (!pc->sc->inFunction()) {
|
||||
if (!pc->sc->isFunction) {
|
||||
parser->reportError(NULL, JSMSG_BAD_RETURN_OR_YIELD, js_yield_str);
|
||||
return false;
|
||||
}
|
||||
@ -5382,7 +5382,7 @@ Parser::generatorExpr(ParseNode *kid)
|
||||
* kid and could be removed from pc->sc.
|
||||
*/
|
||||
gensc.anyCxFlags = outerpc->sc->anyCxFlags;
|
||||
if (outerpc->sc->inFunction())
|
||||
if (outerpc->sc->isFunction)
|
||||
funbox->funCxFlags = outerpc->sc->funbox()->funCxFlags;
|
||||
|
||||
funbox->setIsGenerator();
|
||||
@ -5708,7 +5708,7 @@ Parser::memberExpr(bool allowCallSyntax)
|
||||
* In non-strict mode code, direct calls to eval can add
|
||||
* variables to the call object.
|
||||
*/
|
||||
if (pc->sc->inFunction() && pc->sc->strictModeState != StrictMode::STRICT)
|
||||
if (pc->sc->isFunction && pc->sc->strictModeState != StrictMode::STRICT)
|
||||
pc->sc->funbox()->setHasExtensibleScope();
|
||||
}
|
||||
} else if (lhs->isOp(JSOP_GETPROP)) {
|
||||
|
@ -84,12 +84,12 @@ struct ParseContext /* tree context for semantic checks */
|
||||
}
|
||||
|
||||
uint32_t numArgs() const {
|
||||
JS_ASSERT(sc->inFunction());
|
||||
JS_ASSERT(sc->isFunction);
|
||||
return args_.length();
|
||||
}
|
||||
|
||||
uint32_t numVars() const {
|
||||
JS_ASSERT(sc->inFunction());
|
||||
JS_ASSERT(sc->isFunction);
|
||||
return vars_.length();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ inline
|
||||
SharedContext::SharedContext(JSContext *cx, JSObject *scopeChain, FunctionBox *funbox,
|
||||
StrictMode sms)
|
||||
: context(cx),
|
||||
isFunction(!!funbox),
|
||||
funbox_(funbox),
|
||||
scopeChain_(cx, scopeChain),
|
||||
anyCxFlags(),
|
||||
@ -30,7 +31,7 @@ inline bool
|
||||
SharedContext::inStrictMode()
|
||||
{
|
||||
JS_ASSERT(strictModeState != StrictMode::UNKNOWN);
|
||||
JS_ASSERT_IF(inFunction(), funbox()->strictModeState == strictModeState);
|
||||
JS_ASSERT_IF(isFunction, funbox()->strictModeState == strictModeState);
|
||||
return strictModeState == StrictMode::STRICT;
|
||||
}
|
||||
|
||||
|
@ -135,12 +135,14 @@ class FunctionContextFlags {
|
||||
struct SharedContext {
|
||||
JSContext *const context;
|
||||
|
||||
const bool isFunction; /* true for function code, false for
|
||||
global code */
|
||||
private:
|
||||
FunctionBox *const funbox_; /* null or box for function we're compiling
|
||||
(if inFunction() is true) */
|
||||
(if isFunction is true) */
|
||||
|
||||
const RootedObject scopeChain_; /* scope chain object for the script
|
||||
(if inFunction() is false) */
|
||||
(if isFunction is false) */
|
||||
|
||||
public:
|
||||
AnyContextFlags anyCxFlags;
|
||||
@ -176,10 +178,8 @@ struct SharedContext {
|
||||
void setExplicitUseStrict() { anyCxFlags.hasExplicitUseStrict = true; }
|
||||
void setBindingsAccessedDynamically() { anyCxFlags.bindingsAccessedDynamically = true; }
|
||||
|
||||
bool inFunction() const { return !!funbox_; }
|
||||
|
||||
FunctionBox *funbox() const { JS_ASSERT(inFunction()); return funbox_; }
|
||||
JSObject *scopeChain() const { JS_ASSERT(!inFunction()); return scopeChain_; }
|
||||
FunctionBox *funbox() const { JS_ASSERT(isFunction); return funbox_; }
|
||||
JSObject *scopeChain() const { JS_ASSERT(!isFunction); return scopeChain_; }
|
||||
|
||||
// JSOPTION_STRICT warnings or strict mode errors.
|
||||
inline bool needStrictChecks();
|
||||
|
@ -1638,7 +1638,7 @@ JSScript::fullyInitFromEmitter(JSContext *cx, Handle<JSScript*> script, Bytecode
|
||||
script->mainOffset = prologLength;
|
||||
PodCopy<jsbytecode>(script->code, bce->prologBase(), prologLength);
|
||||
PodCopy<jsbytecode>(script->main(), bce->base(), mainLength);
|
||||
uint32_t nfixed = bce->sc->inFunction() ? script->bindings.numVars() : 0;
|
||||
uint32_t nfixed = bce->sc->isFunction ? script->bindings.numVars() : 0;
|
||||
JS_ASSERT(nfixed < SLOTNO_LIMIT);
|
||||
script->nfixed = uint16_t(nfixed);
|
||||
InitAtomMap(cx, bce->atomIndices.getMap(), script->atoms);
|
||||
@ -1670,14 +1670,14 @@ JSScript::fullyInitFromEmitter(JSContext *cx, Handle<JSScript*> script, Bytecode
|
||||
script->explicitUseStrict = bce->sc->hasExplicitUseStrict();
|
||||
script->bindingsAccessedDynamically = bce->sc->bindingsAccessedDynamically();
|
||||
script->funHasExtensibleScope =
|
||||
bce->sc->inFunction() ? bce->sc->funbox()->hasExtensibleScope() : false;
|
||||
bce->sc->isFunction ? bce->sc->funbox()->hasExtensibleScope() : false;
|
||||
script->hasSingletons = bce->hasSingletons;
|
||||
#ifdef JS_METHODJIT
|
||||
if (cx->compartment->debugMode())
|
||||
script->debugMode = true;
|
||||
#endif
|
||||
|
||||
if (bce->sc->inFunction()) {
|
||||
if (bce->sc->isFunction) {
|
||||
FunctionBox *funbox = bce->sc->funbox();
|
||||
if (funbox->argumentsHasLocalBinding()) {
|
||||
// This must precede the script->bindings.transfer() call below
|
||||
@ -1690,7 +1690,7 @@ JSScript::fullyInitFromEmitter(JSContext *cx, Handle<JSScript*> script, Bytecode
|
||||
}
|
||||
|
||||
RootedFunction fun(cx, NULL);
|
||||
if (bce->sc->inFunction()) {
|
||||
if (bce->sc->isFunction) {
|
||||
JS_ASSERT(!bce->script->noScriptRval);
|
||||
FunctionBox *funbox = bce->sc->funbox();
|
||||
script->isGenerator = funbox->isGenerator();
|
||||
|
Loading…
Reference in New Issue
Block a user