--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -25,28 +25,27 @@
#include <unistd.h>
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
#include "nscore.h"
-#include "mozilla/StackWalk.h"
-
-#include "js/HashTable.h"
-#include "js/Vector.h"
#include "mozilla/Assertions.h"
#include "mozilla/FastBernoulliTrial.h"
#include "mozilla/HashFunctions.h"
+#include "mozilla/HashTable.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/JSONWriter.h"
#include "mozilla/Likely.h"
#include "mozilla/MemoryReporting.h"
+#include "mozilla/StackWalk.h"
+#include "mozilla/Vector.h"
// CodeAddressService is defined entirely in the header, so this does not make
// DMD depend on XPCOM's object file.
#include "CodeAddressService.h"
// replace_malloc.h needs to be included before replace_malloc_bridge.h,
// which DMD.h includes, so DMD.h needs to be included after replace_malloc.h.
#include "replace_malloc.h"
@@ -91,18 +90,18 @@ StatusMsg(const char* aFmt, ...)
static malloc_table_t gMallocTable;
// This provides infallible allocations (they abort on OOM). We use it for all
// of DMD's own allocations, which fall into the following three cases.
//
// - Direct allocations (the easy case).
//
-// - Indirect allocations in js::{Vector,HashSet,HashMap} -- this class serves
-// as their AllocPolicy.
+// - Indirect allocations in mozilla::{Vector,HashSet,HashMap} -- this class
+// serves as their AllocPolicy.
//
// - Other indirect allocations (e.g. MozStackWalk) -- see the comments on
// Thread::mBlockIntercepts and in replace_malloc for how these work.
//
// It would be nice if we could use the InfallibleAllocPolicy from mozalloc,
// but DMD cannot use mozalloc.
//
class InfallibleAllocPolicy
@@ -157,25 +156,23 @@ public:
template <typename T>
static T* pod_calloc(size_t aNumElems)
{
T* p = maybe_pod_calloc<T>(aNumElems);
ExitOnFailure(p);
return p;
}
- // This realloc_ is the one we use for direct reallocs within DMD.
static void* realloc_(void* aPtr, size_t aNewSize)
{
void* p = gMallocTable.realloc(aPtr, aNewSize);
ExitOnFailure(p);
return p;
}
- // This realloc_ is required for this to be a JS container AllocPolicy.
template <typename T>
static T* pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize)
{
T* p = maybe_pod_realloc(aPtr, aOldSize, aNewSize);
ExitOnFailure(p);
return p;
}
@@ -616,28 +613,29 @@ public:
return n;
}
private:
struct StringHasher
{
typedef const char* Lookup;
- static uint32_t hash(const char* const& aS)
+ static mozilla::HashNumber hash(const char* const& aS)
{
return HashString(aS);
}
static bool match(const char* const& aA, const char* const& aB)
{
return strcmp(aA, aB) == 0;
}
};
- typedef js::HashSet<const char*, StringHasher, InfallibleAllocPolicy> StringHashSet;
+ typedef mozilla::HashSet<const char*, StringHasher, InfallibleAllocPolicy>
+ StringHashSet;
StringHashSet mSet;
};
class StringAlloc
{
public:
static char* copy(const char* aString)
@@ -688,17 +686,17 @@ public:
// The stack trace returned by this function is interned in gStackTraceTable,
// and so is immortal and unmovable.
static const StackTrace* Get(Thread* aT);
// Hash policy.
typedef StackTrace* Lookup;
- static uint32_t hash(const StackTrace* const& aSt)
+ static mozilla::HashNumber hash(const StackTrace* const& aSt)
{
return mozilla::HashBytes(aSt->mPcs, aSt->Size());
}
static bool match(const StackTrace* const& aA,
const StackTrace* const& aB)
{
return aA->mLength == aB->mLength &&
@@ -712,29 +710,31 @@ private:
StackTrace* st = (StackTrace*) aClosure;
MOZ_ASSERT(st->mLength < MaxFrames);
st->mPcs[st->mLength] = aPc;
st->mLength++;
MOZ_ASSERT(st->mLength == aFrameNumber);
}
};
-typedef js::HashSet<StackTrace*, StackTrace, InfallibleAllocPolicy>
+typedef mozilla::HashSet<StackTrace*, StackTrace, InfallibleAllocPolicy>
StackTraceTable;
static StackTraceTable* gStackTraceTable = nullptr;
-typedef js::HashSet<const StackTrace*, js::DefaultHasher<const StackTrace*>,
- InfallibleAllocPolicy>
+typedef mozilla::HashSet<const StackTrace*,
+ mozilla::DefaultHasher<const StackTrace*>,
+ InfallibleAllocPolicy>
StackTraceSet;
-typedef js::HashSet<const void*, js::DefaultHasher<const void*>,
- InfallibleAllocPolicy>
+typedef mozilla::HashSet<const void*, mozilla::DefaultHasher<const void*>,
+ InfallibleAllocPolicy>
PointerSet;
-typedef js::HashMap<const void*, uint32_t, js::DefaultHasher<const void*>,
- InfallibleAllocPolicy>
+typedef mozilla::HashMap<const void*, uint32_t,
+ mozilla::DefaultHasher<const void*>,
+ InfallibleAllocPolicy>
PointerIdMap;
// We won't GC the stack trace table until it this many elements.
static uint32_t gGCStackTraceTableWhenSizeExceeds = 4 * 1024;
/* static */ const StackTrace*
StackTrace::Get(Thread* aT)
{
@@ -987,37 +987,38 @@ public:
mReportStackTrace_mReportedOnAlloc[1].Set(nullptr, 0);
}
}
// Hash policy.
typedef const void* Lookup;
- static uint32_t hash(const void* const& aPtr)
+ static mozilla::HashNumber hash(const void* const& aPtr)
{
return mozilla::HashGeneric(aPtr);
}
static bool match(const LiveBlock& aB, const void* const& aPtr)
{
return aB.mPtr == aPtr;
}
};
// A table of live blocks where the lookup key is the block address.
-typedef js::HashSet<LiveBlock, LiveBlock, InfallibleAllocPolicy> LiveBlockTable;
+typedef mozilla::HashSet<LiveBlock, LiveBlock, InfallibleAllocPolicy>
+ LiveBlockTable;
static LiveBlockTable* gLiveBlockTable = nullptr;
class AggregatedLiveBlockHashPolicy
{
public:
typedef const LiveBlock* const Lookup;
- static uint32_t hash(const LiveBlock* const& aB)
+ static mozilla::HashNumber hash(const LiveBlock* const& aB)
{
return gOptions->IsDarkMatterMode()
? mozilla::HashGeneric(aB->ReqSize(),
aB->SlopSize(),
aB->AllocStackTrace(),
aB->ReportedOnAlloc1(),
aB->ReportedOnAlloc2())
: mozilla::HashGeneric(aB->ReqSize(),
@@ -1036,18 +1037,18 @@ public:
: aA->ReqSize() == aB->ReqSize() &&
aA->SlopSize() == aB->SlopSize() &&
aA->AllocStackTrace() == aB->AllocStackTrace();
}
};
// A table of live blocks where the lookup key is everything but the block
// address. For aggregating similar live blocks at output time.
-typedef js::HashMap<const LiveBlock*, size_t, AggregatedLiveBlockHashPolicy,
- InfallibleAllocPolicy>
+typedef mozilla::HashMap<const LiveBlock*, size_t,
+ AggregatedLiveBlockHashPolicy, InfallibleAllocPolicy>
AggregatedLiveBlockTable;
// A freed heap block.
class DeadBlock
{
const size_t mReqSize; // size requested
const size_t mSlopSize; // slop above size requested
@@ -1083,34 +1084,34 @@ public:
MOZ_ALWAYS_TRUE(aStackTraces.put(AllocStackTrace()));
}
}
// Hash policy.
typedef DeadBlock Lookup;
- static uint32_t hash(const DeadBlock& aB)
+ static mozilla::HashNumber hash(const DeadBlock& aB)
{
return mozilla::HashGeneric(aB.ReqSize(),
aB.SlopSize(),
aB.AllocStackTrace());
}
static bool match(const DeadBlock& aA, const DeadBlock& aB)
{
return aA.ReqSize() == aB.ReqSize() &&
aA.SlopSize() == aB.SlopSize() &&
aA.AllocStackTrace() == aB.AllocStackTrace();
}
};
// For each unique DeadBlock value we store a count of how many actual dead
// blocks have that value.
-typedef js::HashMap<DeadBlock, size_t, DeadBlock, InfallibleAllocPolicy>
+typedef mozilla::HashMap<DeadBlock, size_t, DeadBlock, InfallibleAllocPolicy>
DeadBlockTable;
static DeadBlockTable* gDeadBlockTable = nullptr;
// Add the dead block to the dead block table, if that's appropriate.
void MaybeAddToDeadBlockTable(const DeadBlock& aDb)
{
if (gOptions->IsCumulativeMode() && aDb.AllocStackTrace()) {
AutoLockState lock;