Followup to bug 614493 to fix GCC overwarning about 'uninitialized' variables in js_XDRScript. r=warnings
authorJeff Walden <jwalden@mit.edu>
Thu, 30 Dec 2010 16:40:21 -0600
changeset 59974 e0166849b71d866ae07b3b8dd21d214cd3b957cb
parent 59973 68f2d2c8114519fb8c1913a73013f665c6b738d3
child 59975 9a8651caaa0ab490e67ae9c4920dde1e179dd93a
push id17820
push usercleary@mozilla.com
push dateTue, 04 Jan 2011 21:40:57 +0000
treeherdermozilla-central@969691cfe40e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswarnings
bugs614493
milestone2.0b9pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Followup to bug 614493 to fix GCC overwarning about 'uninitialized' variables in js_XDRScript. r=warnings
js/src/jsscript.cpp
js/src/jsscript.h
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -131,17 +131,17 @@ Bindings::add(JSContext *cx, JSAtom *nam
         indexp = &nvars;
         getter = GetCallVar;
         setter = SetCallVar;
         if (kind == CONSTANT)
             attrs |= JSPROP_READONLY;
         slot += nargs + nvars;
     }
 
-    if (*indexp == JS_BITMASK(16)) {
+    if (*indexp == BINDING_COUNT_LIMIT) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                              (kind == ARGUMENT)
                              ? JSMSG_TOO_MANY_FUN_ARGS
                              : JSMSG_TOO_MANY_LOCALS);
         return false;
     }
 
     jsid id;
@@ -371,32 +371,38 @@ js_XDRScript(JSXDRState *xdr, JSScript *
         *hasMagic = JS_FALSE;
         return JS_TRUE;
     }
     if (hasMagic)
         *hasMagic = JS_TRUE;
 
     /* XDR arguments, local vars, and upvars. */
     uint16 nargs, nvars, nupvars;
+#if defined(DEBUG) || defined(__GNUC__) /* quell GCC overwarning */
+    nargs = nvars = nupvars = Bindings::BINDING_COUNT_LIMIT;
+#endif
     uint32 argsVars, paddingUpvars;
     if (xdr->mode == JSXDR_ENCODE) {
         nargs = script->bindings.countArgs();
         nvars = script->bindings.countVars();
         nupvars = script->bindings.countUpvars();
         argsVars = (nargs << 16) | nvars;
         paddingUpvars = nupvars;
     }
     if (!JS_XDRUint32(xdr, &argsVars) || !JS_XDRUint32(xdr, &paddingUpvars))
         return false;
     if (xdr->mode == JSXDR_DECODE) {
         nargs = argsVars >> 16;
         nvars = argsVars & 0xFFFF;
         JS_ASSERT((paddingUpvars >> 16) == 0);
         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);
     uint32 nameCount = nargs + nvars + nupvars;
     if (nameCount > 0) {
         struct AutoMark {
           JSArenaPool * const pool;
           void * const mark;
           AutoMark(JSArenaPool *pool) : pool(pool), mark(JS_ARENA_MARK(pool)) { }
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -200,16 +200,24 @@ class Bindings {
     uintN countLocalNames() const { return nargs + nvars + nupvars; }
 
     bool hasUpvars() const { return nupvars > 0; }
     bool hasLocalNames() const { return countLocalNames() > 0; }
 
     /* Returns the shape lineage generated for these bindings. */
     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
      * being compiled.  If fun is non-null, this binding set is being created
      * for that function, so adjust corresponding metadata in that function
      * while adding.  Otherwise this set must correspond to a top-level script.
      *
      * A binding may be added twice with different kinds; the last one for a
      * given name prevails.  (We preserve both bindings for the decompiler,