Bug 1062473: Implement JS::ubi::Node::size for JSObjects. r=sfink,terrence

This commit is contained in:
Jim Blandy
2015-04-01 18:04:53 -07:00
parent c8e092e129
commit 6f7402a5d8
8 changed files with 156 additions and 12 deletions

View File

@@ -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)
{