Bug 1121202 - Remove unused PL_DHashTableOperate function. r=njn
authorMichael Pruett <michael@68k.org>
Thu, 15 Jan 2015 18:01:07 -0600
changeset 224219 d4a53fee1e2517002b25f06e5516fc95977f7b4b
parent 224218 d172fffe7074288db17141d23f0bc2afe45f92c5
child 224220 d614944d001cf9e5f79591d5df0a27c5f8e01fc4
push id54159
push userryanvm@gmail.com
push dateFri, 16 Jan 2015 16:01:22 +0000
treeherdermozilla-inbound@26263767b141 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1121202
milestone38.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 1121202 - Remove unused PL_DHashTableOperate function. r=njn
dom/plugins/base/nsJSNPRuntime.cpp
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1769,18 +1769,17 @@ NPObjWrapper_ObjectMoved(JSObject *obj, 
     return;
   }
 
   NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
   if (!npobj) {
     return;
   }
 
-  // The hazard analysis thinks that PL_DHashTableOperate() can GC but this is
-  // not possible if we pass PL_DHASH_LOOKUP.
+  // Calling PL_DHashTableLookup() will not result in GC.
   JS::AutoSuppressGCAnalysis nogc;
 
   NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
     (PL_DHashTableLookup(&sNPObjWrappers, npobj));
   MOZ_ASSERT(PL_DHASH_ENTRY_IS_BUSY(entry) && entry->mJSObj);
   MOZ_ASSERT(entry->mJSObj == old);
   entry->mJSObj = obj;
 }
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -631,22 +631,16 @@ PLDHashTable::Operate(const void* aKey, 
   }
 
   DECREMENT_RECURSION_LEVEL(this);
 
   return entry;
 }
 
 PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableOperate(PLDHashTable* aTable, const void* aKey, PLDHashOperator aOp)
-{
-  return aTable->Operate(aKey, aOp);
-}
-
-PLDHashEntryHdr* PL_DHASH_FASTCALL
 PL_DHashTableLookup(PLDHashTable* aTable, const void* aKey)
 {
   return aTable->Operate(aKey, PL_DHASH_LOOKUP);
 }
 
 PLDHashEntryHdr* PL_DHASH_FASTCALL
 PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey)
 {
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -69,23 +69,23 @@ struct PLDHashTableOps;
  * Callback types are defined below and grouped into the PLDHashTableOps
  * structure, for single static initialization per hash table sub-type.
  *
  * Each hash table sub-type should nest the PLDHashEntryHdr structure at the
  * front of its particular entry type.  The keyHash member contains the result
  * of multiplying the hash code returned from the hashKey callback (see below)
  * by PL_DHASH_GOLDEN_RATIO, then constraining the result to avoid the magic 0
  * and 1 values.  The stored keyHash value is table size invariant, and it is
- * maintained automatically by PL_DHashTableOperate -- users should never set
- * it, and its only uses should be via the entry macros below.
+ * maintained automatically -- users should never set it, and its only uses
+ * should be via the entry macros below.
  *
  * However, use PL_DHASH_ENTRY_IS_BUSY for faster liveness testing of entries
- * returned by PL_DHashTableOperate, as PL_DHashTableOperate never returns a
- * non-live, busy (i.e., removed) entry pointer to its caller.  See below for
- * more details on PL_DHashTableOperate's calling rules.
+ * returned by PL_DHashTableLookup and PL_DHashTableAdd, as these functions
+ * never return a non-live, busy (i.e., removed) entry pointer to its caller.
+ * See below for more details on these functions.
  */
 struct PLDHashEntryHdr
 {
   PLDHashNumber keyHash;  /* every entry must begin like this */
 };
 
 MOZ_ALWAYS_INLINE bool
 PL_DHASH_ENTRY_IS_FREE(PLDHashEntryHdr* aEntry)
@@ -128,28 +128,28 @@ typedef enum PLDHashOperator
  *
  * The return value, op, is treated as a set of flags.  If op is PL_DHASH_NEXT,
  * then continue enumerating.  If op contains PL_DHASH_REMOVE, then clear (via
  * aTable->ops->clearEntry) and free entry.  Then we check whether op contains
  * PL_DHASH_STOP; if so, stop enumerating and return the number of live entries
  * that were enumerated so far.  Return the total number of live entries when
  * enumeration completes normally.
  *
- * If etor calls PL_DHashTableOperate on table with op != PL_DHASH_LOOKUP, it
- * must return PL_DHASH_STOP; otherwise undefined behavior results.
+ * If etor calls PL_DHashTableAdd or PL_DHashTableRemove on table, it must
+ * return PL_DHASH_STOP; otherwise undefined behavior results.
  *
  * If any enumerator returns PL_DHASH_REMOVE, aTable->mEntryStore may be shrunk
  * or compressed after enumeration, but before PL_DHashTableEnumerate returns.
  * Such an enumerator therefore can't safely set aside entry pointers, but an
  * enumerator that never returns PL_DHASH_REMOVE can set pointers to entries
  * aside, e.g., to avoid copying live entries into an array of the entry type.
  * Copying entry pointers is cheaper, and safe so long as the caller of such a
  * "stable" Enumerate doesn't use the set-aside pointers after any call either
- * to PL_DHashTableOperate, or to an "unstable" form of Enumerate, which might
- * grow or shrink mEntryStore.
+ * to PL_DHashTableAdd or PL_DHashTableRemove, or to an "unstable" form of
+ * Enumerate, which might grow or shrink mEntryStore.
  *
  * If your enumerator wants to remove certain entries, but set aside pointers
  * to other entries that it retains, it can use PL_DHashTableRawRemove on the
  * entries to be removed, returning PL_DHASH_NEXT to skip them.  Likewise, if
  * you want to remove entries, but for some reason you do not want mEntryStore
  * to be shrunk or compressed, you can call PL_DHashTableRawRemove safely on
  * the entry being enumerated, rather than returning PL_DHASH_REMOVE.
  */
@@ -329,20 +329,19 @@ typedef void (*PLDHashMoveEntry)(PLDHash
  * invoked during a PL_DHASH_REMOVE operation (see below for operation codes),
  * but only if the given key is found in the table.
  */
 typedef void (*PLDHashClearEntry)(PLDHashTable* aTable,
                                   PLDHashEntryHdr* aEntry);
 
 /*
  * Initialize a new entry, apart from keyHash.  This function is called when
- * PL_DHashTableOperate's PL_DHASH_ADD case finds no existing entry for the
- * given key, and must add a new one.  At that point, aEntry->keyHash is not
- * set yet, to avoid claiming the last free entry in a severely overloaded
- * table.
+ * PL_DHashTableAdd finds no existing entry for the given key, and must add a
+ * new one.  At that point, aEntry->keyHash is not set yet, to avoid claiming
+ * the last free entry in a severely overloaded table.
  */
 typedef bool (*PLDHashInitEntry)(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
                                  const void* aKey);
 
 /*
  * Finally, the "vtable" structure for PLDHashTable.  The first four hooks
  * must be provided by implementations; they're called unconditionally by the
  * generic pldhash.c code.  Hooks after these may be null.
@@ -350,23 +349,23 @@ typedef bool (*PLDHashInitEntry)(PLDHash
  * Summary of allocation-related hook usage with C++ placement new emphasis:
  *  initEntry           Call placement new using default key-based ctor.
  *                      Return true on success, false on error.
  *  moveEntry           Call placement new using copy ctor, run dtor on old
  *                      entry storage.
  *  clearEntry          Run dtor on entry.
  *
  * Note the reason why initEntry is optional: the default hooks (stubs) clear
- * entry storage:  On successful PL_DHashTableOperate(tbl, key, PL_DHASH_ADD),
- * the returned entry pointer addresses an entry struct whose keyHash member
- * has been set non-zero, but all other entry members are still clear (null).
- * PL_DHASH_ADD callers can test such members to see whether the entry was
- * newly created by the PL_DHASH_ADD call that just succeeded.  If placement
- * new or similar initialization is required, define an initEntry hook.  Of
- * course, the clearEntry hook must zero or null appropriately.
+ * entry storage:  On successful PL_DHashTableAdd(tbl, key), the returned entry
+ * pointer addresses an entry struct whose keyHash member has been set
+ * non-zero, but all other entry members are still clear (null).
+ * PL_DHashTableAdd callers can test such members to see whether the entry was
+ * newly created by the PL_DHashTableAdd call that just succeeded.  If
+ * placement new or similar initialization is required, define an initEntry
+ * hook.  Of course, the clearEntry hook must zero or null appropriately.
  *
  * XXX assumes 0 is null for pointer types.
  */
 struct PLDHashTableOps
 {
   /* Mandatory hooks.  All implementations must provide these. */
   PLDHashHashKey      hashKey;
   PLDHashMatchEntry   matchEntry;
@@ -457,64 +456,59 @@ MOZ_WARN_UNUSED_RESULT bool PL_DHashTabl
  * to destroy a PLDHashTable that is allocated on the stack or in static memory
  * and was created via PL_DHashTableInit().
  */
 void PL_DHashTableFinish(PLDHashTable* aTable);
 
 /*
  * To lookup a key in table, call:
  *
- *  entry = PL_DHashTableOperate(table, key, PL_DHASH_LOOKUP);
+ *  entry = PL_DHashTableLookup(table, key);
  *
  * If PL_DHASH_ENTRY_IS_BUSY(entry) is true, key was found and it identifies
  * entry.  If PL_DHASH_ENTRY_IS_FREE(entry) is true, key was not found.
- *
+ */
+PLDHashEntryHdr* PL_DHASH_FASTCALL
+PL_DHashTableLookup(PLDHashTable* aTable, const void* aKey);
+
+/*
  * To add an entry identified by key to table, call:
  *
- *  entry = PL_DHashTableOperate(table, key, PL_DHASH_ADD);
+ *  entry = PL_DHashTableAdd(table, key);
  *
  * If entry is null upon return, then either the table is severely overloaded,
  * and memory can't be allocated for entry storage. Or if
  * aTable->ops->initEntry is non-null, the aTable->ops->initEntry op may have
  * returned false.
  *
  * Otherwise, aEntry->keyHash has been set so that PL_DHASH_ENTRY_IS_BUSY(entry)
  * is true, and it is up to the caller to initialize the key and value parts
  * of the entry sub-type, if they have not been set already (i.e. if entry was
  * not already in the table, and if the optional initEntry hook was not used).
- *
+ */
+PLDHashEntryHdr* PL_DHASH_FASTCALL
+PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey);
+
+/*
  * To remove an entry identified by key from table, call:
  *
- *  (void) PL_DHashTableOperate(table, key, PL_DHASH_REMOVE);
+ *  PL_DHashTableRemove(table, key);
  *
  * If key's entry is found, it is cleared (via table->ops->clearEntry) and
  * the entry is marked so that PL_DHASH_ENTRY_IS_FREE(entry).  This operation
  * returns null unconditionally; you should ignore its return value.
  */
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableOperate(PLDHashTable* aTable, const void* aKey,
-                     PLDHashOperator aOp);
-
-/* Look up a key in table. */
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableLookup(PLDHashTable* aTable, const void* aKey);
-
-/* Add an entry identified by key to table. */
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey);
-
-/* Remove an entry identified by key from table. */
 void PL_DHASH_FASTCALL
 PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey);
 
 /*
  * Remove an entry already accessed via LOOKUP or ADD.
  *
  * NB: this is a "raw" or low-level routine, intended to be used only where
- * the inefficiency of a full PL_DHashTableOperate (which rehashes in order
+ * the inefficiency of a full PL_DHashTableRemove (which rehashes in order
  * to find the entry given its key) is not tolerable.  This function does not
  * shrink the table if it is underloaded.  It does not update mStats #ifdef
  * PL_DHASHMETER, either.
  */
 void PL_DHashTableRawRemove(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
 
 uint32_t
 PL_DHashTableEnumerate(PLDHashTable* aTable, PLDHashEnumerator aEtor,