зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1846835 - Part 2: Also assert that other callbacks are found when removal requested r=sfink
Depends on D185306 Differential Revision: https://phabricator.services.mozilla.com/D185307
This commit is contained in:
Родитель
6dcaa59099
Коммит
7516a36349
|
@ -1379,21 +1379,38 @@ bool GCRuntime::updateMarkersVector() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
static bool EraseCallback(CallbackVector<F>& vector, F callback) {
|
||||||
|
for (Callback<F>* p = vector.begin(); p != vector.end(); p++) {
|
||||||
|
if (p->op == callback) {
|
||||||
|
vector.erase(p);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
static bool EraseCallback(CallbackVector<F>& vector, F callback, void* data) {
|
||||||
|
for (Callback<F>* p = vector.begin(); p != vector.end(); p++) {
|
||||||
|
if (p->op == callback && p->data == data) {
|
||||||
|
vector.erase(p);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GCRuntime::addBlackRootsTracer(JSTraceDataOp traceOp, void* data) {
|
bool GCRuntime::addBlackRootsTracer(JSTraceDataOp traceOp, void* data) {
|
||||||
AssertHeapIsIdle();
|
AssertHeapIsIdle();
|
||||||
return !!blackRootTracers.ref().append(
|
return blackRootTracers.ref().append(Callback<JSTraceDataOp>(traceOp, data));
|
||||||
Callback<JSTraceDataOp>(traceOp, data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCRuntime::removeBlackRootsTracer(JSTraceDataOp traceOp, void* data) {
|
void GCRuntime::removeBlackRootsTracer(JSTraceDataOp traceOp, void* data) {
|
||||||
// Can be called from finalizers
|
// Can be called from finalizers
|
||||||
for (size_t i = 0; i < blackRootTracers.ref().length(); i++) {
|
MOZ_ALWAYS_TRUE(EraseCallback(blackRootTracers.ref(), traceOp));
|
||||||
Callback<JSTraceDataOp>* e = &blackRootTracers.ref()[i];
|
|
||||||
if (e->op == traceOp && e->data == data) {
|
|
||||||
blackRootTracers.ref().erase(e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCRuntime::setGrayRootsTracer(JSGrayRootsTracer traceOp, void* data) {
|
void GCRuntime::setGrayRootsTracer(JSGrayRootsTracer traceOp, void* data) {
|
||||||
|
@ -1435,30 +1452,8 @@ bool GCRuntime::addFinalizeCallback(JSFinalizeCallback callback, void* data) {
|
||||||
Callback<JSFinalizeCallback>(callback, data));
|
Callback<JSFinalizeCallback>(callback, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename F>
|
|
||||||
static void EraseCallback(CallbackVector<F>& vector, F callback) {
|
|
||||||
for (Callback<F>* p = vector.begin(); p != vector.end(); p++) {
|
|
||||||
if (p->op == callback) {
|
|
||||||
vector.erase(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename F>
|
|
||||||
static bool EraseCallback(CallbackVector<F>& vector, F callback, void* data) {
|
|
||||||
for (Callback<F>* p = vector.begin(); p != vector.end(); p++) {
|
|
||||||
if (p->op == callback && p->data == data) {
|
|
||||||
vector.erase(p);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GCRuntime::removeFinalizeCallback(JSFinalizeCallback callback) {
|
void GCRuntime::removeFinalizeCallback(JSFinalizeCallback callback) {
|
||||||
EraseCallback(finalizeCallbacks.ref(), callback);
|
MOZ_ALWAYS_TRUE(EraseCallback(finalizeCallbacks.ref(), callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCRuntime::callFinalizeCallbacks(JS::GCContext* gcx,
|
void GCRuntime::callFinalizeCallbacks(JS::GCContext* gcx,
|
||||||
|
@ -1490,7 +1485,8 @@ bool GCRuntime::addWeakPointerZonesCallback(JSWeakPointerZonesCallback callback,
|
||||||
|
|
||||||
void GCRuntime::removeWeakPointerZonesCallback(
|
void GCRuntime::removeWeakPointerZonesCallback(
|
||||||
JSWeakPointerZonesCallback callback) {
|
JSWeakPointerZonesCallback callback) {
|
||||||
EraseCallback(updateWeakPointerZonesCallbacks.ref(), callback);
|
MOZ_ALWAYS_TRUE(
|
||||||
|
EraseCallback(updateWeakPointerZonesCallbacks.ref(), callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCRuntime::callWeakPointerZonesCallbacks(JSTracer* trc) const {
|
void GCRuntime::callWeakPointerZonesCallbacks(JSTracer* trc) const {
|
||||||
|
@ -1507,7 +1503,8 @@ bool GCRuntime::addWeakPointerCompartmentCallback(
|
||||||
|
|
||||||
void GCRuntime::removeWeakPointerCompartmentCallback(
|
void GCRuntime::removeWeakPointerCompartmentCallback(
|
||||||
JSWeakPointerCompartmentCallback callback) {
|
JSWeakPointerCompartmentCallback callback) {
|
||||||
EraseCallback(updateWeakPointerCompartmentCallbacks.ref(), callback);
|
MOZ_ALWAYS_TRUE(
|
||||||
|
EraseCallback(updateWeakPointerCompartmentCallbacks.ref(), callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCRuntime::callWeakPointerCompartmentCallbacks(
|
void GCRuntime::callWeakPointerCompartmentCallbacks(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче