mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 754495, part 1: add JS hooks for compartment CC scanning. r=billm
This commit is contained in:
parent
f52ff46322
commit
95b6a8b9fd
@ -465,6 +465,23 @@ js::GCThingIsMarkedGray(void *thing)
|
||||
return reinterpret_cast<gc::Cell *>(thing)->isMarked(gc::GRAY);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSCompartment*)
|
||||
js::GetGCThingCompartment(void *thing)
|
||||
{
|
||||
JS_ASSERT(thing);
|
||||
return reinterpret_cast<gc::Cell *>(thing)->compartment();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::VisitGrayWrapperTargets(JSCompartment *comp, GCThingCallback *callback, void *closure)
|
||||
{
|
||||
for (WrapperMap::Enum e(comp->crossCompartmentWrappers); !e.empty(); e.popFront()) {
|
||||
gc::Cell *thing = e.front().key.wrapped;
|
||||
if (thing->isMarked(gc::GRAY))
|
||||
callback(closure, thing);
|
||||
}
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallback callback)
|
||||
{
|
||||
|
@ -256,6 +256,15 @@ TraceWeakMaps(WeakMapTracer *trc);
|
||||
extern JS_FRIEND_API(bool)
|
||||
GCThingIsMarkedGray(void *thing);
|
||||
|
||||
extern JS_FRIEND_API(JSCompartment*)
|
||||
GetGCThingCompartment(void *thing);
|
||||
|
||||
typedef void
|
||||
(GCThingCallback)(void *closure, void *gcthing);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
VisitGrayWrapperTargets(JSCompartment *comp, GCThingCallback *callback, void *closure);
|
||||
|
||||
/*
|
||||
* Shadow declarations of JS internal structures, for access by inline access
|
||||
* functions below. Do not use these structures in any other way. When adding
|
||||
|
@ -4075,6 +4075,29 @@ IterateCells(JSRuntime *rt, JSCompartment *compartment, AllocKind thingKind,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IterateGrayObjects(JSCompartment *compartment, GCThingCallback *cellCallback, void *data)
|
||||
{
|
||||
JS_ASSERT(compartment);
|
||||
JSRuntime *rt = compartment->rt;
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
||||
AutoLockGC lock(rt);
|
||||
AutoHeapSession session(rt);
|
||||
rt->gcHelperThread.waitBackgroundSweepEnd();
|
||||
AutoUnlockGC unlock(rt);
|
||||
|
||||
AutoCopyFreeListToArenas copy(rt);
|
||||
|
||||
for (size_t finalizeKind = 0; finalizeKind <= FINALIZE_OBJECT_LAST; finalizeKind++) {
|
||||
for (CellIterUnderGC i(compartment, AllocKind(finalizeKind)); !i.done(); i.next()) {
|
||||
Cell *cell = i.getCell();
|
||||
if (cell->isMarked(GRAY))
|
||||
cellCallback(data, cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace gc {
|
||||
|
||||
JSCompartment *
|
||||
|
@ -1035,6 +1035,12 @@ extern JS_FRIEND_API(void)
|
||||
IterateCells(JSRuntime *rt, JSCompartment *compartment, gc::AllocKind thingKind,
|
||||
void *data, IterateCellCallback cellCallback);
|
||||
|
||||
/*
|
||||
* Invoke cellCallback on every gray JS_OBJECT in the given compartment.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
IterateGrayObjects(JSCompartment *compartment, GCThingCallback *cellCallback, void *data);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
extern void
|
||||
|
Loading…
Reference in New Issue
Block a user