зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1730534) for conflicts with backout of bug 1536061. a=backout
Backed out changeset fc881c57d119 (bug 1730534) Backed out changeset 0f72a8c5f8c5 (bug 1730534) Backed out changeset 007cbeea4325 (bug 1730534) Backed out changeset 83d53ed76e0f (bug 1730534)
This commit is contained in:
Родитель
77d39d312e
Коммит
248c0cd8b6
|
@ -289,11 +289,7 @@ class SegmentedVector : private AllocPolicy {
|
|||
}
|
||||
|
||||
public:
|
||||
bool Done() const {
|
||||
MOZ_ASSERT_IF(mSegment, mSegment->isInList());
|
||||
MOZ_ASSERT_IF(mSegment, mIndex < mSegment->Length());
|
||||
return !mSegment;
|
||||
}
|
||||
bool Done() const { return !mSegment; }
|
||||
|
||||
T& Get() {
|
||||
MOZ_ASSERT(!Done());
|
||||
|
|
|
@ -483,57 +483,43 @@ JSHolderMap::Entry::Entry(void* aHolder, nsScriptObjectTracer* aTracer,
|
|||
{
|
||||
}
|
||||
|
||||
void JSHolderMap::EntryVectorIter::Settle() {
|
||||
if (Done()) {
|
||||
return;
|
||||
JSHolderMap::JSHolderMap() : mJSHolderMap(256) {}
|
||||
|
||||
template <typename F>
|
||||
inline void JSHolderMap::ForEach(F&& f, WhichHolders aWhich) {
|
||||
// Multi-zone JS holders must always be considered.
|
||||
ForEach(mAnyZoneJSHolders, f, nullptr);
|
||||
|
||||
for (auto i = mPerZoneJSHolders.modIter(); !i.done(); i.next()) {
|
||||
if (aWhich == HoldersInGrayMarkingZones &&
|
||||
!JS::ZoneIsGrayMarking(i.get().key())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entry* entry = &mIter.Get();
|
||||
EntryVector* holders = i.get().value().get();
|
||||
ForEach(*holders, f, i.get().key());
|
||||
if (holders->IsEmpty()) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
inline void JSHolderMap::ForEach(EntryVector& aJSHolders, const F& f,
|
||||
JS::Zone* aZone) {
|
||||
for (auto iter = aJSHolders.Iter(); !iter.Done(); iter.Next()) {
|
||||
Entry* entry = &iter.Get();
|
||||
|
||||
// If the entry has been cleared, remove it and shrink the vector.
|
||||
if (!entry->mHolder && !mHolderMap.RemoveEntry(mVector, entry)) {
|
||||
// We removed the last entry, so reset the iterator to an empty one.
|
||||
mIter = EntryVector().Iter();
|
||||
MOZ_ASSERT(Done());
|
||||
}
|
||||
if (!entry->mHolder && !RemoveEntry(aJSHolders, entry)) {
|
||||
break; // Removed the last entry.
|
||||
}
|
||||
|
||||
inline JSHolderMap::Iter::Iter(JSHolderMap& aMap, WhichHolders aWhich)
|
||||
: mHolderMap(aMap), mIter(aMap, aMap.mAnyZoneJSHolders) {
|
||||
#ifdef DEBUG
|
||||
MOZ_RELEASE_ASSERT(!mHolderMap.mHasIterator);
|
||||
mHolderMap.mHasIterator = true;
|
||||
#endif
|
||||
|
||||
// Populate vector of zones to iterate after the any-zone holders.
|
||||
for (auto i = aMap.mPerZoneJSHolders.iter(); !i.done(); i.next()) {
|
||||
JS::Zone* zone = i.get().key();
|
||||
if (aWhich == AllHolders || JS::ZoneIsGrayMarking(zone)) {
|
||||
MOZ_ALWAYS_TRUE(mZones.append(zone));
|
||||
MOZ_ASSERT_IF(aZone, entry->mZone == aZone);
|
||||
f(entry->mHolder, entry->mTracer, aZone);
|
||||
}
|
||||
}
|
||||
|
||||
Settle();
|
||||
}
|
||||
|
||||
void JSHolderMap::Iter::Settle() {
|
||||
while (mIter.Done()) {
|
||||
if (mZone && mIter.Vector().IsEmpty()) {
|
||||
mHolderMap.mPerZoneJSHolders.remove(mZone);
|
||||
}
|
||||
|
||||
if (mZones.empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
mZone = mZones.popCopy();
|
||||
EntryVector& vector = *mHolderMap.mPerZoneJSHolders.lookup(mZone)->value();
|
||||
new (&mIter) EntryVectorIter(mHolderMap, vector);
|
||||
}
|
||||
}
|
||||
|
||||
JSHolderMap::JSHolderMap() : mJSHolderMap(256) {}
|
||||
|
||||
bool JSHolderMap::RemoveEntry(EntryVector& aJSHolders, Entry* aEntry) {
|
||||
MOZ_ASSERT(aEntry);
|
||||
MOZ_ASSERT(!aEntry->mHolder);
|
||||
|
@ -772,9 +758,8 @@ size_t CycleCollectedJSRuntime::SizeOfExcludingThis(
|
|||
}
|
||||
|
||||
void CycleCollectedJSRuntime::UnmarkSkippableJSHolders() {
|
||||
for (JSHolderMap::Iter entry(mJSHolders); !entry.Done(); entry.Next()) {
|
||||
entry->mTracer->CanSkip(entry->mHolder, true);
|
||||
}
|
||||
mJSHolders.ForEach([](void* holder, nsScriptObjectTracer* tracer,
|
||||
JS::Zone* zone) { tracer->CanSkip(holder, true); });
|
||||
}
|
||||
|
||||
void CycleCollectedJSRuntime::DescribeGCThing(
|
||||
|
@ -957,10 +942,8 @@ void CycleCollectedJSRuntime::TraverseNativeRoots(
|
|||
// would hurt to do this after the JS holders.
|
||||
TraverseAdditionalNativeRoots(aCb);
|
||||
|
||||
for (JSHolderMap::Iter entry(mJSHolders); !entry.Done(); entry.Next()) {
|
||||
void* holder = entry->mHolder;
|
||||
nsScriptObjectTracer* tracer = entry->mTracer;
|
||||
|
||||
mJSHolders.ForEach(
|
||||
[&aCb](void* holder, nsScriptObjectTracer* tracer, JS::Zone* zone) {
|
||||
bool noteRoot = false;
|
||||
if (MOZ_UNLIKELY(aCb.WantAllTraces())) {
|
||||
noteRoot = true;
|
||||
|
@ -973,7 +956,7 @@ void CycleCollectedJSRuntime::TraverseNativeRoots(
|
|||
if (noteRoot) {
|
||||
aCb.NoteNativeRoot(holder, tracer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -1408,21 +1391,19 @@ void CycleCollectedJSRuntime::TraceNativeGrayRoots(
|
|||
TraceAdditionalNativeGrayRoots(aTracer);
|
||||
|
||||
bool checkSingleZoneHolders = ShouldCheckSingleZoneHolders();
|
||||
for (JSHolderMap::Iter entry(mJSHolders, aWhich); !entry.Done();
|
||||
entry.Next()) {
|
||||
void* holder = entry->mHolder;
|
||||
nsScriptObjectTracer* tracer = entry->mTracer;
|
||||
|
||||
mJSHolders.ForEach(
|
||||
[aTracer, checkSingleZoneHolders](
|
||||
void* holder, nsScriptObjectTracer* tracer, JS::Zone* zone) {
|
||||
#ifdef CHECK_SINGLE_ZONE_JS_HOLDERS
|
||||
if (checkSingleZoneHolders && !tracer->IsMultiZoneJSHolder()) {
|
||||
CheckHolderIsSingleZone(holder, tracer, entry.Zone());
|
||||
CheckHolderIsSingleZone(holder, tracer, zone);
|
||||
}
|
||||
#else
|
||||
Unused << checkSingleZoneHolders;
|
||||
#endif
|
||||
|
||||
tracer->Trace(holder, JsGcTracer(), aTracer);
|
||||
}
|
||||
},
|
||||
aWhich);
|
||||
}
|
||||
|
||||
void CycleCollectedJSRuntime::AddJSHolder(void* aHolder,
|
||||
|
|
|
@ -90,13 +90,11 @@ class JSHolderMap {
|
|||
public:
|
||||
enum WhichHolders { AllHolders, HoldersInGrayMarkingZones };
|
||||
|
||||
class Iter;
|
||||
|
||||
JSHolderMap();
|
||||
|
||||
#ifdef DEBUG
|
||||
~JSHolderMap() { MOZ_RELEASE_ASSERT(!mHasIterator); }
|
||||
#endif
|
||||
// Call functor |f| for each holder.
|
||||
template <typename F>
|
||||
void ForEach(F&& f, WhichHolders aWhich = AllHolders);
|
||||
|
||||
bool Has(void* aHolder) const;
|
||||
nsScriptObjectTracer* Get(void* aHolder) const;
|
||||
|
@ -126,7 +124,8 @@ class JSHolderMap {
|
|||
mozilla::HashMap<JS::Zone*, UniquePtr<EntryVector>,
|
||||
DefaultHasher<JS::Zone*>, InfallibleAllocPolicy>;
|
||||
|
||||
class EntryVectorIter;
|
||||
template <typename F>
|
||||
void ForEach(EntryVector& aJSHolders, const F& f, JS::Zone* aZone);
|
||||
|
||||
bool RemoveEntry(EntryVector& aJSHolders, Entry* aEntry);
|
||||
|
||||
|
@ -143,73 +142,6 @@ class JSHolderMap {
|
|||
// Currently this will only contain wrapper cache wrappers since these are the
|
||||
// only holders to pass a zone parameter through to AddJSHolder.
|
||||
EntryVectorMap mPerZoneJSHolders;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Iterators can mutate the element vectors by removing stale elements. Allow
|
||||
// at most one to exist at a time.
|
||||
bool mHasIterator = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
// An iterator over an EntryVector that skips over removed entries and removes
|
||||
// them from the map.
|
||||
class JSHolderMap::EntryVectorIter {
|
||||
public:
|
||||
EntryVectorIter(JSHolderMap& aMap, EntryVector& aVector)
|
||||
: mHolderMap(aMap), mVector(aVector), mIter(aVector.Iter()) {
|
||||
Settle();
|
||||
}
|
||||
|
||||
const EntryVector& Vector() const { return mVector; }
|
||||
|
||||
bool Done() const { return mIter.Done(); }
|
||||
const Entry& Get() const { return mIter.Get(); }
|
||||
void Next() {
|
||||
mIter.Next();
|
||||
Settle();
|
||||
}
|
||||
|
||||
operator const Entry*() const { return &Get(); }
|
||||
const Entry* operator->() const { return &Get(); }
|
||||
|
||||
private:
|
||||
void Settle();
|
||||
|
||||
JSHolderMap& mHolderMap;
|
||||
EntryVector& mVector;
|
||||
EntryVector::IterImpl mIter;
|
||||
};
|
||||
|
||||
class JSHolderMap::Iter {
|
||||
public:
|
||||
explicit Iter(JSHolderMap& aMap, WhichHolders aWhich = AllHolders);
|
||||
|
||||
#ifdef DEBUG
|
||||
~Iter() {
|
||||
MOZ_RELEASE_ASSERT(mHolderMap.mHasIterator);
|
||||
mHolderMap.mHasIterator = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Done() const { return mIter.Done(); }
|
||||
const Entry& Get() const { return mIter.Get(); }
|
||||
void Next() {
|
||||
mIter.Next();
|
||||
Settle();
|
||||
}
|
||||
|
||||
operator const Entry*() const { return &Get(); }
|
||||
const Entry* operator->() const { return &Get(); }
|
||||
|
||||
JS::Zone* Zone() const { return mZone; }
|
||||
|
||||
private:
|
||||
void Settle();
|
||||
|
||||
JSHolderMap& mHolderMap;
|
||||
Vector<JS::Zone*, 1, InfallibleAllocPolicy> mZones;
|
||||
JS::Zone* mZone = nullptr;
|
||||
EntryVectorIter mIter;
|
||||
};
|
||||
|
||||
class CycleCollectedJSRuntime {
|
||||
|
|
Загрузка…
Ссылка в новой задаче