Bug 721628 (part 5) - Use size_t instead of int64_t in some JS memory reporting structs. r=luke.
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -50,20 +50,20 @@
#include "js/Utility.h"
#include "js/Vector.h"
namespace JS {
/* Data for tracking analysis/inference memory usage. */
struct TypeInferenceSizes
{
- int64_t scripts;
- int64_t objects;
- int64_t tables;
- int64_t temporary;
+ size_t scripts;
+ size_t objects;
+ size_t tables;
+ size_t temporary;
};
typedef void* (* GetNameCallback)(JSContext *cx, JSCompartment *c);
typedef void (* DestroyNameCallback)(void *string);
struct CompartmentStats
{
CompartmentStats()
@@ -81,42 +81,42 @@ struct CompartmentStats
{
destroyNameCb(name);
}
// Pointer to an nsCString, which we can't use here.
void *name;
DestroyNameCallback destroyNameCb;
- int64_t gcHeapArenaHeaders;
- int64_t gcHeapArenaPadding;
- int64_t gcHeapArenaUnused;
+ size_t gcHeapArenaHeaders;
+ size_t gcHeapArenaPadding;
+ size_t gcHeapArenaUnused;
- int64_t gcHeapObjectsNonFunction;
- int64_t gcHeapObjectsFunction;
- int64_t gcHeapStrings;
- int64_t gcHeapShapesTree;
- int64_t gcHeapShapesDict;
- int64_t gcHeapShapesBase;
- int64_t gcHeapScripts;
- int64_t gcHeapTypeObjects;
- int64_t gcHeapXML;
+ size_t gcHeapObjectsNonFunction;
+ size_t gcHeapObjectsFunction;
+ size_t gcHeapStrings;
+ size_t gcHeapShapesTree;
+ size_t gcHeapShapesDict;
+ size_t gcHeapShapesBase;
+ size_t gcHeapScripts;
+ size_t gcHeapTypeObjects;
+ size_t gcHeapXML;
- int64_t objectSlots;
- int64_t objectElements;
- int64_t stringChars;
- int64_t shapesExtraTreeTables;
- int64_t shapesExtraDictTables;
- int64_t shapesExtraTreeShapeKids;
- int64_t shapesCompartmentTables;
- int64_t scriptData;
+ size_t objectSlots;
+ size_t objectElements;
+ size_t stringChars;
+ size_t shapesExtraTreeTables;
+ size_t shapesExtraDictTables;
+ size_t shapesExtraTreeShapeKids;
+ size_t shapesCompartmentTables;
+ size_t scriptData;
#ifdef JS_METHODJIT
- int64_t mjitCode;
- int64_t mjitData;
+ size_t mjitCode;
+ size_t mjitData;
#endif
TypeInferenceSizes typeInferenceSizes;
};
struct RuntimeStats
{
RuntimeStats(JSMallocSizeOfFun mallocSizeOf, GetNameCallback getNameCb,
DestroyNameCallback destroyNameCb)
@@ -146,40 +146,40 @@ struct RuntimeStats
, totalAnalysisTemp(0)
, compartmentStatsVector()
, currCompartmentStats(NULL)
, mallocSizeOf(mallocSizeOf)
, getNameCb(getNameCb)
, destroyNameCb(destroyNameCb)
{}
- int64_t runtimeObject;
- int64_t runtimeAtomsTable;
- int64_t runtimeContexts;
- int64_t runtimeNormal;
- int64_t runtimeTemporary;
- int64_t runtimeRegexpCode;
- int64_t runtimeStackCommitted;
- int64_t gcHeapChunkTotal;
- int64_t gcHeapChunkCleanUnused;
- int64_t gcHeapChunkDirtyUnused;
- int64_t gcHeapChunkCleanDecommitted;
- int64_t gcHeapChunkDirtyDecommitted;
- int64_t gcHeapArenaUnused;
- int64_t gcHeapChunkAdmin;
- int64_t gcHeapUnusedPercentage;
- int64_t totalObjects;
- int64_t totalShapes;
- int64_t totalScripts;
- int64_t totalStrings;
+ size_t runtimeObject;
+ size_t runtimeAtomsTable;
+ size_t runtimeContexts;
+ size_t runtimeNormal;
+ size_t runtimeTemporary;
+ size_t runtimeRegexpCode;
+ size_t runtimeStackCommitted;
+ size_t gcHeapChunkTotal;
+ size_t gcHeapChunkCleanUnused;
+ size_t gcHeapChunkDirtyUnused;
+ size_t gcHeapChunkCleanDecommitted;
+ size_t gcHeapChunkDirtyDecommitted;
+ size_t gcHeapArenaUnused;
+ size_t gcHeapChunkAdmin;
+ size_t gcHeapUnusedPercentage;
+ size_t totalObjects;
+ size_t totalShapes;
+ size_t totalScripts;
+ size_t totalStrings;
#ifdef JS_METHODJIT
- int64_t totalMjit;
+ size_t totalMjit;
#endif
- int64_t totalTypeInference;
- int64_t totalAnalysisTemp;
+ size_t totalTypeInference;
+ size_t totalAnalysisTemp;
js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> compartmentStatsVector;
CompartmentStats *currCompartmentStats;
JSMallocSizeOfFun mallocSizeOf;
GetNameCallback getNameCb;
DestroyNameCallback destroyNameCb;
};
--- a/js/src/MemoryMetrics.cpp
+++ b/js/src/MemoryMetrics.cpp
@@ -198,38 +198,32 @@ CollectRuntimeStats(JSRuntime *rt, Runti
JSAutoRequest ar(cx);
if (!rtStats->compartmentStatsVector.reserve(rt->compartments.length()))
return false;
rtStats->gcHeapChunkCleanDecommitted =
rt->gcChunkPool.countCleanDecommittedArenas(rt) * gc::ArenaSize;
rtStats->gcHeapChunkCleanUnused =
- int64_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize -
+ size_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize -
rtStats->gcHeapChunkCleanDecommitted;
rtStats->gcHeapChunkTotal =
- int64_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
+ size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
IterateCompartmentsArenasCells(cx, rtStats, CompartmentStatsCallback,
ArenaCallback, CellCallback);
IterateChunks(cx, rtStats, ChunkCallback);
rtStats->runtimeObject = rtStats->mallocSizeOf(rt);
- size_t normal, temporary, regexpCode, stackCommitted;
rt->sizeOfExcludingThis(rtStats->mallocSizeOf,
- &normal,
- &temporary,
- ®expCode,
- &stackCommitted);
-
- rtStats->runtimeNormal = normal;
- rtStats->runtimeTemporary = temporary;
- rtStats->runtimeRegexpCode = regexpCode;
- rtStats->runtimeStackCommitted = stackCommitted;
+ &rtStats->runtimeNormal,
+ &rtStats->runtimeTemporary,
+ &rtStats->runtimeRegexpCode,
+ &rtStats->runtimeStackCommitted);
// Nb: we use sizeOfExcludingThis() because atomState.atoms is within
// JSRuntime, and so counted when JSRuntime is counted.
rtStats->runtimeAtomsTable =
rt->atomState.atoms.sizeOfExcludingThis(rtStats->mallocSizeOf);
JSContext *acx, *iter = NULL;
while ((acx = JS_ContextIteratorUnlocked(rt, &iter)) != NULL)
@@ -245,28 +239,28 @@ CollectRuntimeStats(JSRuntime *rt, Runti
rtStats->gcHeapChunkCleanDecommitted -
rtStats->gcHeapChunkDirtyDecommitted;
for (size_t index = 0;
index < rtStats->compartmentStatsVector.length();
index++) {
CompartmentStats &cStats = rtStats->compartmentStatsVector[index];
- int64_t used = cStats.gcHeapArenaHeaders +
- cStats.gcHeapArenaPadding +
- cStats.gcHeapArenaUnused +
- cStats.gcHeapObjectsNonFunction +
- cStats.gcHeapObjectsFunction +
- cStats.gcHeapStrings +
- cStats.gcHeapShapesTree +
- cStats.gcHeapShapesDict +
- cStats.gcHeapShapesBase +
- cStats.gcHeapScripts +
- cStats.gcHeapTypeObjects +
- cStats.gcHeapXML;
+ size_t used = cStats.gcHeapArenaHeaders +
+ cStats.gcHeapArenaPadding +
+ cStats.gcHeapArenaUnused +
+ cStats.gcHeapObjectsNonFunction +
+ cStats.gcHeapObjectsFunction +
+ cStats.gcHeapStrings +
+ cStats.gcHeapShapesTree +
+ cStats.gcHeapShapesDict +
+ cStats.gcHeapShapesBase +
+ cStats.gcHeapScripts +
+ cStats.gcHeapTypeObjects +
+ cStats.gcHeapXML;
rtStats->gcHeapChunkDirtyUnused -= used;
rtStats->gcHeapArenaUnused += cStats.gcHeapArenaUnused;
rtStats->totalObjects += cStats.gcHeapObjectsNonFunction +
cStats.gcHeapObjectsFunction +
cStats.objectSlots +
cStats.objectElements;
rtStats->totalShapes += cStats.gcHeapShapesTree +
@@ -288,17 +282,17 @@ CollectRuntimeStats(JSRuntime *rt, Runti
cStats.typeInferenceSizes.scripts +
cStats.typeInferenceSizes.tables;
rtStats->totalAnalysisTemp += cStats.typeInferenceSizes.temporary;
}
size_t numDirtyChunks = (rtStats->gcHeapChunkTotal -
rtStats->gcHeapChunkCleanUnused) /
gc::ChunkSize;
- int64_t perChunkAdmin =
+ size_t perChunkAdmin =
sizeof(gc::Chunk) - (sizeof(gc::Arena) * gc::ArenasPerChunk);
rtStats->gcHeapChunkAdmin = numDirtyChunks * perChunkAdmin;
rtStats->gcHeapChunkDirtyUnused -= rtStats->gcHeapChunkAdmin;
// Why 10000x? 100x because it's a percentage, and another 100x
// because nsIMemoryReporter requires that for percentage amounts so
// they can be fractional.
rtStats->gcHeapUnusedPercentage = (rtStats->gcHeapChunkCleanUnused +
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1740,17 +1740,17 @@ public:
// the callback. Separating these steps is important because the
// callback may be a JS function, and executing JS while getting these
// stats seems like a bad idea.
JS::RuntimeStats rtStats(xpc::JsMallocSizeOf, xpc::GetCompartmentName,
xpc::DestroyCompartmentName);
if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats))
return NS_ERROR_FAILURE;
- uint64_t xpconnect;
+ size_t xpconnect;
{
xpconnect =
xpcrt->SizeOfIncludingThis(xpc::JsMallocSizeOf) +
XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(xpc::JsMallocSizeOf);
}
NS_NAMED_LITERAL_CSTRING(pathPrefix, "explicit/js/");