Bug 916612 - Increase maximum number of local variables to 2^28 (r=wingo)

--HG--
extra : rebase_source : d01ba20678957b25426d089c2905f5db657dca90
This commit is contained in:
Luke Wagner 2014-01-16 12:41:46 -06:00
parent a3871deb2e
commit 6aac14d939
23 changed files with 140 additions and 116 deletions

View File

@ -153,8 +153,8 @@ UpdateDepth(ExclusiveContext *cx, BytecodeEmitter *bce, ptrdiff_t target)
* An opcode may temporarily consume stack space during execution.
* Account for this in maxStackDepth separately from uses/defs here.
*/
unsigned depth = (unsigned) bce->stackDepth +
((cs->format & JOF_TMPSLOT_MASK) >> JOF_TMPSLOT_SHIFT);
uint32_t depth = (uint32_t) bce->stackDepth +
((cs->format & JOF_TMPSLOT_MASK) >> JOF_TMPSLOT_SHIFT);
if (depth > bce->maxStackDepth)
bce->maxStackDepth = depth;
}
@ -165,7 +165,7 @@ UpdateDepth(ExclusiveContext *cx, BytecodeEmitter *bce, ptrdiff_t target)
bce->stackDepth -= nuses;
JS_ASSERT(bce->stackDepth >= 0);
bce->stackDepth += ndefs;
if ((unsigned)bce->stackDepth > bce->maxStackDepth)
if ((uint32_t)bce->stackDepth > bce->maxStackDepth)
bce->maxStackDepth = bce->stackDepth;
}
@ -950,13 +950,25 @@ EmitRegExp(ExclusiveContext *cx, uint32_t index, BytecodeEmitter *bce)
* used as a non-asserting version of EMIT_UINT16_IMM_OP.
*/
static bool
EmitUnaliasedVarOp(ExclusiveContext *cx, JSOp op, uint16_t slot, BytecodeEmitter *bce)
EmitUnaliasedVarOp(ExclusiveContext *cx, JSOp op, uint32_t slot, BytecodeEmitter *bce)
{
JS_ASSERT(JOF_OPTYPE(op) != JOF_SCOPECOORD);
ptrdiff_t off = EmitN(cx, bce, op, sizeof(uint16_t));
if (IsLocalOp(op)) {
ptrdiff_t off = EmitN(cx, bce, op, LOCALNO_LEN);
if (off < 0)
return false;
SET_LOCALNO(bce->code(off), slot);
return true;
}
JS_ASSERT(IsArgOp(op));
ptrdiff_t off = EmitN(cx, bce, op, ARGNO_LEN);
if (off < 0)
return false;
SET_UINT16(bce->code(off), slot);
SET_ARGNO(bce->code(off), slot);
return true;
}
@ -2741,7 +2753,7 @@ frontend::EmitFunctionScript(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNo
if (Emit1(cx, bce, JSOP_ARGUMENTS) < 0)
return false;
InternalBindingsHandle bindings(bce->script, &bce->script->bindings);
unsigned varIndex = Bindings::argumentsVarIndex(cx, bindings);
uint32_t varIndex = Bindings::argumentsVarIndex(cx, bindings);
if (bce->script->varIsAliased(varIndex)) {
ScopeCoordinate sc;
sc.setHops(0);
@ -3150,7 +3162,7 @@ EmitDestructuringOpsHelper(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode
if (Emit1(cx, bce, JSOP_POP) < 0)
return false;
} else {
int depthBefore = bce->stackDepth;
int32_t depthBefore = bce->stackDepth;
if (!EmitDestructuringLHS(cx, bce, pn3, emitOption))
return false;
@ -3166,7 +3178,7 @@ EmitDestructuringOpsHelper(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode
* the to-be-destructured-value is always on top of the stack.
*/
JS_ASSERT((bce->stackDepth - bce->stackDepth) >= -1);
unsigned pickDistance = (unsigned)((bce->stackDepth + 1) - depthBefore);
uint32_t pickDistance = (uint32_t)((bce->stackDepth + 1) - depthBefore);
if (pickDistance > 0) {
if (pickDistance > UINT8_MAX) {
bce->reportError(pn3, JSMSG_TOO_MANY_LOCALS);
@ -3208,10 +3220,10 @@ static bool
EmitGroupAssignment(ExclusiveContext *cx, BytecodeEmitter *bce, JSOp prologOp,
ParseNode *lhs, ParseNode *rhs)
{
unsigned depth, limit, i, nslots;
uint32_t depth, limit, i, nslots;
ParseNode *pn;
depth = limit = (unsigned) bce->stackDepth;
depth = limit = (uint32_t) bce->stackDepth;
for (pn = rhs->pn_head; pn; pn = pn->pn_next) {
if (limit == JS_BIT(16)) {
bce->reportError(rhs, JSMSG_ARRAY_INIT_TOO_BIG);
@ -3247,7 +3259,7 @@ EmitGroupAssignment(ExclusiveContext *cx, BytecodeEmitter *bce, JSOp prologOp,
nslots = limit - depth;
EMIT_UINT16_IMM_OP(JSOP_POPN, nslots);
bce->stackDepth = (unsigned) depth;
bce->stackDepth = (uint32_t) depth;
return true;
}
@ -4251,7 +4263,7 @@ EmitLet(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pnLet)
return false;
/* Push storage for hoisted let decls (e.g. 'let (x) { let y }'). */
uint32_t alreadyPushed = unsigned(bce->stackDepth - letHeadDepth);
uint32_t alreadyPushed = bce->stackDepth - letHeadDepth;
uint32_t blockObjCount = blockObj->slotCount();
for (uint32_t i = alreadyPushed; i < blockObjCount; ++i) {
if (Emit1(cx, bce, JSOP_UNDEFINED) < 0)
@ -5208,7 +5220,7 @@ EmitYieldStar(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *iter)
// Catch location.
// THROW? = 'throw' in ITER // ITER
bce->stackDepth = (unsigned) depth;
bce->stackDepth = (uint32_t) depth;
if (Emit1(cx, bce, JSOP_EXCEPTION) < 0) // ITER EXCEPTION
return false;
if (Emit1(cx, bce, JSOP_SWAP) < 0) // EXCEPTION ITER
@ -5232,7 +5244,7 @@ EmitYieldStar(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *iter)
SetJumpOffsetAt(bce, checkThrow); // delegate:
// RESULT = ITER.throw(EXCEPTION) // EXCEPTION ITER
bce->stackDepth = (unsigned) depth + 1;
bce->stackDepth = (uint32_t) depth + 1;
if (Emit1(cx, bce, JSOP_DUP) < 0) // EXCEPTION ITER ITER
return false;
if (Emit1(cx, bce, JSOP_DUP) < 0) // EXCEPTION ITER ITER ITER
@ -6012,7 +6024,7 @@ EmitArrayComp(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
* its kids under pn2 to generate this comprehension.
*/
JS_ASSERT(bce->stackDepth > 0);
unsigned saveDepth = bce->arrayCompDepth;
uint32_t saveDepth = bce->arrayCompDepth;
bce->arrayCompDepth = (uint32_t) (bce->stackDepth - 1);
if (!EmitTree(cx, bce, pn->pn_head))
return false;

View File

@ -113,10 +113,10 @@ struct BytecodeEmitter
OwnedAtomIndexMapPtr atomIndices; /* literals indexed for mapping */
unsigned firstLine; /* first line, for JSScript::initFromEmitter */
int stackDepth; /* current stack depth in script frame */
unsigned maxStackDepth; /* maximum stack depth so far */
int32_t stackDepth; /* current stack depth in script frame */
uint32_t maxStackDepth; /* maximum stack depth so far */
unsigned arrayCompDepth; /* stack depth of array in comprehension */
uint32_t arrayCompDepth; /* stack depth of array in comprehension */
unsigned emitLevel; /* js::frontend::EmitTree recursion level */

View File

@ -168,7 +168,7 @@ ParseContext<FullParseHandler>::define(TokenStream &ts,
return false;
if (!vars_.append(dn))
return false;
if (vars_.length() >= SLOTNO_LIMIT) {
if (vars_.length() >= LOCALNO_LIMIT) {
ts.reportError(JSMSG_TOO_MANY_LOCALS);
return false;
}
@ -242,12 +242,12 @@ ParseContext<ParseHandler>::updateDecl(JSAtom *atom, Node pn)
JS_ASSERT(!oldDecl->pn_cookie.isFree());
newDecl->pn_cookie = oldDecl->pn_cookie;
newDecl->pn_dflags |= PND_BOUND;
if (JOF_OPTYPE(oldDecl->getOp()) == JOF_QARG) {
if (IsArgOp(oldDecl->getOp())) {
newDecl->setOp(JSOP_GETARG);
JS_ASSERT(args_[oldDecl->pn_cookie.slot()] == oldDecl);
args_[oldDecl->pn_cookie.slot()] = newDecl;
} else {
JS_ASSERT(JOF_OPTYPE(oldDecl->getOp()) == JOF_LOCAL);
JS_ASSERT(IsLocalOp(oldDecl->getOp()));
newDecl->setOp(JSOP_GETLOCAL);
JS_ASSERT(vars_[oldDecl->pn_cookie.slot()] == oldDecl);
vars_[oldDecl->pn_cookie.slot()] = newDecl;
@ -266,7 +266,7 @@ template <typename ParseHandler>
static void
AppendPackedBindings(const ParseContext<ParseHandler> *pc, const DeclVector &vec, Binding *dst)
{
for (unsigned i = 0; i < vec.length(); ++i, ++dst) {
for (size_t i = 0; i < vec.length(); ++i, ++dst) {
Definition *dn = vec[i];
PropertyName *name = dn->name();
@ -301,14 +301,22 @@ AppendPackedBindings(const ParseContext<ParseHandler> *pc, const DeclVector &vec
template <typename ParseHandler>
bool
ParseContext<ParseHandler>::generateFunctionBindings(ExclusiveContext *cx, LifoAlloc &alloc,
ParseContext<ParseHandler>::generateFunctionBindings(ExclusiveContext *cx, TokenStream &ts,
LifoAlloc &alloc,
InternalHandle<Bindings*> bindings) const
{
JS_ASSERT(sc->isFunctionBox());
JS_ASSERT(args_.length() < ARGNO_LIMIT);
JS_ASSERT(vars_.length() < SLOTNO_LIMIT);
JS_ASSERT(vars_.length() < LOCALNO_LIMIT);
unsigned count = args_.length() + vars_.length();
/*
* Avoid pathological edge cases by explicitly limiting the total number of
* bindings to what will fit in a uint32_t.
*/
if (UINT32_MAX - args_.length() <= vars_.length())
return ts.reportError(JSMSG_TOO_MANY_LOCALS);
uint32_t count = args_.length() + vars_.length();
Binding *packedBindings = alloc.newArrayUninitialized<Binding>(count);
if (!packedBindings) {
js_ReportOutOfMemory(cx);
@ -325,7 +333,7 @@ ParseContext<ParseHandler>::generateFunctionBindings(ExclusiveContext *cx, LifoA
template <typename ParseHandler>
bool
Parser<ParseHandler>::reportHelper(ParseReportKind kind, bool strict, uint32_t offset,
unsigned errorNumber, va_list args)
unsigned errorNumber, va_list args)
{
bool result = false;
switch (kind) {
@ -890,7 +898,7 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoN
InternalHandle<Bindings*> funboxBindings =
InternalHandle<Bindings*>::fromMarkedLocation(&funbox->bindings);
if (!funpc.generateFunctionBindings(context, alloc, funboxBindings))
if (!funpc.generateFunctionBindings(context, tokenStream, alloc, funboxBindings))
return null();
JS_ASSERT(fn->pn_body->isKind(PNK_ARGSBODY));
@ -1417,7 +1425,7 @@ Parser<FullParseHandler>::leaveFunction(ParseNode *fn, ParseContext<FullParseHan
InternalHandle<Bindings*> bindings =
InternalHandle<Bindings*>::fromMarkedLocation(&funbox->bindings);
return pc->generateFunctionBindings(context, alloc, bindings);
return pc->generateFunctionBindings(context, tokenStream, alloc, bindings);
}
template <>
@ -2251,7 +2259,7 @@ Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, unsigned st
InternalHandle<Bindings*> bindings =
InternalHandle<Bindings*>::fromMarkedLocation(&funbox->bindings);
if (!pc->generateFunctionBindings(context, alloc, bindings))
if (!pc->generateFunctionBindings(context, tokenStream, alloc, bindings))
return null();
if (!FoldConstants(context, &pn, this))

View File

@ -199,7 +199,8 @@ struct ParseContext : public GenericParseContext
* - Sometimes a script's bindings are accessed at runtime to retrieve the
* contents of the lexical scope (e.g., from the debugger).
*/
bool generateFunctionBindings(ExclusiveContext *cx, LifoAlloc &alloc,
bool generateFunctionBindings(ExclusiveContext *cx, TokenStream &ts,
LifoAlloc &alloc,
InternalHandle<Bindings*> bindings) const;
private:

View File

@ -1,7 +0,0 @@
//|jit-test| error: InternalError
var LIMIT = 65535;
for ( var i = 0, args = "" ; i < LIMIT; i++ ) {
args += String(i) + ( i+1 < LIMIT ? "," : "" );
}
var LENGTH = eval( "GetLength("+ args +")" );

View File

@ -0,0 +1,13 @@
const MANY_VARS = Math.pow(2,17);
var code = "function f1() {\n";
code += " var x0 = 0";
for (var i = 1; i < MANY_VARS; i++)
code += ", x" + i + " = " + i;
code += ";\n";
for (var i = 0; i < MANY_VARS; i += 100)
code += " assertEq(x" + i + ", " + i + ");\n";
code += " return x80000;\n";
code += "}\n";
eval(code);
assertEq(f1(), 80000);

View File

@ -2242,7 +2242,7 @@ BaselineCompiler::emit_JSOP_INITELEM_SETTER()
bool
BaselineCompiler::emit_JSOP_GETLOCAL()
{
uint32_t local = GET_SLOTNO(pc);
uint32_t local = GET_LOCALNO(pc);
if (local >= frame.nlocals()) {
// Destructuring assignments may use GETLOCAL to access stack values.
@ -2269,7 +2269,7 @@ BaselineCompiler::emit_JSOP_SETLOCAL()
// This also allows us to use R0 as scratch below.
frame.syncStack(1);
uint32_t local = GET_SLOTNO(pc);
uint32_t local = GET_LOCALNO(pc);
storeValue(frame.peek(-1), frame.addressOfLocal(local), R0);
return true;
}
@ -2352,7 +2352,7 @@ BaselineCompiler::emitFormalArgAccess(uint32_t arg, bool get)
bool
BaselineCompiler::emit_JSOP_GETARG()
{
uint32_t arg = GET_SLOTNO(pc);
uint32_t arg = GET_ARGNO(pc);
return emitFormalArgAccess(arg, /* get = */ true);
}
@ -2371,7 +2371,7 @@ BaselineCompiler::emit_JSOP_SETARG()
modifiesArguments_ = true;
uint32_t arg = GET_SLOTNO(pc);
uint32_t arg = GET_ARGNO(pc);
return emitFormalArgAccess(arg, /* get = */ false);
}

View File

@ -149,7 +149,7 @@ class BaselineFrame
return (Value *)this - (slot + 1);
}
Value &unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) const {
Value &unaliasedVar(uint32_t i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) const {
JS_ASSERT_IF(checkAliasing, !script()->varIsAliased(i));
JS_ASSERT(i < script()->nfixed());
return *valueSlot(i);
@ -169,7 +169,7 @@ class BaselineFrame
return argv()[i];
}
Value &unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) const {
Value &unaliasedLocal(uint32_t i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) const {
#ifdef DEBUG
CheckLocalUnaliased(checkAliasing, script(), i);
#endif

View File

@ -464,9 +464,9 @@ IonBuilder::analyzeNewLoopTypes(MBasicBlock *entry, jsbytecode *start, jsbytecod
for (jsbytecode *pc = start; pc != end; earlier = last, last = pc, pc += GetBytecodeLength(pc)) {
uint32_t slot;
if (*pc == JSOP_SETLOCAL)
slot = info().localSlot(GET_SLOTNO(pc));
slot = info().localSlot(GET_LOCALNO(pc));
else if (*pc == JSOP_SETARG)
slot = info().argSlotUnchecked(GET_SLOTNO(pc));
slot = info().argSlotUnchecked(GET_ARGNO(pc));
else
continue;
if (slot >= info().firstStackSlot())
@ -487,8 +487,8 @@ IonBuilder::analyzeNewLoopTypes(MBasicBlock *entry, jsbytecode *start, jsbytecod
}
} else if (*last == JSOP_GETLOCAL || *last == JSOP_GETARG) {
uint32_t slot = (*last == JSOP_GETLOCAL)
? info().localSlot(GET_SLOTNO(last))
: info().argSlotUnchecked(GET_SLOTNO(last));
? info().localSlot(GET_LOCALNO(last))
: info().argSlotUnchecked(GET_ARGNO(last));
if (slot < info().firstStackSlot()) {
MPhi *otherPhi = entry->getSlot(slot)->toPhi();
if (otherPhi->hasBackedgeType())
@ -1517,24 +1517,24 @@ IonBuilder::inspectOpcode(JSOp op)
if (info().argsObjAliasesFormals()) {
MGetArgumentsObjectArg *getArg = MGetArgumentsObjectArg::New(alloc(),
current->argumentsObject(),
GET_SLOTNO(pc));
GET_ARGNO(pc));
current->add(getArg);
current->push(getArg);
} else {
current->pushArg(GET_SLOTNO(pc));
current->pushArg(GET_ARGNO(pc));
}
return true;
case JSOP_SETARG:
return jsop_setarg(GET_SLOTNO(pc));
return jsop_setarg(GET_ARGNO(pc));
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
current->pushLocal(GET_SLOTNO(pc));
current->pushLocal(GET_LOCALNO(pc));
return true;
case JSOP_SETLOCAL:
current->setLocal(GET_SLOTNO(pc));
current->setLocal(GET_LOCALNO(pc));
return true;
case JSOP_POP:
@ -9139,7 +9139,7 @@ IonBuilder::jsop_setarg(uint32_t arg)
if (NeedsPostBarrier(info(), val))
current->add(MPostWriteBarrier::New(alloc(), current->argumentsObject(), val));
current->add(MSetArgumentsObjectArg::New(alloc(), current->argumentsObject(),
GET_SLOTNO(pc), val));
GET_ARGNO(pc), val));
return true;
}

View File

@ -315,7 +315,7 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
*/
jsbytecode *next = pc + JSOP_GETLOCAL_LENGTH;
if (JSOp(*next) != JSOP_POP || jumpTarget(next)) {
uint32_t local = GET_SLOTNO(pc);
uint32_t local = GET_LOCALNO(pc);
if (local >= script_->nfixed()) {
localsAliasStack_ = true;
break;
@ -326,7 +326,7 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
case JSOP_CALLLOCAL:
case JSOP_SETLOCAL: {
uint32_t local = GET_SLOTNO(pc);
uint32_t local = GET_LOCALNO(pc);
if (local >= script_->nfixed()) {
localsAliasStack_ = true;
break;

View File

@ -243,12 +243,12 @@ static inline uint32_t GetBytecodeSlot(JSScript *script, jsbytecode *pc)
case JSOP_GETARG:
case JSOP_CALLARG:
case JSOP_SETARG:
return ArgSlot(GET_SLOTNO(pc));
return ArgSlot(GET_ARGNO(pc));
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
case JSOP_SETLOCAL:
return LocalSlot(script, GET_SLOTNO(pc));
return LocalSlot(script, GET_LOCALNO(pc));
case JSOP_THIS:
return ThisSlot();

View File

@ -1022,7 +1022,7 @@ js_Disassemble1(JSContext *cx, HandleScript script, jsbytecode *pc,
break;
case JOF_LOCAL:
Sprint(sp, " %u", GET_SLOTNO(pc));
Sprint(sp, " %u", GET_LOCALNO(pc));
break;
{
@ -1444,7 +1444,7 @@ struct ExpressionDecompiler
bool init();
bool decompilePCForStackOperand(jsbytecode *pc, int i);
bool decompilePC(jsbytecode *pc);
JSAtom *getVar(unsigned slot);
JSAtom *getVar(uint32_t slot);
JSAtom *getArg(unsigned slot);
JSAtom *findLetVar(jsbytecode *pc, unsigned depth);
JSAtom *loadAtom(jsbytecode *pc);
@ -1511,7 +1511,7 @@ ExpressionDecompiler::decompilePC(jsbytecode *pc)
}
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL: {
unsigned i = GET_SLOTNO(pc);
uint32_t i = GET_LOCALNO(pc);
JSAtom *atom;
if (i >= script->nfixed()) {
i -= script->nfixed();
@ -1649,7 +1649,7 @@ ExpressionDecompiler::loadAtom(jsbytecode *pc)
}
JSAtom *
ExpressionDecompiler::findLetVar(jsbytecode *pc, unsigned depth)
ExpressionDecompiler::findLetVar(jsbytecode *pc, uint32_t depth)
{
for (JSObject *chain = script->getBlockScope(pc); chain; chain = chain->getParent()) {
StaticBlockObject &block = chain->as<StaticBlockObject>();
@ -1675,7 +1675,7 @@ ExpressionDecompiler::getArg(unsigned slot)
}
JSAtom *
ExpressionDecompiler::getVar(unsigned slot)
ExpressionDecompiler::getVar(uint32_t slot)
{
JS_ASSERT(fun);
slot += fun->nargs();

View File

@ -201,10 +201,11 @@ SET_UINT32_INDEX(jsbytecode *pc, uint32_t index)
#define ARGNO_LEN 2
#define ARGNO_LIMIT UINT16_LIMIT
#define GET_SLOTNO(pc) GET_UINT16(pc)
#define SET_SLOTNO(pc,varno) SET_UINT16(pc,varno)
#define SLOTNO_LEN 2
#define SLOTNO_LIMIT UINT16_LIMIT
#define GET_LOCALNO(pc) GET_UINT24(pc)
#define SET_LOCALNO(pc,varno) SET_UINT24(pc,varno)
#define LOCALNO_LEN 3
#define LOCALNO_BITS 24
#define LOCALNO_LIMIT (1 << LOCALNO_BITS)
/*
* Describes the 'hops' component of a JOF_SCOPECOORD opcode.

View File

@ -180,8 +180,8 @@ OPDEF(JSOP_SPREAD, 83, "spread", NULL, 1, 3, 2, JOF_BYTE|JOF_E
/* Fast get/set ops for function arguments and local variables. */
OPDEF(JSOP_GETARG, 84, "getarg", NULL, 3, 0, 1, JOF_QARG |JOF_NAME)
OPDEF(JSOP_SETARG, 85, "setarg", NULL, 3, 1, 1, JOF_QARG |JOF_NAME|JOF_SET)
OPDEF(JSOP_GETLOCAL, 86,"getlocal", NULL, 3, 0, 1, JOF_LOCAL|JOF_NAME)
OPDEF(JSOP_SETLOCAL, 87,"setlocal", NULL, 3, 1, 1, JOF_LOCAL|JOF_NAME|JOF_SET|JOF_DETECTING)
OPDEF(JSOP_GETLOCAL, 86,"getlocal", NULL, 4, 0, 1, JOF_LOCAL|JOF_NAME)
OPDEF(JSOP_SETLOCAL, 87,"setlocal", NULL, 4, 1, 1, JOF_LOCAL|JOF_NAME|JOF_SET|JOF_DETECTING)
/* Push unsigned 16-bit int constant. */
OPDEF(JSOP_UINT16, 88, "uint16", NULL, 3, 0, 1, JOF_UINT16)
@ -439,7 +439,7 @@ OPDEF(JSOP_UNUSED201, 201,"unused201", NULL, 1, 0, 0, JOF_BYTE)
*/
OPDEF(JSOP_GENERATOR, 202,"generator", NULL, 1, 0, 0, JOF_BYTE)
OPDEF(JSOP_YIELD, 203,"yield", NULL, 1, 1, 1, JOF_BYTE)
OPDEF(JSOP_ARRAYPUSH, 204,"arraypush", NULL, 3, 1, 0, JOF_LOCAL)
OPDEF(JSOP_ARRAYPUSH, 204,"arraypush", NULL, 4, 1, 0, JOF_LOCAL)
OPDEF(JSOP_UNUSED205, 205, "unused205", NULL, 1, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED206, 206, "unused206", NULL, 1, 0, 0, JOF_BYTE)
@ -450,7 +450,7 @@ OPDEF(JSOP_UNUSED209, 209, "unused209", NULL, 1, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED210, 210, "unused210", NULL, 1, 0, 0, JOF_BYTE)
OPDEF(JSOP_CALLGNAME, 211, "callgname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET|JOF_GNAME)
OPDEF(JSOP_CALLLOCAL, 212, "calllocal", NULL, 3, 0, 1, JOF_LOCAL|JOF_NAME)
OPDEF(JSOP_CALLLOCAL, 212, "calllocal", NULL, 4, 0, 1, JOF_LOCAL|JOF_NAME)
OPDEF(JSOP_CALLARG, 213, "callarg", NULL, 3, 0, 1, JOF_QARG |JOF_NAME)
OPDEF(JSOP_BINDGNAME, 214, "bindgname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_SET|JOF_GNAME)

View File

@ -53,7 +53,7 @@ using mozilla::PodZero;
typedef Rooted<GlobalObject *> RootedGlobalObject;
/* static */ unsigned
/* static */ uint32_t
Bindings::argumentsVarIndex(ExclusiveContext *cx, InternalBindingsHandle bindings)
{
HandlePropertyName arguments = cx->names().arguments;
@ -65,14 +65,14 @@ Bindings::argumentsVarIndex(ExclusiveContext *cx, InternalBindingsHandle binding
bool
Bindings::initWithTemporaryStorage(ExclusiveContext *cx, InternalBindingsHandle self,
unsigned numArgs, unsigned numVars,
unsigned numArgs, uint32_t numVars,
Binding *bindingArray)
{
JS_ASSERT(!self->callObjShape_);
JS_ASSERT(self->bindingArrayAndFlag_ == TEMPORARY_STORAGE_BIT);
JS_ASSERT(!(uintptr_t(bindingArray) & TEMPORARY_STORAGE_BIT));
JS_ASSERT(numArgs <= ARGC_LIMIT);
JS_ASSERT(numVars <= SLOTNO_LIMIT);
JS_ASSERT(numVars <= LOCALNO_LIMIT);
JS_ASSERT(UINT32_MAX - numArgs >= numVars);
self->bindingArrayAndFlag_ = uintptr_t(bindingArray) | TEMPORARY_STORAGE_BIT;
@ -105,8 +105,8 @@ Bindings::initWithTemporaryStorage(ExclusiveContext *cx, InternalBindingsHandle
#endif
BindingIter bi(self);
unsigned slot = CallObject::RESERVED_SLOTS;
for (unsigned i = 0, n = self->count(); i < n; i++, bi++) {
uint32_t slot = CallObject::RESERVED_SLOTS;
for (uint32_t i = 0, n = self->count(); i < n; i++, bi++) {
if (!bi->aliased())
continue;
@ -180,7 +180,7 @@ GCMethods<Bindings>::initial()
template<XDRMode mode>
static bool
XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, unsigned numVars,
XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, uint32_t numVars,
HandleScript script)
{
JSContext *cx = xdr->cx();
@ -198,12 +198,12 @@ XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, un
return false;
}
} else {
unsigned nameCount = numArgs + numVars;
uint32_t nameCount = numArgs + numVars;
AutoValueVector atoms(cx);
if (!atoms.resize(nameCount))
return false;
for (unsigned i = 0; i < nameCount; i++) {
for (uint32_t i = 0; i < nameCount; i++) {
RootedAtom atom(cx);
if (!XDRAtom(xdr, &atom))
return false;
@ -213,7 +213,7 @@ XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, un
Binding *bindingArray = las.alloc().newArrayUninitialized<Binding>(nameCount);
if (!bindingArray)
return false;
for (unsigned i = 0; i < nameCount; i++) {
for (uint32_t i = 0; i < nameCount; i++) {
uint8_t u8;
if (!xdr->codeUint8(&u8))
return false;
@ -234,7 +234,7 @@ XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, un
}
bool
Bindings::bindingIsAliased(unsigned bindingIndex)
Bindings::bindingIsAliased(uint32_t bindingIndex)
{
JS_ASSERT(bindingIndex < count());
return bindingArray()[bindingIndex].aliased();
@ -2033,7 +2033,7 @@ JSScript::fullyInitFromEmitter(ExclusiveContext *cx, HandleScript script, Byteco
}
// The call to nfixed() depends on the above setFunction() call.
if (script->nfixed() + bce->maxStackDepth >= JS_BIT(16)) {
if (UINT32_MAX - script->nfixed() < bce->maxStackDepth) {
bce->reportError(nullptr, JSMSG_NEED_DIET, "script");
return false;
}
@ -2974,7 +2974,7 @@ js::SetFrameArgumentsObject(JSContext *cx, AbstractFramePtr frame,
*/
InternalBindingsHandle bindings(script, &script->bindings);
const unsigned var = Bindings::argumentsVarIndex(cx, bindings);
const uint32_t var = Bindings::argumentsVarIndex(cx, bindings);
if (script->varIsAliased(var)) {
/*
@ -3075,7 +3075,7 @@ JSScript::argumentsOptimizationFailed(JSContext *cx, HandleScript script)
}
bool
JSScript::varIsAliased(unsigned varSlot)
JSScript::varIsAliased(uint32_t varSlot)
{
AutoThreadSafeAccess ts(this);
return bindings.bindingIsAliased(bindings.numArgs() + varSlot);

View File

@ -188,7 +188,7 @@ class Bindings
HeapPtr<Shape> callObjShape_;
uintptr_t bindingArrayAndFlag_;
uint16_t numArgs_;
uint16_t numVars_;
uint32_t numVars_;
/*
* During parsing, bindings are allocated out of a temporary LifoAlloc.
@ -219,7 +219,7 @@ class Bindings
* pointer into the Binding array stored in script->data.
*/
static bool initWithTemporaryStorage(ExclusiveContext *cx, InternalBindingsHandle self,
unsigned numArgs, unsigned numVars,
unsigned numArgs, uint32_t numVars,
Binding *bindingArray);
uint8_t *switchToScriptStorage(Binding *newStorage);
@ -232,17 +232,17 @@ class Bindings
HandleScript srcScript);
unsigned numArgs() const { return numArgs_; }
unsigned numVars() const { return numVars_; }
unsigned count() const { return numArgs() + numVars(); }
uint32_t numVars() const { return numVars_; }
uint32_t count() const { return numArgs() + numVars(); }
/* Return the initial shape of call objects created for this scope. */
Shape *callObjShape() const { return callObjShape_; }
/* Convenience method to get the var index of 'arguments'. */
static unsigned argumentsVarIndex(ExclusiveContext *cx, InternalBindingsHandle);
static uint32_t argumentsVarIndex(ExclusiveContext *cx, InternalBindingsHandle);
/* Return whether the binding at bindingIndex is aliased. */
bool bindingIsAliased(unsigned bindingIndex);
bool bindingIsAliased(uint32_t bindingIndex);
/* Return whether this scope has any aliased bindings. */
bool hasAnyAliasedBindings() const {
@ -627,10 +627,6 @@ class JSScript : public js::gc::BarrieredCell<JSScript>
/* Information used to re-lazify a lazily-parsed interpreted function. */
js::LazyScript *lazyScript;
#if JS_BITS_PER_WORD == 32
uint32_t padding0;
#endif
/*
* Pointer to either baseline->method()->raw() or ion->method()->raw(), or
* nullptr if there's no Baseline or Ion script.
@ -650,6 +646,7 @@ class JSScript : public js::gc::BarrieredCell<JSScript>
predef'ing prolog */
uint32_t natoms_; /* length of atoms array */
uint32_t nslots_; /* vars plus maximum stack depth */
/* Range of characters in scriptSource which contains this script's source. */
uint32_t sourceStart_;
@ -677,7 +674,6 @@ class JSScript : public js::gc::BarrieredCell<JSScript>
uint16_t nTypeSets_; /* number of type sets used in this script for
dynamic type monitoring */
uint16_t nslots_; /* vars plus maximum stack depth */
uint16_t staticLevel_;/* static level for display maintenance */
// Bit fields.
@ -1440,7 +1436,7 @@ class JSScript : public js::gc::BarrieredCell<JSScript>
return JSOp(*pc) == JSOP_RETRVAL;
}
bool varIsAliased(unsigned varSlot);
bool varIsAliased(uint32_t varSlot);
bool formalIsAliased(unsigned argSlot);
bool formalLivesInArgumentsObject(unsigned argSlot);
@ -1521,7 +1517,7 @@ namespace js {
class BindingIter
{
const InternalBindingsHandle bindings_;
unsigned i_;
uint32_t i_;
friend class Bindings;
@ -1534,7 +1530,7 @@ class BindingIter
void operator++(int) { JS_ASSERT(!done()); i_++; }
BindingIter &operator++() { (*this)++; return *this; }
unsigned frameIndex() const {
uint32_t frameIndex() const {
JS_ASSERT(!done());
return i_ < bindings_->numArgs() ? i_ : i_ - bindings_->numArgs();
}

View File

@ -2951,7 +2951,7 @@ LambdaIsGetElem(JSContext *cx, JSObject &lambda, MutableHandleObject pobj)
pc += JSOP_GETALIASEDVAR_LENGTH;
/* Look for 'a' to be the lambda's first argument. */
if (JSOp(*pc) != JSOP_GETARG || GET_SLOTNO(pc) != 0)
if (JSOp(*pc) != JSOP_GETARG || GET_ARGNO(pc) != 0)
return true;
pc += JSOP_GETARG_LENGTH;

View File

@ -2922,7 +2922,7 @@ END_CASE(JSOP_SETARG)
CASE(JSOP_GETLOCAL)
CASE(JSOP_CALLLOCAL)
{
unsigned i = GET_SLOTNO(REGS.pc);
uint32_t i = GET_LOCALNO(REGS.pc);
PUSH_COPY_SKIP_CHECK(REGS.fp()->unaliasedLocal(i));
/*
@ -2938,7 +2938,7 @@ END_CASE(JSOP_GETLOCAL)
CASE(JSOP_SETLOCAL)
{
unsigned i = GET_SLOTNO(REGS.pc);
uint32_t i = GET_LOCALNO(REGS.pc);
REGS.fp()->unaliasedLocal(i) = REGS.sp[-1];
}
END_CASE(JSOP_SETLOCAL)
@ -3395,7 +3395,7 @@ CASE(JSOP_YIELD)
CASE(JSOP_ARRAYPUSH)
{
uint32_t slot = GET_UINT16(REGS.pc);
uint32_t slot = GET_LOCALNO(REGS.pc);
JS_ASSERT(script->nfixed() <= slot);
JS_ASSERT(slot < script->nslots());
RootedObject &obj = rootObject0;

View File

@ -1149,7 +1149,7 @@ class DebugScopeProxy : public BaseProxyHandler
return false;
if (bi->kind() == VARIABLE || bi->kind() == CONSTANT) {
unsigned i = bi.frameIndex();
uint32_t i = bi.frameIndex();
if (script->varIsAliased(i))
return false;
@ -1220,7 +1220,7 @@ class DebugScopeProxy : public BaseProxyHandler
if (maybeLiveScope) {
AbstractFramePtr frame = maybeLiveScope->frame();
JSScript *script = frame.script();
unsigned local = block->slotToLocalIndex(script->bindings, shape->slot());
uint32_t local = block->slotToLocalIndex(script->bindings, shape->slot());
if (action == GET)
vp.set(frame.unaliasedLocal(local));
else

View File

@ -356,12 +356,12 @@ class BlockObject : public NestedScopeObject
* range [0, slotCount()) and the return local index is in the range
* [script->nfixed, script->nfixed + script->nslots).
*/
unsigned slotToLocalIndex(const Bindings &bindings, unsigned slot) {
uint32_t slotToLocalIndex(const Bindings &bindings, uint32_t slot) {
JS_ASSERT(slot < RESERVED_SLOTS + slotCount());
return bindings.numVars() + stackDepth() + (slot - RESERVED_SLOTS);
}
unsigned localIndexToSlot(const Bindings &bindings, uint32_t i) {
uint32_t localIndexToSlot(const Bindings &bindings, uint32_t i) {
return RESERVED_SLOTS + (i - (bindings.numVars() + stackDepth()));
}

View File

@ -97,7 +97,7 @@ StackFrame::initVarsToUndefined()
}
inline Value &
StackFrame::unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing)
StackFrame::unaliasedVar(uint32_t i, MaybeCheckAliasing checkAliasing)
{
JS_ASSERT_IF(checkAliasing, !script()->varIsAliased(i));
JS_ASSERT(i < script()->nfixed());
@ -105,7 +105,7 @@ StackFrame::unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing)
}
inline Value &
StackFrame::unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing)
StackFrame::unaliasedLocal(uint32_t i, MaybeCheckAliasing checkAliasing)
{
#ifdef DEBUG
CheckLocalUnaliased(checkAliasing, script(), i);
@ -469,7 +469,7 @@ AbstractFramePtr::numFormalArgs() const
}
inline Value &
AbstractFramePtr::unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing)
AbstractFramePtr::unaliasedVar(uint32_t i, MaybeCheckAliasing checkAliasing)
{
if (isStackFrame())
return asStackFrame()->unaliasedVar(i, checkAliasing);
@ -481,7 +481,7 @@ AbstractFramePtr::unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing)
}
inline Value &
AbstractFramePtr::unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing)
AbstractFramePtr::unaliasedLocal(uint32_t i, MaybeCheckAliasing checkAliasing)
{
if (isStackFrame())
return asStackFrame()->unaliasedLocal(i, checkAliasing);

View File

@ -1257,7 +1257,7 @@ AbstractFramePtr::hasPushedSPSFrame() const
#ifdef DEBUG
void
js::CheckLocalUnaliased(MaybeCheckAliasing checkAliasing, JSScript *script, unsigned i)
js::CheckLocalUnaliased(MaybeCheckAliasing checkAliasing, JSScript *script, uint32_t i)
{
if (!checkAliasing)
return;

View File

@ -75,7 +75,7 @@ enum MaybeCheckAliasing { CHECK_ALIASING = true, DONT_CHECK_ALIASING = false };
#ifdef DEBUG
extern void
CheckLocalUnaliased(MaybeCheckAliasing checkAliasing, JSScript *script, unsigned i);
CheckLocalUnaliased(MaybeCheckAliasing checkAliasing, JSScript *script, uint32_t i);
#endif
namespace jit {
@ -211,8 +211,8 @@ class AbstractFramePtr
inline bool copyRawFrameSlots(AutoValueVector *vec) const;
inline Value &unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
inline Value &unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
inline Value &unaliasedVar(uint32_t i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
inline Value &unaliasedLocal(uint32_t i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
inline Value &unaliasedFormal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
inline Value &unaliasedActual(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
@ -524,8 +524,8 @@ class StackFrame
* unaliased. For more about canonical values locations.
*/
inline Value &unaliasedVar(unsigned i, MaybeCheckAliasing = CHECK_ALIASING);
inline Value &unaliasedLocal(unsigned i, MaybeCheckAliasing = CHECK_ALIASING);
inline Value &unaliasedVar(uint32_t i, MaybeCheckAliasing = CHECK_ALIASING);
inline Value &unaliasedLocal(uint32_t i, MaybeCheckAliasing = CHECK_ALIASING);
bool hasArgs() const { return isNonEvalFunctionFrame(); }
inline Value &unaliasedFormal(unsigned i, MaybeCheckAliasing = CHECK_ALIASING);