Followup to bug 614493 to fix GCC overwarning about 'uninitialized' variables in js_XDRScript. r=warnings

--HG--
extra : rebase_source : ce0062c356524ee14dedf39e67c6aa1880259afb
This commit is contained in:
Jeff Walden 2010-12-30 16:40:21 -06:00
parent bc1aa44f51
commit 32dfb1669c
2 changed files with 15 additions and 1 deletions

View File

@ -136,7 +136,7 @@ Bindings::add(JSContext *cx, JSAtom *name, BindingKind kind)
slot += nargs + nvars; slot += nargs + nvars;
} }
if (*indexp == JS_BITMASK(16)) { if (*indexp == BINDING_COUNT_LIMIT) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
(kind == ARGUMENT) (kind == ARGUMENT)
? JSMSG_TOO_MANY_FUN_ARGS ? JSMSG_TOO_MANY_FUN_ARGS
@ -376,6 +376,9 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
/* XDR arguments, local vars, and upvars. */ /* XDR arguments, local vars, and upvars. */
uint16 nargs, nvars, nupvars; uint16 nargs, nvars, nupvars;
#if defined(DEBUG) || defined(__GNUC__) /* quell GCC overwarning */
nargs = nvars = nupvars = Bindings::BINDING_COUNT_LIMIT;
#endif
uint32 argsVars, paddingUpvars; uint32 argsVars, paddingUpvars;
if (xdr->mode == JSXDR_ENCODE) { if (xdr->mode == JSXDR_ENCODE) {
nargs = script->bindings.countArgs(); nargs = script->bindings.countArgs();
@ -392,6 +395,9 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
JS_ASSERT((paddingUpvars >> 16) == 0); JS_ASSERT((paddingUpvars >> 16) == 0);
nupvars = paddingUpvars & 0xFFFF; nupvars = paddingUpvars & 0xFFFF;
} }
JS_ASSERT(nargs != Bindings::BINDING_COUNT_LIMIT);
JS_ASSERT(nvars != Bindings::BINDING_COUNT_LIMIT);
JS_ASSERT(nupvars != Bindings::BINDING_COUNT_LIMIT);
Bindings bindings(cx); Bindings bindings(cx);
uint32 nameCount = nargs + nvars + nupvars; uint32 nameCount = nargs + nvars + nupvars;

View File

@ -205,6 +205,14 @@ class Bindings {
/* Returns the shape lineage generated for these bindings. */ /* Returns the shape lineage generated for these bindings. */
inline const js::Shape *lastShape() const; inline const js::Shape *lastShape() const;
enum {
/*
* A script may have no more than this many arguments, variables, or
* upvars.
*/
BINDING_COUNT_LIMIT = 0xFFFF
};
/* /*
* Add a local binding for the given name, of the given type, for the code * Add a local binding for the given name, of the given type, for the code
* being compiled. If fun is non-null, this binding set is being created * being compiled. If fun is non-null, this binding set is being created