Bug 1118044, part 1 - Use GCCellPtr in CycleCollectedJSRuntime::TraverseGCThing. r=smaug

This commit is contained in:
Andrew McCreight 2015-01-08 15:30:54 -08:00
Родитель 4b9c7c9fe3
Коммит 37e6ea860b
2 изменённых файлов: 18 добавлений и 23 удалений

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

@ -346,8 +346,8 @@ JSGCThingParticipant::Traverse(void* aPtr,
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime,
mGCThingCycleCollectorGlobal));
runtime->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_FULL,
aPtr, js::GCThingTraceKind(aPtr), aCb);
JS::GCCellPtr cellPtr(aPtr, js::GCThingTraceKind(aPtr));
runtime->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_FULL, cellPtr, aCb);
return NS_OK;
}
@ -546,8 +546,7 @@ CycleCollectedJSRuntime::UnmarkSkippableJSHolders()
}
void
CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, void* aThing,
JSGCTraceKind aTraceKind,
CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb) const
{
if (!aCb.WantDebugInfo()) {
@ -557,8 +556,8 @@ CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, void* aThing,
char name[72];
uint64_t compartmentAddress = 0;
if (aTraceKind == JSTRACE_OBJECT) {
JSObject* obj = static_cast<JSObject*>(aThing);
if (aThing.isObject()) {
JSObject* obj = aThing.toObject();
compartmentAddress = (uint64_t)js::GetObjectCompartment(obj);
const js::Class* clasp = js::GetObjectClass(obj);
@ -582,7 +581,7 @@ CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, void* aThing,
JS_snprintf(name, sizeof(name), "JS Object (%s)", clasp->name);
}
} else {
JS_snprintf(name, sizeof(name), "JS %s", JS::GCTraceKindToAscii(aTraceKind));
JS_snprintf(name, sizeof(name), "JS %s", JS::GCTraceKindToAscii(aThing.kind()));
}
// Disable printing global for objects while we figure out ObjShrink fallout.
@ -590,13 +589,12 @@ CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, void* aThing,
}
void
CycleCollectedJSRuntime::NoteGCThingJSChildren(void* aThing,
JSGCTraceKind aTraceKind,
CycleCollectedJSRuntime::NoteGCThingJSChildren(JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb) const
{
MOZ_ASSERT(mJSRuntime);
TraversalTracer trc(mJSRuntime, aCb);
JS_TraceChildren(&trc, aThing, aTraceKind);
JS_TraceChildren(&trc, aThing.asCell(), aThing.kind());
}
void
@ -632,15 +630,13 @@ CycleCollectedJSRuntime::NoteGCThingXPCOMChildren(const js::Class* aClasp,
}
void
CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, void* aThing,
JSGCTraceKind aTraceKind,
CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb)
{
MOZ_ASSERT(aTraceKind == js::GCThingTraceKind(aThing));
bool isMarkedGray = JS::GCThingIsMarkedGray(JS::GCCellPtr(aThing, aTraceKind));
bool isMarkedGray = JS::GCThingIsMarkedGray(aThing);
if (aTs == TRAVERSE_FULL) {
DescribeGCThing(!isMarkedGray, aThing, aTraceKind, aCb);
DescribeGCThing(!isMarkedGray, aThing, aCb);
}
// If this object is alive, then all of its children are alive. For JS objects,
@ -652,11 +648,11 @@ CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, void* aThing,
}
if (aTs == TRAVERSE_FULL) {
NoteGCThingJSChildren(aThing, aTraceKind, aCb);
NoteGCThingJSChildren(aThing, aCb);
}
if (aTraceKind == JSTRACE_OBJECT) {
JSObject* obj = static_cast<JSObject*>(aThing);
if (aThing.isObject()) {
JSObject* obj = aThing.toObject();
NoteGCThingXPCOMChildren(js::GetObjectClass(obj), obj, aCb);
}
}
@ -710,7 +706,7 @@ CycleCollectedJSRuntime::TraverseObjectShim(void* aData, JS::GCCellPtr aThing)
MOZ_ASSERT(aThing.isObject());
closure->self->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_CPP,
aThing.asCell(), JSTRACE_OBJECT, closure->cb);
aThing, closure->cb);
}
void

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

@ -147,7 +147,7 @@ protected:
private:
void
DescribeGCThing(bool aIsMarked, void* aThing, JSGCTraceKind aTraceKind,
DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb) const;
virtual bool
@ -158,7 +158,7 @@ private:
}
void
NoteGCThingJSChildren(void* aThing, JSGCTraceKind aTraceKind,
NoteGCThingJSChildren(JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb) const;
void
@ -178,8 +178,7 @@ private:
};
void
TraverseGCThing(TraverseSelect aTs, void* aThing,
JSGCTraceKind aTraceKind,
TraverseGCThing(TraverseSelect aTs, JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb);
void