Bug 897507 - part 2: add nsrcnotes argument to SaveSharedScriptData and use it instead of script->numNotes(). r=bhackett
authorTill Schneidereit <till@tillschneidereit.net>
Fri, 26 Jul 2013 01:27:04 +0200
changeset 140057 91bc683b2f45e0c0b2a45aae70da4ff009f7588b
parent 140056 5c0924e999922e4eb1f2cbcbbb456386a44518cc
child 140058 924c4d59db8b27892cfcdff998c97ec0111a4689
push id31584
push usertschneidereit@gmail.com
push dateFri, 26 Jul 2013 01:06:05 +0000
treeherdermozilla-inbound@91bc683b2f45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs897507
milestone25.0a1
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
Bug 897507 - part 2: add nsrcnotes argument to SaveSharedScriptData and use it instead of script->numNotes(). r=bhackett
js/src/jsscript.cpp
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -381,17 +381,17 @@ FindBlockIndex(JSScript *script, StaticB
         if (vector[i] == &block)
             return i;
     }
 
     MOZ_ASSUME_UNREACHABLE("Block not found");
 }
 
 static bool
-SaveSharedScriptData(ExclusiveContext *, Handle<JSScript *> , SharedScriptData *);
+SaveSharedScriptData(ExclusiveContext *, Handle<JSScript *>, SharedScriptData *, uint32_t);
 
 template<XDRMode mode>
 bool
 js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enclosingScript,
               HandleFunction fun, MutableHandleScript scriptp)
 {
     /* NB: Keep this in sync with CloneScript. */
 
@@ -648,17 +648,17 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         } else {
             RootedAtom tmp(cx, script->atoms[i]);
             if (!XDRAtom(xdr, &tmp))
                 return false;
         }
     }
 
     if (mode == XDR_DECODE) {
-        if (!SaveSharedScriptData(cx, script, ssd))
+        if (!SaveSharedScriptData(cx, script, ssd, nsrcnotes))
             return false;
     }
 
     /*
      * Here looping from 0-to-length to xdr objects is essential to ensure that
      * all references to enclosing blocks (via FindBlockIndex below) happen
      * after the enclosing block has been XDR'd.
      */
@@ -1521,17 +1521,18 @@ js::SharedScriptData::new_(ExclusiveCont
 
 /*
  * Takes ownership of its *ssd parameter and either adds it into the runtime's
  * ScriptDataTable or frees it if a matching entry already exists.
  *
  * Sets the |code| and |atoms| fields on the given JSScript.
  */
 static bool
-SaveSharedScriptData(ExclusiveContext *cx, Handle<JSScript *> script, SharedScriptData *ssd)
+SaveSharedScriptData(ExclusiveContext *cx, Handle<JSScript *> script, SharedScriptData *ssd,
+                     uint32_t nsrcnotes)
 {
     ASSERT(script != NULL);
     ASSERT(ssd != NULL);
 
     AutoLockForExclusiveAccess lock(cx);
 
     ScriptBytecodeHasher::Lookup l(ssd);
 
@@ -1557,17 +1558,17 @@ SaveSharedScriptData(ExclusiveContext *c
     if (cx->isJSContext()) {
         JSRuntime *rt = cx->asJSContext()->runtime();
         if (JS::IsIncrementalGCInProgress(rt) && rt->gcIsFull)
             ssd->marked = true;
     }
 #endif
 
     script->code = ssd->data;
-    script->atoms = ssd->atoms(script->length, script->numNotes());
+    script->atoms = ssd->atoms(script->length, nsrcnotes);
     return true;
 }
 
 static inline void
 MarkScriptData(JSRuntime *rt, const jsbytecode *bytecode)
 {
     /*
      * As an invariant, a ScriptBytecodeEntry should not be 'marked' outside of
@@ -1874,17 +1875,17 @@ JSScript::fullyInitTrivial(ExclusiveCont
 
     SharedScriptData *ssd = SharedScriptData::new_(cx, 1, 1, 0);
     if (!ssd)
         return false;
 
     ssd->data[0] = JSOP_STOP;
     ssd->data[1] = SRC_NULL;
     script->length = 1;
-    return SaveSharedScriptData(cx, script, ssd);
+    return SaveSharedScriptData(cx, script, ssd, 1);
 }
 
 /* static */ bool
 JSScript::fullyInitFromEmitter(ExclusiveContext *cx, HandleScript script, BytecodeEmitter *bce)
 {
     /* The counts of indexed things must be checked during code generation. */
     JS_ASSERT(bce->atomIndices->count() <= INDEX_LIMIT);
     JS_ASSERT(bce->objectList.length <= INDEX_LIMIT);
@@ -1914,17 +1915,17 @@ JSScript::fullyInitFromEmitter(Exclusive
 
     jsbytecode *code = ssd->data;
     PodCopy<jsbytecode>(code, bce->prolog.code.begin(), prologLength);
     PodCopy<jsbytecode>(code + prologLength, bce->code().begin(), mainLength);
     if (!FinishTakingSrcNotes(cx, bce, (jssrcnote *)(code + script->length)))
         return false;
     InitAtomMap(bce->atomIndices.getMap(), ssd->atoms(script->length, nsrcnotes));
 
-    if (!SaveSharedScriptData(cx, script, ssd))
+    if (!SaveSharedScriptData(cx, script, ssd, nsrcnotes))
         return false;
 
     uint32_t nfixed = bce->sc->isFunctionBox() ? script->bindings.numVars() : 0;
     JS_ASSERT(nfixed < SLOTNO_LIMIT);
     script->nfixed = uint16_t(nfixed);
     if (script->nfixed + bce->maxStackDepth >= JS_BIT(16)) {
         bce->reportError(NULL, JSMSG_NEED_DIET, "script");
         return false;