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 183645 9933fa36efa5
parent 183644 7e9b33204db9
child 183646 51e5b0ec21b3
push id3434
push userryanvm@gmail.com
push date2014-04-07 16:57 +0000
treeherdermozilla-beta@004a7c15d761 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, sledru
bugs980537
milestone29.0
Bug 980537 - Only store FakeBackstagePass instances in mThisObjects. r=khuey, a=sledru
js/xpconnect/loader/mozJSComponentLoader.cpp
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -564,17 +564,19 @@ mozJSComponentLoader::FindTargetObject(J
 
 void
 mozJSComponentLoader::NoteSubScript(HandleScript aScript, HandleObject aThisObject)
 {
   if (!mInitialized && NS_FAILED(ReallyInit())) {
       MOZ_CRASH();
   }
 
-  mThisObjects.Put(aScript, aThisObject);
+  if (js::GetObjectJSClass(aThisObject) == &kFakeBackstagePassJSClass) {
+    mThisObjects.Put(aScript, aThisObject);
+  }
 }
 
 /* static */ size_t
 mozJSComponentLoader::DataEntrySizeOfExcludingThis(const nsACString& aKey,
                                                    ModuleEntry* const& aData,
                                                    MallocSizeOf aMallocSizeOf, void*)
 {
     return aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
@@ -997,20 +999,23 @@ mozJSComponentLoader::ObjectForLocation(
     RootedScript tableScript(cx, script);
     if (!tableScript) {
         tableScript = JS_GetFunctionScript(cx, function);
         MOZ_ASSERT(tableScript);
     }
 
     *aTableScript = tableScript;
 
-    // tableScript stays in the table until shutdown. To avoid it being
-    // collected and another script getting the same address, we root
-    // tableScript lower down in this function.
-    mThisObjects.Put(tableScript, obj);
+    if (js::GetObjectJSClass(obj) == &kFakeBackstagePassJSClass) {
+        MOZ_ASSERT(mReuseLoaderGlobal);
+        // tableScript stays in the table until shutdown. To avoid it being
+        // collected and another script getting the same address, we root
+        // tableScript lower down in this function.
+        mThisObjects.Put(tableScript, obj);
+    }
     bool ok = false;
 
     {
         AutoSaveContextOptions asco(cx);
         if (aPropagateExceptions)
             ContextOptionsRef(cx).setDontReportUncaught(true);
         if (script) {
             ok = JS_ExecuteScriptVersion(cx, obj, script, nullptr, JSVERSION_LATEST);