Bug 996785 - Rename CPOW object map (r=mrbkap)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 16 May 2014 16:40:35 -0700
changeset 183650 737d5beb60c4f59acd68bb233893b9188d55bf98
parent 183649 48a84f76656dea28f489c306212c17a4b5edbff8
child 183651 bb17661ca3bcde81273bd4b176693f69072733a7
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 - Rename CPOW object map (r=mrbkap)
js/ipc/JavaScriptChild.h
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
--- a/js/ipc/JavaScriptChild.h
+++ b/js/ipc/JavaScriptChild.h
@@ -74,15 +74,15 @@ class JavaScriptChild
   private:
     bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp);
     bool fail(JSContext *cx, ReturnStatus *rs);
     bool ok(ReturnStatus *rs);
 
   private:
     ObjectId lastId_;
     JSRuntime *rt_;
-    ObjectIdCache ids_;
+    ObjectToIdMap ids_;
 };
 
 } // mozilla
 } // jsipc
 
 #endif
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -10,121 +10,122 @@
 #include "jsfriendapi.h"
 #include "xpcprivate.h"
 
 using namespace js;
 using namespace JS;
 using namespace mozilla;
 using namespace mozilla::jsipc;
 
-ObjectStore::ObjectStore()
+IdToObjectMap::IdToObjectMap()
   : table_(SystemAllocPolicy())
 {
 }
 
 bool
-ObjectStore::init()
+IdToObjectMap::init()
 {
     return table_.init(32);
 }
 
 void
-ObjectStore::trace(JSTracer *trc)
+IdToObjectMap::trace(JSTracer *trc)
 {
-    for (ObjectTable::Range r(table_.all()); !r.empty(); r.popFront()) {
+    for (Table::Range r(table_.all()); !r.empty(); r.popFront()) {
         DebugOnly<JSObject *> prior = r.front().value().get();
         JS_CallHeapObjectTracer(trc, &r.front().value(), "ipc-object");
         MOZ_ASSERT(r.front().value() == prior);
     }
 }
 
 JSObject *
-ObjectStore::find(ObjectId id)
+IdToObjectMap::find(ObjectId id)
 {
-    ObjectTable::Ptr p = table_.lookup(id);
+    Table::Ptr p = table_.lookup(id);
     if (!p)
         return nullptr;
     return p->value();
 }
 
 bool
-ObjectStore::add(ObjectId id, JSObject *obj)
+IdToObjectMap::add(ObjectId id, JSObject *obj)
 {
     return table_.put(id, obj);
 }
 
 void
-ObjectStore::remove(ObjectId id)
+IdToObjectMap::remove(ObjectId id)
 {
     table_.remove(id);
 }
 
-ObjectIdCache::ObjectIdCache()
+ObjectToIdMap::ObjectToIdMap()
   : table_(nullptr)
 {
 }
 
-ObjectIdCache::~ObjectIdCache()
+ObjectToIdMap::~ObjectToIdMap()
 {
     if (table_) {
-        dom::AddForDeferredFinalization<ObjectIdTable, nsAutoPtr>(table_);
+        dom::AddForDeferredFinalization<Table, nsAutoPtr>(table_);
         table_ = nullptr;
     }
 }
 
 bool
-ObjectIdCache::init()
+ObjectToIdMap::init()
 {
     MOZ_ASSERT(!table_);
-    table_ = new ObjectIdTable(SystemAllocPolicy());
+    table_ = new Table(SystemAllocPolicy());
     return table_ && table_->init(32);
 }
 
 void
-ObjectIdCache::trace(JSTracer *trc)
+ObjectToIdMap::trace(JSTracer *trc)
 {
-    for (ObjectIdTable::Range r(table_->all()); !r.empty(); r.popFront()) {
+    for (Table::Range r(table_->all()); !r.empty(); r.popFront()) {
         JSObject *obj = r.front().key();
         JS_CallObjectTracer(trc, &obj, "ipc-id");
         MOZ_ASSERT(obj == r.front().key());
     }
 }
 
 ObjectId
-ObjectIdCache::find(JSObject *obj)
+ObjectToIdMap::find(JSObject *obj)
 {
-    ObjectIdTable::Ptr p = table_->lookup(obj);
+    Table::Ptr p = table_->lookup(obj);
     if (!p)
         return 0;
     return p->value();
 }
 
 bool
-ObjectIdCache::add(JSContext *cx, JSObject *obj, ObjectId id)
+ObjectToIdMap::add(JSContext *cx, JSObject *obj, ObjectId id)
 {
     if (!table_->put(obj, id))
         return false;
     JS_StoreObjectPostBarrierCallback(cx, keyMarkCallback, obj, table_);
     return true;
 }
 
 /*
  * This function is called during minor GCs for each key in the HashMap that has
  * been moved.
  */
 /* static */ void
-ObjectIdCache::keyMarkCallback(JSTracer *trc, JSObject *key, void *data) {
-    ObjectIdTable* table = static_cast<ObjectIdTable*>(data);
+ObjectToIdMap::keyMarkCallback(JSTracer *trc, JSObject *key, void *data)
+{
+    Table *table = static_cast<Table*>(data);
     JSObject *prior = key;
     JS_CallObjectTracer(trc, &key, "ObjectIdCache::table_ key");
     table->rekeyIfMoved(prior, key);
 }
 
 void
-ObjectIdCache::remove(JSObject *obj)
+ObjectToIdMap::remove(JSObject *obj)
 {
     table_->remove(obj);
 }
 
 bool
 JavaScriptShared::init()
 {
     if (!objects_.init())
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -32,57 +32,57 @@ class CpowIdHolder : public CpowHolder
     bool ToObject(JSContext *cx, JS::MutableHandleObject objp);
 
   private:
     JavaScriptShared *js_;
     const InfallibleTArray<CpowEntry> &cpows_;
 };
 
 // Map ids -> JSObjects
-class ObjectStore
+class IdToObjectMap
 {
     typedef js::DefaultHasher<ObjectId> TableKeyHasher;
 
-    typedef js::HashMap<ObjectId, JS::Heap<JSObject *>, TableKeyHasher, js::SystemAllocPolicy> ObjectTable;
+    typedef js::HashMap<ObjectId, JS::Heap<JSObject *>, TableKeyHasher, js::SystemAllocPolicy> Table;
 
   public:
-    ObjectStore();
+    IdToObjectMap();
 
     bool init();
     void trace(JSTracer *trc);
 
     bool add(ObjectId id, JSObject *obj);
     JSObject *find(ObjectId id);
     void remove(ObjectId id);
 
   private:
-    ObjectTable table_;
+    Table table_;
 };
 
 // Map JSObjects -> ids
-class ObjectIdCache
+class ObjectToIdMap
 {
     typedef js::PointerHasher<JSObject *, 3> Hasher;
-    typedef js::HashMap<JSObject *, ObjectId, Hasher, js::SystemAllocPolicy> ObjectIdTable;
+    typedef js::HashMap<JSObject *, ObjectId, Hasher, js::SystemAllocPolicy> Table;
 
   public:
-    ObjectIdCache();
-    ~ObjectIdCache();
+    ObjectToIdMap();
+    ~ObjectToIdMap();
 
     bool init();
     void trace(JSTracer *trc);
 
     bool add(JSContext *cx, JSObject *obj, ObjectId id);
     ObjectId find(JSObject *obj);
     void remove(JSObject *obj);
 
   private:
     static void keyMarkCallback(JSTracer *trc, JSObject *key, void *data);
 
-    ObjectIdTable *table_;
+    Table *table_;
 };
 
 class JavaScriptShared
 {
   public:
     bool init();
 
     static const uint32_t OBJECT_EXTRA_BITS  = 1;
@@ -124,17 +124,17 @@ class JavaScriptShared
     static void ConvertID(const nsID &from, JSIID *to);
     static void ConvertID(const JSIID &from, nsID *to);
 
     JSObject *findObject(uint32_t objId) {
         return objects_.find(objId);
     }
 
   protected:
-    ObjectStore objects_;
+    IdToObjectMap objects_;
 };
 
 // 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