mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1714561 - Allow single-zone JS holders to contain pointers into the atoms zone r=mccr8,sfink
Differential Revision: https://phabricator.services.mozilla.com/D116848
This commit is contained in:
parent
6de5f47867
commit
39dcc0ea21
@ -1172,6 +1172,8 @@ extern JS_PUBLIC_API void SetHostCleanupFinalizationRegistryCallback(
|
|||||||
extern JS_PUBLIC_API void ClearKeptObjects(JSContext* cx);
|
extern JS_PUBLIC_API void ClearKeptObjects(JSContext* cx);
|
||||||
|
|
||||||
extern JS_PUBLIC_API bool ZoneIsCollecting(Zone* zone);
|
extern JS_PUBLIC_API bool ZoneIsCollecting(Zone* zone);
|
||||||
|
extern JS_PUBLIC_API bool AtomsZoneIsCollecting(JSRuntime* runtime);
|
||||||
|
extern JS_PUBLIC_API bool IsAtomsZone(Zone* zone);
|
||||||
|
|
||||||
} // namespace JS
|
} // namespace JS
|
||||||
|
|
||||||
|
@ -1368,6 +1368,14 @@ JS_PUBLIC_API bool JS::ZoneIsCollecting(JS::Zone* zone) {
|
|||||||
return zone->wasGCStarted();
|
return zone->wasGCStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS_PUBLIC_API bool JS::AtomsZoneIsCollecting(JSRuntime* runtime) {
|
||||||
|
return runtime->activeGCInAtomsZone();
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_PUBLIC_API bool JS::IsAtomsZone(JS::Zone* zone) {
|
||||||
|
return zone->isAtomsZone();
|
||||||
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS_AddWeakPointerZonesCallback(JSContext* cx,
|
JS_PUBLIC_API bool JS_AddWeakPointerZonesCallback(JSContext* cx,
|
||||||
JSWeakPointerZonesCallback cb,
|
JSWeakPointerZonesCallback cb,
|
||||||
void* data) {
|
void* data) {
|
||||||
|
@ -971,7 +971,14 @@ void CycleCollectedJSRuntime::TraceGrayJS(JSTracer* aTracer, void* aData) {
|
|||||||
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
|
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
|
||||||
|
|
||||||
// Mark these roots as gray so the CC can walk them later.
|
// Mark these roots as gray so the CC can walk them later.
|
||||||
self->TraceNativeGrayRoots(aTracer, JSHolderMap::HoldersInCollectingZones);
|
|
||||||
|
JSHolderMap::WhichHolders which = JSHolderMap::HoldersInCollectingZones;
|
||||||
|
if (JS::AtomsZoneIsCollecting(self->Runtime())) {
|
||||||
|
// Any holder may point into the atoms zone.
|
||||||
|
which = JSHolderMap::AllHolders;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->TraceNativeGrayRoots(aTracer, which);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
@ -1268,6 +1275,11 @@ struct CheckZoneTracer : public TraceCallbacks {
|
|||||||
: mClassName(aClassName), mZone(aZone) {}
|
: mClassName(aClassName), mZone(aZone) {}
|
||||||
|
|
||||||
void checkZone(JS::Zone* aZone, const char* aName) const {
|
void checkZone(JS::Zone* aZone, const char* aName) const {
|
||||||
|
if (JS::IsAtomsZone(aZone)) {
|
||||||
|
// Any holder may contain pointers into the atoms zone.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mZone) {
|
if (!mZone) {
|
||||||
mZone = aZone;
|
mZone = aZone;
|
||||||
return;
|
return;
|
||||||
@ -1277,9 +1289,12 @@ struct CheckZoneTracer : public TraceCallbacks {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Most JS holders only contain pointers to GC things in a single zone. In
|
// Most JS holders only contain pointers to GC things in a single zone. We
|
||||||
// the future this will allow us to improve GC performance by only tracing
|
// group holders by referent zone where possible, allowing us to improve GC
|
||||||
// holders in zones that are being collected.
|
// performance by only tracing holders for zones that are being collected.
|
||||||
|
//
|
||||||
|
// Additionally, pointers from any holder into the atoms zone are allowed
|
||||||
|
// since all holders are traced when we collect the atoms zone.
|
||||||
//
|
//
|
||||||
// If you added a holder that has pointers into multiple zones please try to
|
// If you added a holder that has pointers into multiple zones please try to
|
||||||
// remedy this. Some options are:
|
// remedy this. Some options are:
|
||||||
@ -1306,7 +1321,7 @@ struct CheckZoneTracer : public TraceCallbacks {
|
|||||||
void* aClosure) const override {
|
void* aClosure) const override {
|
||||||
jsid id = aPtr->unbarrieredGet();
|
jsid id = aPtr->unbarrieredGet();
|
||||||
if (id.isGCThing()) {
|
if (id.isGCThing()) {
|
||||||
checkZone(JS::GetTenuredGCThingZone(id.toGCCellPtr()), aName);
|
MOZ_ASSERT(JS::IsAtomsZone(JS::GetTenuredGCThingZone(id.toGCCellPtr())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
|
virtual void Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
|
||||||
|
@ -872,8 +872,8 @@ T* DowncastCCParticipant(void* aPtr) {
|
|||||||
_class::NS_CYCLE_COLLECTION_INNERCLASS _class::NS_CYCLE_COLLECTION_INNERNAME;
|
_class::NS_CYCLE_COLLECTION_INNERCLASS _class::NS_CYCLE_COLLECTION_INNERNAME;
|
||||||
|
|
||||||
// Most JS holder classes should only contain pointers to JS GC things in a
|
// Most JS holder classes should only contain pointers to JS GC things in a
|
||||||
// single JS zone, but there are some exceptions. Such classes should use this
|
// single JS zone (excluding pointers into the atoms zone), but there are some
|
||||||
// macro to tell the system about this.
|
// exceptions. Such classes should use this macro to tell the system about this.
|
||||||
#define NS_IMPL_CYCLE_COLLECTION_MULTI_ZONE_JSHOLDER_CLASS(_class) \
|
#define NS_IMPL_CYCLE_COLLECTION_MULTI_ZONE_JSHOLDER_CLASS(_class) \
|
||||||
_class::NS_CYCLE_COLLECTION_INNERCLASS \
|
_class::NS_CYCLE_COLLECTION_INNERCLASS \
|
||||||
_class::NS_CYCLE_COLLECTION_INNERNAME( \
|
_class::NS_CYCLE_COLLECTION_INNERNAME( \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user