Bug 976054 - Fix XDR to store script->nslots_ with a uint32_t (r=wingo)
authorLuke Wagner <luke@mozilla.com>
Tue, 25 Feb 2014 09:47:46 -0600
changeset 170752 758fef09a7277bbe2caec27c3344817e715d7bd5
parent 170751 2912b402523d8dce3afa51c7100e73b11a01d476
child 170753 07f3cfaa79004858f4466a71b0b83f2ed035e472
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerswingo
bugs976054
milestone30.0a1
Bug 976054 - Fix XDR to store script->nslots_ with a uint32_t (r=wingo)
js/src/jsscript.cpp
js/src/vm/Xdr.h
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -533,17 +533,17 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         ExplicitUseStrict,
         SelfHosted,
         IsCompileAndGo,
         HasSingleton,
         TreatAsRunOnce,
         HasLazyScript
     };
 
-    uint32_t length, lineno, column, nslots;
+    uint32_t length, lineno, column, nslots, staticLevel;
     uint32_t natoms, nsrcnotes, i;
     uint32_t nconsts, nobjects, nregexps, ntrynotes, nblockscopes;
     uint32_t prologLength, version;
     uint32_t funLength = 0;
     uint32_t nTypeSets = 0;
     uint32_t scriptBits = 0;
 
     JSContext *cx = xdr->cx();
@@ -572,18 +572,18 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         return false;
 
     if (mode == XDR_ENCODE) {
         prologLength = script->mainOffset();
         JS_ASSERT(script->getVersion() != JSVERSION_UNKNOWN);
         version = script->getVersion();
         lineno = script->lineno();
         column = script->column();
-        nslots = (uint32_t)script->nslots();
-        nslots = (uint32_t)((script->staticLevel() << 16) | script->nslots());
+        nslots = script->nslots();
+        staticLevel = script->staticLevel();
         natoms = script->natoms();
 
         nsrcnotes = script->numNotes();
 
         if (script->hasConsts())
             nconsts = script->consts()->length;
         if (script->hasObjects())
             nobjects = script->objects()->length;
@@ -764,27 +764,29 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         if (!script->scriptSource()->performXDR<mode>(xdr))
             return false;
     }
     if (!xdr->codeUint32(&script->sourceStart_))
         return false;
     if (!xdr->codeUint32(&script->sourceEnd_))
         return false;
 
-    if (!xdr->codeUint32(&lineno) || !xdr->codeUint32(&column) ||
-        !xdr->codeUint32(&nslots))
+    if (!xdr->codeUint32(&lineno) ||
+        !xdr->codeUint32(&column) ||
+        !xdr->codeUint32(&nslots) ||
+        !xdr->codeUint32(&staticLevel))
     {
         return false;
     }
 
     if (mode == XDR_DECODE) {
         script->lineno_ = lineno;
         script->column_ = column;
-        script->nslots_ = uint16_t(nslots);
-        script->staticLevel_ = uint16_t(nslots >> 16);
+        script->nslots_ = nslots;
+        script->staticLevel_ = staticLevel;
     }
 
     jsbytecode *code = script->code();
     SharedScriptData *ssd;
     if (mode == XDR_DECODE) {
         ssd = SharedScriptData::new_(cx, length, nsrcnotes, natoms);
         if (!ssd)
             return false;
--- a/js/src/vm/Xdr.h
+++ b/js/src/vm/Xdr.h
@@ -18,17 +18,17 @@ namespace js {
  * Bytecode version number. Increment the subtrahend whenever JS bytecode
  * changes incompatibly.
  *
  * This version number is XDR'd near the front of xdr bytecode and
  * aborts deserialization if there is a mismatch between the current
  * and saved versions. If deserialization fails, the data should be
  * invalidated if possible.
  */
-static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 166);
+static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 167);
 
 class XDRBuffer {
   public:
     XDRBuffer(JSContext *cx)
       : context(cx), base(nullptr), cursor(nullptr), limit(nullptr) { }
 
     JSContext *cx() const {
         return context;