Bug 765436 - Remove WrappedNative2WrapperMap; r=mrbkap
authorTerrence Cole <terrence@mozilla.com>
Mon, 18 Jun 2012 18:47:55 -0700
changeset 101786 8a7588128430bca0346f89481e3428b3bccd37b7
parent 101785 2168e72ab8d323e9ff8f6f6416fc57ba6fc9783a
child 101787 ddf9d7173d720d721705a05a7062a85bebebcfa5
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs765436
milestone16.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 765436 - Remove WrappedNative2WrapperMap; r=mrbkap It is completely unused.
js/xpconnect/src/XPCForwards.h
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCMaps.h
--- a/js/xpconnect/src/XPCForwards.h
+++ b/js/xpconnect/src/XPCForwards.h
@@ -42,17 +42,16 @@ class Native2WrappedNativeMap;
 class IID2WrappedJSClassMap;
 class IID2NativeInterfaceMap;
 class ClassInfo2NativeSetMap;
 class ClassInfo2WrappedNativeProtoMap;
 class NativeSetMap;
 class IID2ThisTranslatorMap;
 class XPCNativeScriptableSharedMap;
 class XPCWrappedNativeProtoMap;
-class WrappedNative2WrapperMap;
 class JSObject2JSObjectMap;
 
 class nsXPCComponents;
 class nsXPCComponents_Interfaces;
 class nsXPCComponents_InterfacesByID;
 class nsXPCComponents_Classes;
 class nsXPCComponents_ClassesByID;
 class nsXPCComponents_Results;
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -644,137 +644,8 @@ XPCWrappedNativeProtoMap::XPCWrappedNati
 
 XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
 {
     if (mTable)
         JS_DHashTableDestroy(mTable);
 }
 
 /***************************************************************************/
-// implement WrappedNative2WrapperMap...
-
-struct JSDHashTableOps
-WrappedNative2WrapperMap::sOps = {
-    JS_DHashAllocTable,
-    JS_DHashFreeTable,
-    JS_DHashVoidPtrKeyStub,
-    JS_DHashMatchEntryStub,
-    MoveLink,
-    ClearLink,
-    JS_DHashFinalizeStub,
-    nsnull
-};
-
-// static
-void
-WrappedNative2WrapperMap::ClearLink(JSDHashTable* table,
-                                    JSDHashEntryHdr* entry)
-{
-    Entry* e = static_cast<Entry*>(entry);
-    e->key = nsnull;
-    PR_REMOVE_LINK(&e->value);
-    memset(e, 0, sizeof(*e));
-}
-
-// static
-void
-WrappedNative2WrapperMap::MoveLink(JSDHashTable* table,
-                                   const JSDHashEntryHdr* from,
-                                   JSDHashEntryHdr* to)
-{
-    const Entry* oldEntry = static_cast<const Entry*>(from);
-    Entry* newEntry = static_cast<Entry*>(to);
-
-    newEntry->key = oldEntry->key;
-
-    // Now update the list.
-    if (PR_CLIST_IS_EMPTY(&oldEntry->value)) {
-        PR_INIT_CLIST(&newEntry->value);
-        newEntry->value.obj = oldEntry->value.obj;
-    } else {
-        newEntry->value = oldEntry->value;
-        newEntry->value.next->prev = &newEntry->value;
-        newEntry->value.prev->next = &newEntry->value;
-    }
-}
-
-// static
-WrappedNative2WrapperMap*
-WrappedNative2WrapperMap::newMap(int size)
-{
-    WrappedNative2WrapperMap* map = new WrappedNative2WrapperMap(size);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nsnull;
-}
-
-WrappedNative2WrapperMap::WrappedNative2WrapperMap(int size)
-{
-    mTable = JS_NewDHashTable(&sOps, nsnull, sizeof(Entry), size);
-}
-
-WrappedNative2WrapperMap::~WrappedNative2WrapperMap()
-{
-    if (mTable)
-        JS_DHashTableDestroy(mTable);
-}
-
-JSObject*
-WrappedNative2WrapperMap::Add(WrappedNative2WrapperMap* head,
-                              JSObject* wrappedObject,
-                              JSObject* wrapper)
-{
-    NS_PRECONDITION(wrappedObject,"bad param");
-    Entry* entry = (Entry*)
-        JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_ADD);
-    if (!entry)
-        return nsnull;
-    NS_ASSERTION(!entry->key || this == head, "dangling pointer?");
-    entry->key = wrappedObject;
-    Link* l = &entry->value;
-
-    NS_ASSERTION(!l->obj, "Uh, how'd this happen?");
-
-    if (!l->next) {
-        // Initialize the circular list. This case only happens when
-        // this == head.
-        PR_INIT_CLIST(l);
-    }
-
-    l->obj = wrapper;
-
-    if (this != head) {
-        Link* headLink = head->FindLink(wrappedObject);
-        if (!headLink) {
-            Entry* dummy = (Entry*)
-                JS_DHashTableOperate(head->mTable, wrappedObject, JS_DHASH_ADD);
-            dummy->key = wrappedObject;
-            headLink = &dummy->value;
-            PR_INIT_CLIST(headLink);
-            headLink->obj = nsnull;
-        }
-
-        PR_INSERT_BEFORE(l, headLink);
-    }
-
-    return wrapper;
-}
-
-bool
-WrappedNative2WrapperMap::AddLink(JSObject* wrappedObject, Link* oldLink)
-{
-    Entry* entry = (Entry*)
-        JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_ADD);
-    if (!entry)
-        return false;
-    NS_ASSERTION(!entry->key, "Eh? What's happening?");
-    entry->key = wrappedObject;
-    Link* newLink = &entry->value;
-
-    PR_INSERT_LINK(newLink, oldLink);
-    PR_REMOVE_AND_INIT_LINK(oldLink);
-    newLink->obj = oldLink->obj;
-
-    return true;
-}
-
-/***************************************************************************/
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -596,88 +596,17 @@ public:
     ~XPCWrappedNativeProtoMap();
 private:
     XPCWrappedNativeProtoMap();    // no implementation
     XPCWrappedNativeProtoMap(int size);
 private:
     JSDHashTable *mTable;
 };
 
-class WrappedNative2WrapperMap
-{
-    static struct JSDHashTableOps sOps;
-
-    static void ClearLink(JSDHashTable* table, JSDHashEntryHdr* entry);
-    static void MoveLink(JSDHashTable* table, const JSDHashEntryHdr* from,
-                         JSDHashEntryHdr* to);
-
-public:
-    struct Link : public PRCList
-    {
-        JSObject *obj;
-    };
-
-    struct Entry : public JSDHashEntryHdr
-    {
-        // Note: key must be the flat JSObject for a wrapped native.
-        JSObject*         key;
-        Link              value;
-    };
-
-    static WrappedNative2WrapperMap* newMap(int size);
-
-    inline JSObject* Find(JSObject* wrapper)
-    {
-        NS_PRECONDITION(wrapper, "bad param");
-        Entry* entry = (Entry*)
-            JS_DHashTableOperate(mTable, wrapper, JS_DHASH_LOOKUP);
-        if (JS_DHASH_ENTRY_IS_FREE(entry))
-            return nsnull;
-        return entry->value.obj;
-    }
-
-    // Note: If the entry already exists, then this will overwrite the
-    // existing entry, returning the old value.
-    JSObject* Add(WrappedNative2WrapperMap* head,
-                  JSObject* wrappedObject,
-                  JSObject* wrapper);
-
-    // Function to find a link.
-    Link* FindLink(JSObject* wrappedObject)
-    {
-        Entry* entry = (Entry*)
-            JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_LOOKUP);
-        if (JS_DHASH_ENTRY_IS_BUSY(entry))
-            return &entry->value;
-        return nsnull;
-    }
-
-    // "Internal" function to add an empty link without doing unnecessary
-    // work.
-    bool AddLink(JSObject* wrappedObject, Link* oldLink);
-
-    inline void Remove(JSObject* wrapper)
-    {
-        NS_PRECONDITION(wrapper,"bad param");
-        JS_DHashTableOperate(mTable, wrapper, JS_DHASH_REMOVE);
-    }
-
-    inline uint32_t Count() {return mTable->entryCount;}
-    inline uint32_t Enumerate(JSDHashEnumerator f, void *arg)
-        {return JS_DHashTableEnumerate(mTable, f, arg);}
-
-    ~WrappedNative2WrapperMap();
-
-private:
-    WrappedNative2WrapperMap();    // no implementation
-    WrappedNative2WrapperMap(int size);
-
-private:
-    JSDHashTable *mTable;
-};
+/***************************************************************************/
 
 class JSObject2JSObjectMap
 {
     typedef js::HashMap<JSObject *, JSObject *, js::PointerHasher<JSObject *, 3>,
                         js::SystemAllocPolicy> Map;
 
 public:
     static JSObject2JSObjectMap* newMap(int size)