Bug 980537 - Only store FakeBackstagePass instances in mThisObjects. r=khuey, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Sun, 06 Apr 2014 12:32:39 -0700
changeset 1836459933fa36efa5
parent 183644 7e9b33204db9
child 183646 51e5b0ec21b3
push id3434
push userryanvm@gmail.com
push date2014-04-07 16:57 +0000
Treeherderresults
reviewerskhuey, sledru
bugs980537
milestone29.0
Bug 980537 - Only store FakeBackstagePass instances in mThisObjects. r=khuey, a=sledru
js/xpconnect/loader/mozJSComponentLoader.cpp
     1.1 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp
     1.2 +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
     1.3 @@ -564,17 +564,19 @@ mozJSComponentLoader::FindTargetObject(J
     1.4  
     1.5  void
     1.6  mozJSComponentLoader::NoteSubScript(HandleScript aScript, HandleObject aThisObject)
     1.7  {
     1.8    if (!mInitialized && NS_FAILED(ReallyInit())) {
     1.9        MOZ_CRASH();
    1.10    }
    1.11  
    1.12 -  mThisObjects.Put(aScript, aThisObject);
    1.13 +  if (js::GetObjectJSClass(aThisObject) == &kFakeBackstagePassJSClass) {
    1.14 +    mThisObjects.Put(aScript, aThisObject);
    1.15 +  }
    1.16  }
    1.17  
    1.18  /* static */ size_t
    1.19  mozJSComponentLoader::DataEntrySizeOfExcludingThis(const nsACString& aKey,
    1.20                                                     ModuleEntry* const& aData,
    1.21                                                     MallocSizeOf aMallocSizeOf, void*)
    1.22  {
    1.23      return aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
    1.24 @@ -997,20 +999,23 @@ mozJSComponentLoader::ObjectForLocation(
    1.25      RootedScript tableScript(cx, script);
    1.26      if (!tableScript) {
    1.27          tableScript = JS_GetFunctionScript(cx, function);
    1.28          MOZ_ASSERT(tableScript);
    1.29      }
    1.30  
    1.31      *aTableScript = tableScript;
    1.32  
    1.33 -    // tableScript stays in the table until shutdown. To avoid it being
    1.34 -    // collected and another script getting the same address, we root
    1.35 -    // tableScript lower down in this function.
    1.36 -    mThisObjects.Put(tableScript, obj);
    1.37 +    if (js::GetObjectJSClass(obj) == &kFakeBackstagePassJSClass) {
    1.38 +        MOZ_ASSERT(mReuseLoaderGlobal);
    1.39 +        // tableScript stays in the table until shutdown. To avoid it being
    1.40 +        // collected and another script getting the same address, we root
    1.41 +        // tableScript lower down in this function.
    1.42 +        mThisObjects.Put(tableScript, obj);
    1.43 +    }
    1.44      bool ok = false;
    1.45  
    1.46      {
    1.47          AutoSaveContextOptions asco(cx);
    1.48          if (aPropagateExceptions)
    1.49              ContextOptionsRef(cx).setDontReportUncaught(true);
    1.50          if (script) {
    1.51              ok = JS_ExecuteScriptVersion(cx, obj, script, nullptr, JSVERSION_LATEST);