Backed out 4 changesets (bug 1943811) for causing hazard bustages. CLOSED TREE

Backed out changeset d676336db245 (bug 1943811)
Backed out changeset 2f56a6399ae7 (bug 1943811)
Backed out changeset 8146656f4566 (bug 1943811)
Backed out changeset 2eceb546abd2 (bug 1943811)
This commit is contained in:
Goloman Adrian
2025-03-12 01:16:56 +02:00
parent e8548b74b4
commit 595de0c837
14 changed files with 39 additions and 131 deletions

View File

@@ -3041,8 +3041,13 @@ struct DeferredFinalizerImpl {
static bool DeferredFinalize(uint32_t aSlice, void* aData) {
MOZ_ASSERT(aSlice > 0, "nonsensical/useless call with aSlice == 0");
SmartPtrArray* pointers = static_cast<SmartPtrArray*>(aData);
uint32_t oldLen = pointers->Length();
if (oldLen < aSlice) {
aSlice = oldLen;
}
uint32_t newLen = oldLen - aSlice;
pointers->PopLastN(aSlice);
if (pointers->IsEmpty()) {
if (newLen == 0) {
delete pointers;
return true;
}

View File

@@ -413,6 +413,10 @@ DOMInterfaces = {
'headerFile': 'IDBEvents.h',
},
'ImageData': {
'wrapperCache': False,
},
'InspectorFontFace': {
'wrapperCache': False,
},

View File

@@ -6307,7 +6307,7 @@ already_AddRefed<ImageData> CanvasRenderingContext2D::GetImageData(
return nullptr;
}
MOZ_ASSERT(array);
return MakeAndAddRef<ImageData>(GetParentObject(), w, h, *array);
return MakeAndAddRef<ImageData>(w, h, *array);
}
static IntRect ClipImageDataTransfer(IntRect& aSrc, const IntPoint& aDestOffset,
@@ -6650,7 +6650,7 @@ static already_AddRefed<ImageData> CreateImageData(
return nullptr;
}
return do_AddRef(new ImageData(aContext->GetParentObject(), aW, aH, *darray));
return do_AddRef(new ImageData(aW, aH, *darray));
}
already_AddRefed<ImageData> CanvasRenderingContext2D::CreateImageData(

View File

@@ -22,45 +22,25 @@
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTING_ADDREF(ImageData)
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(ImageData, DropData())
NS_IMPL_CYCLE_COLLECTING_RELEASE(ImageData)
NS_IMPL_CYCLE_COLLECTION_CLASS(ImageData)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ImageData)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ImageData)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mData)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ImageData)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ImageData)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->DropData();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(ImageData)
if (tmp->HasKnownLiveWrapper()) {
tmp->mData.exposeToActiveJS();
return true;
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(ImageData)
return tmp->HasKnownLiveWrapper() && tmp->HasNothingToTrace(tmp);
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(ImageData)
return tmp->HasKnownLiveWrapper();
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
// static
already_AddRefed<ImageData> ImageData::Constructor(const GlobalObject& aGlobal,
const uint32_t aWidth,
@@ -83,8 +63,7 @@ already_AddRefed<ImageData> ImageData::Constructor(const GlobalObject& aGlobal,
if (aRv.Failed()) {
return nullptr;
}
RefPtr<ImageData> imageData =
new ImageData(aGlobal.GetAsSupports(), aWidth, aHeight, *data);
RefPtr<ImageData> imageData = new ImageData(aWidth, aHeight, *data);
return imageData.forget();
}
@@ -113,8 +92,7 @@ already_AddRefed<ImageData> ImageData::Constructor(
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr;
}
RefPtr<ImageData> imageData =
new ImageData(aGlobal.GetAsSupports(), aWidth, height, *aData.Obj());
RefPtr<ImageData> imageData = new ImageData(aWidth, height, *aData.Obj());
return imageData.forget();
}
@@ -122,14 +100,13 @@ void ImageData::HoldData() { mozilla::HoldJSObjects(this); }
void ImageData::DropData() {
if (mData) {
mData = nullptr;
mozilla::DropJSObjects(this);
}
}
JSObject* ImageData::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return ImageData_Binding::Wrap(aCx, this, aGivenProto);
bool ImageData::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
JS::MutableHandle<JSObject*> aReflector) {
return ImageData_Binding::Wrap(aCx, this, aGivenProto, aReflector);
}
// static
@@ -146,7 +123,7 @@ already_AddRefed<ImageData> ImageData::ReadStructuredClone(
MOZ_ASSERT(dataArray.isObject());
RefPtr<ImageData> imageData =
new ImageData(aGlobal, width, height, dataArray.toObject());
new ImageData(width, height, dataArray.toObject());
return imageData.forget();
}

View File

@@ -15,7 +15,6 @@
#include "mozilla/dom/TypedArray.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
class JSObject;
class nsIGlobalObject;
@@ -32,20 +31,23 @@ class GlobalObject;
template <typename T>
class Optional;
// ImageData extends nsWrapperCache only to support nursery allocated wrapper.
class ImageData final : public nsISupports, public nsWrapperCache {
class ImageData final : public nsISupports {
public:
ImageData(nsISupports* aOwner, uint32_t aWidth, uint32_t aHeight,
JSObject& aData)
: mOwner(aOwner), mWidth(aWidth), mHeight(aHeight), mData(&aData) {
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
const uint32_t mWidth;
const uint32_t mHeight;
private:
JS::Heap<JSObject*> mData;
public:
ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
: mWidth(aWidth), mHeight(aHeight), mData(&aData) {
HoldData();
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(ImageData)
nsISupports* GetParentObject() const { return mOwner; }
static already_AddRefed<ImageData> Constructor(const GlobalObject& aGlobal,
const uint32_t aWidth,
const uint32_t aHeight,
@@ -63,7 +65,8 @@ class ImageData final : public nsISupports, public nsWrapperCache {
}
JSObject* GetDataObject() const { return mData; }
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
JS::MutableHandle<JSObject*> aReflector);
//[Serializable] implementation
static already_AddRefed<ImageData> ReadStructuredClone(
@@ -78,13 +81,6 @@ class ImageData final : public nsISupports, public nsWrapperCache {
ImageData() = delete;
~ImageData() { DropData(); }
nsCOMPtr<nsISupports> mOwner;
const uint32_t mWidth;
const uint32_t mHeight;
JS::Heap<JSObject*> mData;
};
} // namespace dom

View File

@@ -11,7 +11,7 @@
*/
[Exposed=(Window,Worker),
Serializable, ProbablyShortLivingWrapper]
Serializable]
interface ImageData {
[Throws]
constructor(unsigned long sw, unsigned long sh);

View File

@@ -224,8 +224,10 @@ class SegmentedVector : private AllocPolicy {
}
// Equivalent to calling |PopLast| |aNumElements| times, but potentially
// more efficient. It is safe to call this even when aNumElements > Length().
// more efficient.
void PopLastN(uint32_t aNumElements) {
MOZ_ASSERT(aNumElements <= Length());
Segment* last;
// Pop full segments for as long as we can. Note that this loop

View File

@@ -110,23 +110,6 @@ void TestBasics() {
// Verify the contents are what we expect.
CheckContents(v, 700);
// Verify PopLastN can take larger than .Length() value as an argument.
v.PopLastN(1000);
MOZ_RELEASE_ASSERT(v.Length() == 0);
MOZ_RELEASE_ASSERT(v.IsEmpty());
// Fill the vector again.
for (i = 0; i < 1000; ++i) {
v.InfallibleAppend(std::move(i));
}
MOZ_RELEASE_ASSERT(!v.IsEmpty());
MOZ_RELEASE_ASSERT(v.Length() == 1000);
// Verify that calling PopLastN with Length() empties the vector.
v.PopLastN(v.Length());
MOZ_RELEASE_ASSERT(v.Length() == 0);
MOZ_RELEASE_ASSERT(v.IsEmpty());
}
void TestMoveAndSwap() {

View File

@@ -563,9 +563,6 @@ void CycleCollectedJSContext::AfterProcessTask(uint32_t aRecursionDepth) {
// This should be a fast test so that it won't affect the next task
// processing.
MaybePokeGC();
mRuntime->FinalizeDeferredThings(CycleCollectedJSRuntime::FinalizeNow);
nsCycleCollector_maybeDoDeferredDeletion();
}
void CycleCollectedJSContext::AfterProcessMicrotasks() {

View File

@@ -1598,10 +1598,6 @@ void CycleCollectedJSRuntime::JSObjectsTenured(JS::GCContext* aGCContext) {
mNurseryObjects.InfallibleAppend(cache);
}
}
if (!mFinalizeRunnable) {
FinalizeDeferredThings(FinalizeIncrementally);
}
}
void CycleCollectedJSRuntime::NurseryWrapperAdded(nsWrapperCache* aCache) {

View File

@@ -1160,11 +1160,6 @@ class nsCycleCollector : public nsIMemoryReporter {
uint32_t mWhiteNodeCount;
// Note, this counter may not be exact if some object has its
// reference count increased from zero or if we're doing incremental
// snow white releasing.
uint32_t mKnownSnowWhiteCount;
CC_BeforeUnlinkCallback mBeforeUnlinkCB;
CC_ForgetSkippableCallback mForgetSkippableCB;
@@ -1203,12 +1198,6 @@ class nsCycleCollector : public nsIMemoryReporter {
bool aAsyncSnowWhiteFreeing);
bool FreeSnowWhite(bool aUntilNoSWInPurpleBuffer);
bool FreeSnowWhiteWithBudget(SliceBudget& aBudget);
bool MaybeFreeSnowWhite() {
if ((mKnownSnowWhiteCount * 2) > SuspectedCount()) {
return FreeSnowWhite(false);
}
return false;
}
// This method assumes its argument is already canonicalized.
void RemoveObjectFromGraph(void* aPtr);
@@ -1232,8 +1221,6 @@ class nsCycleCollector : public nsIMemoryReporter {
CycleCollectedJSRuntime* Runtime() { return mCCJSRuntime; }
void NewSnowWhiteObjectAdded() { ++mKnownSnowWhiteCount; }
private:
void CheckThreadSafety();
MOZ_CAN_RUN_SCRIPT
@@ -2810,7 +2797,6 @@ bool nsCycleCollector::FreeSnowWhite(bool aUntilNoSWInPurpleBuffer) {
AutoRestore<bool> ar(mFreeingSnowWhite);
mFreeingSnowWhite = true;
mKnownSnowWhiteCount = 0;
bool hadSnowWhiteObjects = false;
do {
@@ -2834,7 +2820,6 @@ bool nsCycleCollector::FreeSnowWhiteWithBudget(SliceBudget& aBudget) {
AUTO_PROFILER_LABEL_CATEGORY_PAIR(GCCC_FreeSnowWhite);
AutoRestore<bool> ar(mFreeingSnowWhite);
mFreeingSnowWhite = true;
mKnownSnowWhiteCount = 0;
SnowWhiteKiller visitor(this, &aBudget);
mPurpleBuf.VisitEntries(visitor);
@@ -2858,9 +2843,6 @@ void nsCycleCollector::ForgetSkippable(SliceBudget& aBudget,
if (mCCJSRuntime) {
mCCJSRuntime->PrepareForForgetSkippable();
}
mKnownSnowWhiteCount = 0;
MOZ_ASSERT(
!mScanInProgress,
"Don't forget skippable or free snow-white while scan is in progress.");
@@ -3308,9 +3290,6 @@ bool nsCycleCollector::CollectWhite() {
mIncrementalPhase = CleanupPhase;
// Don't delete snow white objects immediately after unlinking.
mKnownSnowWhiteCount = 0;
return numWhiteNodes > 0 || numWhiteGCed > 0 || numWhiteJSZones > 0;
}
@@ -3363,7 +3342,6 @@ nsCycleCollector::nsCycleCollector()
mEventTarget(GetCurrentSerialEventTarget()),
#endif
mWhiteNodeCount(0),
mKnownSnowWhiteCount(0),
mBeforeUnlinkCB(nullptr),
mForgetSkippableCB(nullptr),
mUnmergedNeeded(0),
@@ -4082,13 +4060,6 @@ void NS_CycleCollectorSuspect3(void* aPtr, nsCycleCollectionParticipant* aCp,
SuspectAfterShutdown(aPtr, aCp, aRefCnt, aShouldDelete);
}
void NS_CycleCollectableHasRefCntZero() {
CollectorData* data = sCollectorData.get();
if (data && data->mCollector) {
data->mCollector->NewSnowWhiteObjectAdded();
}
}
void ClearNurseryPurpleBuffer() {
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
CollectorData* data = sCollectorData.get();
@@ -4196,15 +4167,6 @@ bool nsCycleCollector_doDeferredDeletion() {
return data->mCollector->FreeSnowWhite(false);
}
bool nsCycleCollector_maybeDoDeferredDeletion() {
CollectorData* data = sCollectorData.get();
if (!data || !data->mCollector) {
return false;
}
return data->mCollector->MaybeFreeSnowWhite();
}
bool nsCycleCollector_doDeferredDeletionWithBudget(SliceBudget& aBudget) {
CollectorData* data = sCollectorData.get();

View File

@@ -51,7 +51,6 @@ void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false,
bool aPurge = false);
bool nsCycleCollector_doDeferredDeletion();
bool nsCycleCollector_doDeferredDeletionWithBudget(JS::SliceBudget& aBudget);
bool nsCycleCollector_maybeDoDeferredDeletion();
already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink(
bool aLogGC);

View File

@@ -533,9 +533,6 @@ class InterfaceNeedsThreadSafeRefCnt : public std::false_type {};
nsrefcnt count = \
mRefCnt.decr(static_cast<void*>(this), \
_class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()); \
if (count == 0) { \
NS_CycleCollectableHasRefCntZero(); \
} \
NS_LOG_RELEASE(this, count, #_class); \
return count;
@@ -561,7 +558,6 @@ class InterfaceNeedsThreadSafeRefCnt : public std::false_type {};
_last; \
mRefCnt.decr(static_cast<void*>(this), \
_class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()); \
NS_CycleCollectableHasRefCntZero(); \
if (shouldDelete) { \
mRefCnt.stabilizeForDeletion(); \
DeleteCycleCollectable(); \
@@ -639,7 +635,7 @@ class InterfaceNeedsThreadSafeRefCnt : public std::false_type {};
\
protected: \
nsAutoRefCnt mRefCnt; \
_owning public:
_owning public:
/**
* Use this macro to declare and implement the AddRef & Release methods for a
@@ -961,9 +957,6 @@ void ProxyDeleteVoid(const char* aRunnableName,
NS_ASSERT_OWNINGTHREAD(_class); \
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
nsrefcnt count = mRefCnt.decr(base); \
if (count == 0) { \
NS_CycleCollectableHasRefCntZero(); \
} \
NS_LOG_RELEASE(this, count, #_class); \
return count; \
} \
@@ -986,7 +979,6 @@ void ProxyDeleteVoid(const char* aRunnableName,
mRefCnt.incr(base); \
_last; \
mRefCnt.decr(base); \
NS_CycleCollectableHasRefCntZero(); \
if (shouldDelete) { \
mRefCnt.stabilizeForDeletion(); \
DeleteCycleCollectable(); \
@@ -1011,7 +1003,6 @@ void ProxyDeleteVoid(const char* aRunnableName,
mRefCnt.incr(base); \
_last; \
mRefCnt.decr(base); \
NS_CycleCollectableHasRefCntZero(); \
if (shouldDelete) { \
mRefCnt.stabilizeForDeletion(); \
DeleteCycleCollectable(); \
@@ -1047,7 +1038,6 @@ void ProxyDeleteVoid(const char* aRunnableName,
MOZ_ASSERT(mRefCnt.get() > 0); \
return mRefCnt.get(); \
} \
NS_CycleCollectableHasRefCntZero(); \
if (shouldDelete) { \
mRefCnt.stabilizeForDeletion(); \
DeleteCycleCollectable(); \

View File

@@ -355,9 +355,6 @@ NS_CycleCollectorSuspect3(void* aPtr, nsCycleCollectionParticipant* aCp,
nsCycleCollectingAutoRefCnt* aRefCnt,
bool* aShouldDelete);
XPCOM_API(void)
NS_CycleCollectableHasRefCntZero();
#endif
/**