Bug 721628 (part 3) - Rename several size type-inference-related measurement functions and types. r=bhackett.

--HG--
extra : rebase_source : e66bc2d787c31de93ff80280597543cf47924967
This commit is contained in:
Nicholas Nethercote 2012-01-26 19:09:31 -08:00
Родитель 470a265f0b
Коммит 6ee279d5ec
7 изменённых файлов: 70 добавлений и 77 удалений

Просмотреть файл

@ -53,7 +53,7 @@
namespace JS {
/* Data for tracking analysis/inference memory usage. */
struct TypeInferenceMemoryStats
struct TypeInferenceSizes
{
int64_t scripts;
int64_t objects;
@ -113,7 +113,7 @@ struct CompartmentStats
int64_t mjitCode;
int64_t mjitData;
#endif
TypeInferenceMemoryStats typeInferenceMemory;
TypeInferenceSizes typeInferenceSizes;
};
struct IterateData
@ -195,19 +195,6 @@ GetExplicitNonHeapForRuntime(JSRuntime *rt, int64_t *amount,
#endif /* JS_THREADSAFE */
extern void
SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment,
TypeInferenceMemoryStats *stats,
JSMallocSizeOfFun mallocSizeOf);
extern void
SizeOfTypeObjectExcludingThis(/*TypeObject*/ void *object,
TypeInferenceMemoryStats *stats,
JSMallocSizeOfFun mallocSizeOf);
extern size_t
SizeOfCompartmentShapeTable(JSCompartment *c, JSMallocSizeOfFun mallocSizeOf);
extern JS_PUBLIC_API(size_t)
SystemCompartmentCount(const JSRuntime *rt);

Просмотреть файл

@ -70,11 +70,8 @@ CompartmentMemoryCallback(JSContext *cx, void *vdata, JSCompartment *compartment
#ifdef JS_METHODJIT
curr.mjitCode = compartment->sizeOfMjitCode();
#endif
SizeOfCompartmentTypeInferenceData(cx, compartment,
&curr.typeInferenceMemory,
data->mallocSizeOf);
curr.shapesCompartmentTables =
SizeOfCompartmentShapeTable(compartment, data->mallocSizeOf);
compartment->sizeOfTypeInferenceData(cx, &curr.typeInferenceSizes, data->mallocSizeOf);
curr.shapesCompartmentTables = compartment->sizeOfShapeTable(data->mallocSizeOf);
}
static void
@ -178,8 +175,7 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind,
{
types::TypeObject *obj = static_cast<types::TypeObject *>(thing);
curr->gcHeapTypeObjects += thingSize;
SizeOfTypeObjectExcludingThis(obj, &curr->typeInferenceMemory,
data->mallocSizeOf);
obj->sizeOfExcludingThis(&curr->typeInferenceSizes, data->mallocSizeOf);
break;
}
case JSTRACE_XML:
@ -292,10 +288,10 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
stats.mjitData;
#endif
data->totalTypeInference += stats.gcHeapTypeObjects +
stats.typeInferenceMemory.objects +
stats.typeInferenceMemory.scripts +
stats.typeInferenceMemory.tables;
data->totalAnalysisTemp += stats.typeInferenceMemory.temporary;
stats.typeInferenceSizes.objects +
stats.typeInferenceSizes.scripts +
stats.typeInferenceSizes.tables;
data->totalAnalysisTemp += stats.typeInferenceSizes.temporary;
}
size_t numDirtyChunks = (data->gcHeapChunkTotal -

Просмотреть файл

@ -770,10 +770,10 @@ JSCompartment::createBarrierTracer()
}
size_t
JS::SizeOfCompartmentShapeTable(JSCompartment *c, JSMallocSizeOfFun mallocSizeOf)
JSCompartment::sizeOfShapeTable(JSMallocSizeOfFun mallocSizeOf)
{
return c->baseShapes.sizeOfExcludingThis(mallocSizeOf)
+ c->initialShapes.sizeOfExcludingThis(mallocSizeOf)
+ c->newTypeObjects.sizeOfExcludingThis(mallocSizeOf)
+ c->lazyTypeObjects.sizeOfExcludingThis(mallocSizeOf);
return baseShapes.sizeOfExcludingThis(mallocSizeOf)
+ initialShapes.sizeOfExcludingThis(mallocSizeOf)
+ newTypeObjects.sizeOfExcludingThis(mallocSizeOf)
+ lazyTypeObjects.sizeOfExcludingThis(mallocSizeOf);
}

Просмотреть файл

@ -164,6 +164,10 @@ typedef HashSet<ScriptFilenameEntry *,
} /* namespace js */
namespace JS {
struct TypeInferenceSizes;
}
struct JSCompartment
{
JSRuntime *rt;
@ -240,6 +244,10 @@ struct JSCompartment
size_t sizeOfMjitCode() const;
#endif
size_t sizeOfShapeTable(JSMallocSizeOfFun mallocSizeOf);
void sizeOfTypeInferenceData(JSContext *cx, JS::TypeInferenceSizes *stats,
JSMallocSizeOfFun mallocSizeOf);
/*
* Shared scope property tree, and arena-pool for allocating its nodes.
*/

Просмотреть файл

@ -6258,12 +6258,12 @@ TypeScript::destroy()
}
inline size_t
TypeSet::dynamicSize()
TypeSet::computedSizeOfExcludingThis()
{
/*
* This memory is allocated within the temp pool (but accounted for
* elsewhere) so we can't use a JSMallocSizeOfFun to measure it. We must
* do it analytically.
* compute its size analytically.
*/
uint32_t count = baseObjectCount();
if (count >= 2)
@ -6272,12 +6272,12 @@ TypeSet::dynamicSize()
}
inline size_t
TypeObject::dynamicSize()
TypeObject::computedSizeOfExcludingThis()
{
/*
* This memory is allocated within the temp pool (but accounted for
* elsewhere) so we can't use a JSMallocSizeOfFun to measure it. We must
* do it analytically.
* compute its size analytically.
*/
size_t bytes = 0;
@ -6289,14 +6289,15 @@ TypeObject::dynamicSize()
for (unsigned i = 0; i < count; i++) {
Property *prop = getProperty(i);
if (prop)
bytes += sizeof(Property) + prop->types.dynamicSize();
bytes += sizeof(Property) + prop->types.computedSizeOfExcludingThis();
}
return bytes;
}
static void
GetScriptMemoryStats(JSScript *script, TypeInferenceMemoryStats *stats, JSMallocSizeOfFun mallocSizeOf)
SizeOfScriptTypeInferenceData(JSScript *script, TypeInferenceSizes *sizes,
JSMallocSizeOfFun mallocSizeOf)
{
TypeScript *typeScript = script->types;
if (!typeScript)
@ -6304,18 +6305,18 @@ GetScriptMemoryStats(JSScript *script, TypeInferenceMemoryStats *stats, JSMalloc
/* If TI is disabled, a single TypeScript is still present. */
if (!script->compartment()->types.inferenceEnabled) {
stats->scripts += mallocSizeOf(typeScript);
sizes->scripts += mallocSizeOf(typeScript);
return;
}
stats->scripts += mallocSizeOf(typeScript->nesting);
sizes->scripts += mallocSizeOf(typeScript->nesting);
unsigned count = TypeScript::NumTypeSets(script);
stats->scripts += mallocSizeOf(typeScript);
sizes->scripts += mallocSizeOf(typeScript);
TypeResult *result = typeScript->dynamicList;
while (result) {
stats->scripts += mallocSizeOf(result);
sizes->scripts += mallocSizeOf(result);
result = result->next;
}
@ -6325,15 +6326,14 @@ GetScriptMemoryStats(JSScript *script, TypeInferenceMemoryStats *stats, JSMalloc
*/
TypeSet *typeArray = typeScript->typeArray();
for (unsigned i = 0; i < count; i++) {
size_t bytes = typeArray[i].dynamicSize();
stats->scripts += bytes;
stats->temporary -= bytes;
size_t bytes = typeArray[i].computedSizeOfExcludingThis();
sizes->scripts += bytes;
sizes->temporary -= bytes;
}
}
void
JS::SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment,
TypeInferenceMemoryStats *stats,
JSCompartment::sizeOfTypeInferenceData(JSContext *cx, TypeInferenceSizes *sizes,
JSMallocSizeOfFun mallocSizeOf)
{
/*
@ -6341,28 +6341,27 @@ JS::SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment
* by being copied to the replacement pool. This memory will be counted
* elsewhere and deducted from the amount of temporary data.
*/
stats->temporary += compartment->typeLifoAlloc.sizeOfExcludingThis(mallocSizeOf);
sizes->temporary += typeLifoAlloc.sizeOfExcludingThis(mallocSizeOf);
/* Pending arrays are cleared on GC along with the analysis pool. */
stats->temporary +=
mallocSizeOf(compartment->types.pendingArray);
sizes->temporary += mallocSizeOf(types.pendingArray);
/* TypeCompartment::pendingRecompiles is non-NULL only while inference code is running. */
JS_ASSERT(!compartment->types.pendingRecompiles);
JS_ASSERT(!types.pendingRecompiles);
for (gc::CellIter i(cx, compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next())
GetScriptMemoryStats(i.get<JSScript>(), stats, mallocSizeOf);
for (gc::CellIter i(cx, this, gc::FINALIZE_SCRIPT); !i.done(); i.next())
SizeOfScriptTypeInferenceData(i.get<JSScript>(), sizes, mallocSizeOf);
if (compartment->types.allocationSiteTable)
stats->tables += compartment->types.allocationSiteTable->sizeOfIncludingThis(mallocSizeOf);
if (types.allocationSiteTable)
sizes->tables += types.allocationSiteTable->sizeOfIncludingThis(mallocSizeOf);
if (compartment->types.arrayTypeTable)
stats->tables += compartment->types.arrayTypeTable->sizeOfIncludingThis(mallocSizeOf);
if (types.arrayTypeTable)
sizes->tables += types.arrayTypeTable->sizeOfIncludingThis(mallocSizeOf);
if (compartment->types.objectTypeTable) {
stats->tables += compartment->types.objectTypeTable->sizeOfIncludingThis(mallocSizeOf);
if (types.objectTypeTable) {
sizes->tables += types.objectTypeTable->sizeOfIncludingThis(mallocSizeOf);
for (ObjectTypeTable::Enum e(*compartment->types.objectTypeTable);
for (ObjectTypeTable::Enum e(*types.objectTypeTable);
!e.empty();
e.popFront())
{
@ -6370,34 +6369,31 @@ JS::SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment
const ObjectTableEntry &value = e.front().value;
/* key.ids and values.types have the same length. */
stats->tables += mallocSizeOf(key.ids) + mallocSizeOf(value.types);
sizes->tables += mallocSizeOf(key.ids) + mallocSizeOf(value.types);
}
}
}
void
JS::SizeOfTypeObjectExcludingThis(void *object_, TypeInferenceMemoryStats *stats, JSMallocSizeOfFun mallocSizeOf)
TypeObject::sizeOfExcludingThis(TypeInferenceSizes *sizes, JSMallocSizeOfFun mallocSizeOf)
{
TypeObject *object = (TypeObject *) object_;
if (object->singleton) {
if (singleton) {
/*
* Properties and associated type sets for singletons are cleared on
* every GC. The type object is normally destroyed too, but we don't
* charge this to 'temporary' as this is not for GC heap values.
*/
JS_ASSERT(!object->newScript);
JS_ASSERT(!newScript);
return;
}
if (object->newScript)
stats->objects += mallocSizeOf(object->newScript);
sizes->objects += mallocSizeOf(newScript);
/*
* This counts memory that is in the temp pool but gets attributed
* elsewhere. See JS_GetTypeInferenceMemoryStats for more details.
* elsewhere. See JSCompartment::sizeOfTypeInferenceData for more details.
*/
size_t bytes = object->dynamicSize();
stats->objects += bytes;
stats->temporary -= bytes;
size_t bytes = computedSizeOfExcludingThis();
sizes->objects += bytes;
sizes->temporary -= bytes;
}

Просмотреть файл

@ -51,6 +51,10 @@
#include "gc/Barrier.h"
#include "js/HashTable.h"
namespace JS {
struct TypeInferenceSizes;
}
namespace js {
namespace types {
@ -366,7 +370,7 @@ class TypeSet
void print(JSContext *cx);
inline void sweep(JSContext *cx, JSCompartment *compartment);
inline size_t dynamicSize();
inline size_t computedSizeOfExcludingThis();
/* Whether this set contains a specific type. */
inline bool hasType(Type type);
@ -865,7 +869,9 @@ struct TypeObject : gc::Cell
inline void clearProperties();
inline void sweep(JSContext *cx);
inline size_t dynamicSize();
inline size_t computedSizeOfExcludingThis();
void sizeOfExcludingThis(TypeInferenceSizes *sizes, JSMallocSizeOfFun mallocSizeOf);
/*
* Type objects don't have explicit finalizers. Memory owned by a type

Просмотреть файл

@ -1598,7 +1598,7 @@ ReportCompartmentStats(const JS::CompartmentStats &stats,
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats,
"type-inference/script-main"),
nsIMemoryReporter::KIND_HEAP,
stats.typeInferenceMemory.scripts,
stats.typeInferenceSizes.scripts,
"Memory used during type inference to store type sets of variables "
"and dynamically observed types.",
callback, closure);
@ -1606,7 +1606,7 @@ ReportCompartmentStats(const JS::CompartmentStats &stats,
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats,
"type-inference/object-main"),
nsIMemoryReporter::KIND_HEAP,
stats.typeInferenceMemory.objects,
stats.typeInferenceSizes.objects,
"Memory used during type inference to store types and possible "
"property types of JS objects.",
callback, closure);
@ -1614,14 +1614,14 @@ ReportCompartmentStats(const JS::CompartmentStats &stats,
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats,
"type-inference/tables"),
nsIMemoryReporter::KIND_HEAP,
stats.typeInferenceMemory.tables,
stats.typeInferenceSizes.tables,
"Memory used during type inference for compartment-wide tables.",
callback, closure);
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats,
"analysis-temporary"),
nsIMemoryReporter::KIND_HEAP,
stats.typeInferenceMemory.temporary,
stats.typeInferenceSizes.temporary,
"Memory used during type inference and compilation to hold transient "
"analysis information. Cleared on GC.",
callback, closure);