Bug 996785 - Use separate maps for local and remote CPOW objects (r=mrbkap)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 16 May 2014 16:40:36 -0700
changeset 183654 85e6824afa65a9ab3b1eb7afc705143a7d104f0a
parent 183653 4b7c1b82d2aa722406acf8e83c75b3e2a8759503
child 183655 15ecb06251c8b7e886dec794e42c923fa8ab6217
push id6844
push userphilringnalda@gmail.com
push dateSun, 18 May 2014 01:12:08 +0000
treeherderfx-team@41a54c8add09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs996785
milestone32.0a1
Bug 996785 - Use separate maps for local and remote CPOW objects (r=mrbkap)
js/ipc/JavaScriptChild.cpp
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
--- a/js/ipc/JavaScriptChild.cpp
+++ b/js/ipc/JavaScriptChild.cpp
@@ -35,16 +35,17 @@ JavaScriptChild::~JavaScriptChild()
 {
     JS_RemoveExtraGCRootsTracer(rt_, Trace, this);
 }
 
 void
 JavaScriptChild::trace(JSTracer *trc)
 {
     objects_.trace(trc);
+    cpows_.trace(trc);
     ids_.trace(trc);
 }
 
 bool
 JavaScriptChild::init()
 {
     if (!JavaScriptShared::init())
         return false;
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -505,17 +505,17 @@ CPOWProxyHandler::finalize(JSFreeOp *fop
     ParentOf(proxy)->drop(proxy);
 }
 
 void
 JavaScriptParent::drop(JSObject *obj)
 {
     ObjectId objId = idOf(obj);
 
-    objects_.remove(objId);
+    cpows_.remove(objId);
     if (!inactive_ && !SendDropObject(objId))
         (void)0;
     decref();
 }
 
 bool
 JavaScriptParent::init()
 {
@@ -587,17 +587,17 @@ JavaScriptParent::fromId(JSContext *cx, 
                          &CPOWProxyHandler::singleton,
                          v,
                          nullptr,
                          global,
                          options);
     if (!obj)
         return nullptr;
 
-    if (!objects_.add(objId, obj))
+    if (!cpows_.add(objId, obj))
         return nullptr;
 
     // Incref once we know the decref will be called.
     incref();
 
     SetProxyExtra(obj, 0, PrivateValue(this));
     SetProxyExtra(obj, 1, DoubleValue(BitwiseCast<double>(objId)));
     return obj;
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -125,16 +125,18 @@ ObjectToIdMap::remove(JSObject *obj)
     table_->remove(obj);
 }
 
 bool
 JavaScriptShared::init()
 {
     if (!objects_.init())
         return false;
+    if (!cpows_.init())
+        return false;
     return true;
 }
 
 bool
 JavaScriptShared::convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsString *to)
 {
     RootedValue idval(cx);
     if (!JS_IdToValue(cx, id, &idval))
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -115,24 +115,25 @@ class JavaScriptShared
         objp.set(fromId(cx, id));
         return bool(objp.get());
     }
 
     static void ConvertID(const nsID &from, JSIID *to);
     static void ConvertID(const JSIID &from, nsID *to);
 
     JSObject *findCPOWById(uint32_t objId) {
-        return objects_.find(objId);
+        return cpows_.find(objId);
     }
     JSObject *findObjectById(uint32_t objId) {
         return objects_.find(objId);
     }
 
   protected:
     IdToObjectMap objects_;
+    IdToObjectMap cpows_;
 };
 
 // Use 47 at most, to be safe, since jsval privates are encoded as doubles.
 static const uint64_t MAX_CPOW_IDS = (uint64_t(1) << 47) - 1;
 
 } // namespace jsipc
 } // namespace mozilla