Bug 1180763 - Part 1: Add the size of the tenured object to the tenure promotions log entry; r=sfink

This commit is contained in:
Nick Fitzgerald 2015-07-13 20:20:29 -07:00
parent 741a23f13c
commit 38b909f9c6
4 changed files with 19 additions and 9 deletions

View File

@ -140,6 +140,7 @@ Zone::logPromotionsToTenured()
return;
auto now = JS_GetCurrentEmbedderTime();
JSRuntime* rt = runtimeFromAnyThread();
for (auto** dbgp = dbgs->begin(); dbgp != dbgs->end(); dbgp++) {
if (!(*dbgp)->isEnabled() || !(*dbgp)->isTrackingTenurePromotions())
@ -147,7 +148,7 @@ Zone::logPromotionsToTenured()
for (auto range = awaitingTenureLogging.all(); !range.empty(); range.popFront()) {
if ((*dbgp)->isDebuggee(range.front()->compartment()))
(*dbgp)->logTenurePromotion(*range.front(), now);
(*dbgp)->logTenurePromotion(rt, *range.front(), now);
}
}

View File

@ -1701,10 +1701,18 @@ Debugger::isDebuggee(const JSCompartment* compartment) const
return compartment->isDebuggee() && debuggees.has(compartment->maybeGlobal());
}
Debugger::TenurePromotionsEntry::TenurePromotionsEntry(JSRuntime* rt, JSObject& obj, double when)
: className(obj.getClass()->name),
when(when),
frame(getObjectAllocationSite(obj)),
size(JS::ubi::Node(&obj).size(rt->debuggerMallocSizeOf))
{ }
void
Debugger::logTenurePromotion(JSObject& obj, double when)
Debugger::logTenurePromotion(JSRuntime* rt, JSObject& obj, double when)
{
auto* entry = js_new<TenurePromotionsEntry>(obj, when);
auto* entry = js_new<TenurePromotionsEntry>(rt, obj, when);
if (!entry)
CrashAtUnhandlableOOM("Debugger::logTenurePromotion");

View File

@ -269,7 +269,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
return enabled;
}
void logTenurePromotion(JSObject& obj, double when);
void logTenurePromotion(JSRuntime* rt, JSObject& obj, double when);
static JSObject* getObjectAllocationSite(JSObject& obj);
private:
@ -286,15 +286,12 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
struct TenurePromotionsEntry : public mozilla::LinkedListElement<TenurePromotionsEntry>
{
TenurePromotionsEntry(JSObject& obj, double when)
: className(obj.getClass()->name),
when(when),
frame(getObjectAllocationSite(obj))
{ }
TenurePromotionsEntry(JSRuntime* rt, JSObject& obj, double when);
const char* className;
double when;
RelocatablePtrObject frame;
size_t size;
};
using TenurePromotionsLog = mozilla::LinkedList<TenurePromotionsEntry>;

View File

@ -387,6 +387,10 @@ DebuggerMemory::drainTenurePromotionsLog(JSContext* cx, unsigned argc, Value* vp
if (!DefineProperty(cx, obj, cx->names().class_, classNameValue))
return false;
RootedValue sizeValue(cx, NumberValue(entry->size));
if (!DefineProperty(cx, obj, cx->names().size, sizeValue))
return false;
result->setDenseElement(i, ObjectValue(*obj));
// Pop the front queue entry, and delete it immediately, so that