зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1587378 - Remove TraceCallbacks method that takes raw JSObject pointers r=mccr8
This method turned out to only be used for tracing wrapper cached things. The wrapper cache has its own way of implementing barriers and contains a raw JSObject pointer. Changing this trace method to take an nsWrapperCache pointer (effectively a JSObjct**) enforces correct use of Heap<T> for other TraceCallbacks callers. Differential Revision: https://phabricator.services.mozilla.com/D48693 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ff95dca4e6
Коммит
58e4c9be34
|
@ -232,7 +232,7 @@ class nsWrapperCache {
|
|||
|
||||
void TraceWrapper(const TraceCallbacks& aCallbacks, void* aClosure) {
|
||||
if (PreservingWrapper() && mWrapper) {
|
||||
aCallbacks.Trace(&mWrapper, "Preserved wrapper", aClosure);
|
||||
aCallbacks.Trace(this, "Preserved wrapper", aClosure);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,13 +304,13 @@ class nsWrapperCache {
|
|||
|
||||
void ReleaseWrapper(void* aScriptObjectHolder);
|
||||
|
||||
protected:
|
||||
void TraceWrapper(JSTracer* aTrc, const char* name) {
|
||||
if (mWrapper) {
|
||||
js::UnsafeTraceManuallyBarrieredEdge(aTrc, &mWrapper, name);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void PoisonWrapper() {
|
||||
if (mWrapper) {
|
||||
// Set the pointer to a value that will cause a crash if it is
|
||||
|
|
|
@ -985,10 +985,9 @@ struct JsGcTracer : public TraceCallbacks {
|
|||
void* aClosure) const override {
|
||||
JS::TraceEdge(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JSObject** aPtr, const char* aName,
|
||||
virtual void Trace(nsWrapperCache* aPtr, const char* aName,
|
||||
void* aClosure) const override {
|
||||
js::UnsafeTraceManuallyBarrieredEdge(static_cast<JSTracer*>(aClosure), aPtr,
|
||||
aName);
|
||||
aPtr->TraceWrapper(static_cast<JSTracer*>(aClosure), aName);
|
||||
}
|
||||
virtual void Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const override {
|
||||
|
@ -1055,9 +1054,9 @@ struct ClearJSHolder : public TraceCallbacks {
|
|||
*aPtr = nullptr;
|
||||
}
|
||||
|
||||
virtual void Trace(JSObject** aPtr, const char* aName,
|
||||
virtual void Trace(nsWrapperCache* aPtr, const char* aName,
|
||||
void* aClosure) const override {
|
||||
*aPtr = nullptr;
|
||||
aPtr->ClearWrapper();
|
||||
}
|
||||
|
||||
virtual void Trace(JS::TenuredHeap<JSObject*>* aPtr, const char*,
|
||||
|
|
|
@ -49,6 +49,8 @@ class nsCycleCollectionISupports {
|
|||
NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionISupports,
|
||||
NS_CYCLECOLLECTIONISUPPORTS_IID)
|
||||
|
||||
class nsWrapperCache;
|
||||
|
||||
namespace JS {
|
||||
template <class T>
|
||||
class Heap;
|
||||
|
@ -66,7 +68,7 @@ struct TraceCallbacks {
|
|||
void* aClosure) const = 0;
|
||||
virtual void Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const = 0;
|
||||
virtual void Trace(JSObject** aPtr, const char* aName,
|
||||
virtual void Trace(nsWrapperCache* aPtr, const char* aName,
|
||||
void* aClosure) const = 0;
|
||||
virtual void Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const = 0;
|
||||
|
@ -94,7 +96,7 @@ struct TraceCallbackFunc : public TraceCallbacks {
|
|||
void* aClosure) const override;
|
||||
virtual void Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const override;
|
||||
virtual void Trace(JSObject** aPtr, const char* aName,
|
||||
virtual void Trace(nsWrapperCache* aPtr, const char* aName,
|
||||
void* aClosure) const override;
|
||||
virtual void Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const override;
|
||||
|
|
|
@ -2490,9 +2490,9 @@ class SnowWhiteKiller : public TraceCallbacks {
|
|||
AppendJSObjectToPurpleBuffer(aObject->unbarrieredGet());
|
||||
}
|
||||
|
||||
virtual void Trace(JSObject** aObject, const char* aName,
|
||||
virtual void Trace(nsWrapperCache* aWrapperCache, const char* aName,
|
||||
void* aClosure) const override {
|
||||
AppendJSObjectToPurpleBuffer(*aObject);
|
||||
AppendJSObjectToPurpleBuffer(aWrapperCache->GetWrapperPreserveColor());
|
||||
}
|
||||
|
||||
virtual void Trace(JS::TenuredHeap<JSObject*>* aObject, const char* aName,
|
||||
|
|
|
@ -50,10 +50,11 @@ void TraceCallbackFunc::Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
|
|||
}
|
||||
}
|
||||
|
||||
void TraceCallbackFunc::Trace(JSObject** aPtr, const char* aName,
|
||||
void TraceCallbackFunc::Trace(nsWrapperCache* aPtr, const char* aName,
|
||||
void* aClosure) const {
|
||||
if (*aPtr) {
|
||||
mCallback(JS::GCCellPtr(*aPtr), aName, aClosure);
|
||||
JSObject* obj = aPtr->GetWrapperPreserveColor();
|
||||
if (obj) {
|
||||
mCallback(JS::GCCellPtr(obj), aName, aClosure);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче