Bug 1062473: Implement JS::ubi::Node::size for JSObjects. r=sfink,terrence
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include "jit/BaselineJIT.h"
|
||||
#include "js/MemoryMetrics.h"
|
||||
#include "js/Proxy.h"
|
||||
#include "js/UbiNode.h"
|
||||
#include "vm/ArgumentsObject.h"
|
||||
#include "vm/Interpreter.h"
|
||||
#include "vm/ProxyObject.h"
|
||||
@@ -4011,6 +4012,49 @@ JSObject::addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::ClassIn
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
JSObject::sizeOfIncludingThisInNursery() const
|
||||
{
|
||||
// This function doesn't concern itself yet with typed objects (bug 1133593)
|
||||
// nor unboxed objects (bug 1133592).
|
||||
|
||||
MOZ_ASSERT(!isTenured());
|
||||
|
||||
const Nursery &nursery = compartment()->runtimeFromAnyThread()->gc.nursery;
|
||||
size_t size = Arena::thingSize(allocKindForTenure(nursery));
|
||||
|
||||
if (is<NativeObject>()) {
|
||||
const NativeObject &native = as<NativeObject>();
|
||||
|
||||
size += native.numFixedSlots() * sizeof(Value);
|
||||
size += native.numDynamicSlots() * sizeof(Value);
|
||||
|
||||
if (native.hasDynamicElements()) {
|
||||
js::ObjectElements &elements = *native.getElementsHeader();
|
||||
if (!elements.isCopyOnWrite() || elements.ownerObject() == this)
|
||||
size += elements.capacity * sizeof(HeapSlot);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t
|
||||
JS::ubi::Concrete<JSObject>::size(mozilla::MallocSizeOf mallocSizeOf) const
|
||||
{
|
||||
JSObject &obj = get();
|
||||
|
||||
if (!obj.isTenured())
|
||||
return obj.sizeOfIncludingThisInNursery();
|
||||
|
||||
JS::ClassInfo info;
|
||||
obj.addSizeOfExcludingThis(mallocSizeOf, &info);
|
||||
return obj.tenuredSizeOfThis() + info.sizeOfAllThings();
|
||||
}
|
||||
|
||||
template<> const char16_t JS::ubi::TracerConcrete<JSObject>::concreteTypeName[] =
|
||||
MOZ_UTF16("JSObject");
|
||||
|
||||
void
|
||||
JSObject::markChildren(JSTracer* trc)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user