mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 515233: Widen JSTreeContext::flags to 32 bits. r=igor
All the bits in this uint16 field are currently in use. Adding bits for projects like strict mode entails relocating existing flags, which is additional work. Furthermore, it seems that this has already inspired people to put flags in places they don't belong: TSF_DESTRUCTURING is a JSTokenStream flag, but is only used by the parser. This patch widens the field to 32 bits, and adjusts JSFunctionBox and a few other places to match. We should really replace these all with bitfields.
This commit is contained in:
parent
2b9bcea9dc
commit
744e7161ea
@ -4362,7 +4362,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
new (cg2space) JSCodeGenerator(cg->compiler,
|
||||
cg->codePool, cg->notePool,
|
||||
pn->pn_pos.begin.lineno);
|
||||
cg2->flags = (uint16) (pn->pn_funbox->tcflags | TCF_IN_FUNCTION);
|
||||
cg2->flags = pn->pn_funbox->tcflags | TCF_IN_FUNCTION;
|
||||
#if JS_HAS_SHARP_VARS
|
||||
if (cg2->flags & TCF_HAS_SHARPS) {
|
||||
cg2->sharpSlotBase = fun->sharpSlotBase(cx);
|
||||
|
@ -162,7 +162,7 @@ struct JSStmtInfo {
|
||||
#endif
|
||||
|
||||
struct JSTreeContext { /* tree context for semantic checks */
|
||||
uint16 flags; /* statement state flags, see below */
|
||||
uint32 flags; /* statement state flags, see below */
|
||||
uint16 ngvars; /* max. no. of global variables/regexps */
|
||||
uint32 bodyid; /* block number of program/function body */
|
||||
uint32 blockidGen; /* preincremented block number generator */
|
||||
@ -239,11 +239,6 @@ struct JSTreeContext { /* tree context for semantic checks */
|
||||
*/
|
||||
#define TCF_RETURN_FLAGS (TCF_RETURN_EXPR | TCF_RETURN_VOID)
|
||||
|
||||
/*
|
||||
* TreeContext flags must fit in 16 bits, and all bits are in use now. Widening
|
||||
* requires changing JSFunctionBox.tcflags too and repacking. Alternative fix
|
||||
* gets rid of flags, probably starting with TCF_HAS_FUNCTION_STMT.
|
||||
*/
|
||||
#define TCF_COMPILING 0x01 /* JSTreeContext is JSCodeGenerator */
|
||||
#define TCF_IN_FUNCTION 0x02 /* parsing inside function body */
|
||||
#define TCF_RETURN_EXPR 0x04 /* function has 'return expr;' */
|
||||
|
@ -343,10 +343,10 @@ UnlinkFunctionBox(JSParseNode *pn, JSTreeContext *tc)
|
||||
funboxp = &(*funboxp)->siblings;
|
||||
}
|
||||
|
||||
uint16 oldflags = tc->flags;
|
||||
uint32 oldflags = tc->flags;
|
||||
JSFunctionBox *oldlist = tc->functionList;
|
||||
|
||||
tc->flags = (uint16) funbox->tcflags;
|
||||
tc->flags = funbox->tcflags;
|
||||
tc->functionList = funbox->kids;
|
||||
UnlinkFunctionBoxes(pn->pn_body, tc);
|
||||
funbox->kids = tc->functionList;
|
||||
@ -825,7 +825,7 @@ JSCompiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *cal
|
||||
/* Null script early in case of error, to reduce our code footprint. */
|
||||
script = NULL;
|
||||
|
||||
cg.flags |= uint16(tcflags);
|
||||
cg.flags |= tcflags;
|
||||
cg.scopeChain = scopeChain;
|
||||
if (!SetStaticLevel(&cg, staticLevel))
|
||||
goto out;
|
||||
@ -1681,7 +1681,7 @@ MatchOrInsertSemicolon(JSContext *cx, JSTokenStream *ts)
|
||||
}
|
||||
|
||||
bool
|
||||
JSCompiler::analyzeFunctions(JSFunctionBox *funbox, uint16& tcflags)
|
||||
JSCompiler::analyzeFunctions(JSFunctionBox *funbox, uint32& tcflags)
|
||||
{
|
||||
if (!markFunArgs(funbox, tcflags))
|
||||
return false;
|
||||
@ -1900,7 +1900,7 @@ OneBlockId(JSParseNode *fn, uint32 id)
|
||||
}
|
||||
|
||||
void
|
||||
JSCompiler::setFunctionKinds(JSFunctionBox *funbox, uint16& tcflags)
|
||||
JSCompiler::setFunctionKinds(JSFunctionBox *funbox, uint32& tcflags)
|
||||
{
|
||||
#ifdef JS_FUNCTION_METERING
|
||||
# define FUN_METER(x) JS_RUNTIME_METER(context->runtime, functionMeter.x)
|
||||
@ -8675,10 +8675,10 @@ js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc, bool inCond)
|
||||
switch (pn->pn_arity) {
|
||||
case PN_FUNC:
|
||||
{
|
||||
uint16 oldflags = tc->flags;
|
||||
uint32 oldflags = tc->flags;
|
||||
JSFunctionBox *oldlist = tc->functionList;
|
||||
|
||||
tc->flags = (uint16) pn->pn_funbox->tcflags;
|
||||
tc->flags = pn->pn_funbox->tcflags;
|
||||
tc->functionList = pn->pn_funbox->kids;
|
||||
if (!js_FoldConstants(cx, pn->pn_body, tc))
|
||||
return JS_FALSE;
|
||||
|
@ -764,8 +764,8 @@ struct JSFunctionBox : public JSObjectBox
|
||||
JSFunctionBox *parent;
|
||||
uint32 queued:1,
|
||||
inLoop:1, /* in a loop in parent function */
|
||||
level:JSFB_LEVEL_BITS,
|
||||
tcflags:16;
|
||||
level:JSFB_LEVEL_BITS;
|
||||
uint32 tcflags;
|
||||
};
|
||||
|
||||
struct JSFunctionBoxQueue {
|
||||
@ -869,9 +869,9 @@ struct JSCompiler {
|
||||
* starting at funbox, recursively walking its kids, then following its
|
||||
* siblings, their kids, etc.
|
||||
*/
|
||||
bool analyzeFunctions(JSFunctionBox *funbox, uint16& tcflags);
|
||||
bool analyzeFunctions(JSFunctionBox *funbox, uint32& tcflags);
|
||||
bool markFunArgs(JSFunctionBox *funbox, uintN tcflags);
|
||||
void setFunctionKinds(JSFunctionBox *funbox, uint16& tcflags);
|
||||
void setFunctionKinds(JSFunctionBox *funbox, uint32& tcflags);
|
||||
|
||||
void trace(JSTracer *trc);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user