Bug 1760920 - pt 8. Query memory per zone r=jonco

Since the caller usually needs to know the zone anyway, this seems simpler
if we query based on the zone rather than the object.

Differential Revision: https://phabricator.services.mozilla.com/D146677
This commit is contained in:
Paul Bone 2022-11-07 22:36:38 +00:00
Родитель 74b579a5ca
Коммит 4a20204e4e
3 изменённых файлов: 5 добавлений и 7 удалений

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

@ -763,9 +763,7 @@ JS_PUBLIC_API JS::Value js::MaybeGetScriptPrivate(JSObject* object) {
return object->as<ScriptSourceObject>().getPrivate();
}
JS_PUBLIC_API uint64_t js::GetMemoryUsageForObjectZone(JSObject* obj) {
Zone* zone = obj->zone();
JS_PUBLIC_API uint64_t js::GetMemoryUsageForZone(Zone* zone) {
// We do not include zone->sharedMemoryUseCounts since that's already included
// in zone->mallocHeapSize.
return zone->gcHeapSize.bytes() + zone->mallocHeapSize.bytes() +

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

@ -733,8 +733,8 @@ class MOZ_STACK_CLASS JS_PUBLIC_API AutoAssertNoContentJS {
};
/**
* This function reports memory used by a JS object's zone, this includes:
* * The size of this object's JS GC zone.
* This function reports memory used by a zone in bytes, this includes:
* * The size of this JS GC zone.
* * Malloc memory referred to from this zone.
* * JIT memory for this zone.
*
@ -742,7 +742,7 @@ class MOZ_STACK_CLASS JS_PUBLIC_API AutoAssertNoContentJS {
* SharedArrayBuffers which may also be referred to from other zones. Adding the
* memory usage of multiple zones may lead to an over-estimate.
*/
extern JS_PUBLIC_API uint64_t GetMemoryUsageForObjectZone(JSObject* obj);
extern JS_PUBLIC_API uint64_t GetMemoryUsageForZone(JS::Zone* zone);
/**
* This function only reports GC heap memory,

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

@ -145,7 +145,7 @@ RefPtr<MemoryPromise> CollectMemoryInfo(
// GetMemoryUsageForObjectZone() can will include SharedArrayBuffers
// which may be shared between multiple zones, this can lead to an
// over-estimate.
jsMemUsed += js::GetMemoryUsageForObjectZone(object);
jsMemUsed += js::GetMemoryUsageForZone(zone);
if (!zonesVisited.add(p, zone)) {
// OOM. Let us stop counting memory, we may undercount.
break;