зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1736604 - Part 3: Rename MapSweepPolicy to MapEntryGCPolicy r=sfink
It's only used for traceWeak it's true, but it's like a GCPolicy for the map entry itself. Differential Revision: https://phabricator.services.mozilla.com/D128904
This commit is contained in:
Родитель
4514fe83d3
Коммит
be63f8d9df
|
@ -21,7 +21,7 @@ namespace JS {
|
||||||
|
|
||||||
// Define a reasonable default GC policy for GC-aware Maps.
|
// Define a reasonable default GC policy for GC-aware Maps.
|
||||||
template <typename Key, typename Value>
|
template <typename Key, typename Value>
|
||||||
struct DefaultMapSweepPolicy {
|
struct DefaultMapEntryGCPolicy {
|
||||||
static bool traceWeak(JSTracer* trc, Key* key, Value* value) {
|
static bool traceWeak(JSTracer* trc, Key* key, Value* value) {
|
||||||
return GCPolicy<Key>::traceWeak(trc, key) &&
|
return GCPolicy<Key>::traceWeak(trc, key) &&
|
||||||
GCPolicy<Value>::traceWeak(trc, value);
|
GCPolicy<Value>::traceWeak(trc, value);
|
||||||
|
@ -41,13 +41,13 @@ struct DefaultMapSweepPolicy {
|
||||||
// define your own GCPolicy specialization, generic helpers can be found in
|
// define your own GCPolicy specialization, generic helpers can be found in
|
||||||
// js/public/TracingAPI.h.
|
// js/public/TracingAPI.h.
|
||||||
//
|
//
|
||||||
// The MapSweepPolicy template parameter controls how the table drops entries
|
// The MapEntryGCPolicy template parameter controls how the table drops entries
|
||||||
// when edges are weakly held. GCHashMap::traceWeak applies the MapSweepPolicy's
|
// when edges are weakly held. GCHashMap::traceWeak applies the
|
||||||
// traceWeak method to each table entry; if it returns true, the entry is
|
// MapEntryGCPolicy's traceWeak method to each table entry; if it returns true,
|
||||||
// dropped. The default MapSweepPolicy drops the entry if either the key or
|
// the entry is dropped. The default MapEntryGCPolicy drops the entry if either
|
||||||
// value is about to be finalized, according to its GCPolicy<T>::traceWeak
|
// the key or value is about to be finalized, according to its
|
||||||
// method. (This default is almost always fine: it's hard to imagine keeping
|
// GCPolicy<T>::traceWeak method. (This default is almost always fine: it's hard
|
||||||
// such an entry around anyway.)
|
// to imagine keeping such an entry around anyway.)
|
||||||
//
|
//
|
||||||
// Note that this HashMap only knows *how* to trace, but it does not itself
|
// Note that this HashMap only knows *how* to trace, but it does not itself
|
||||||
// cause tracing to be invoked. For tracing, it must be used as
|
// cause tracing to be invoked. For tracing, it must be used as
|
||||||
|
@ -56,12 +56,12 @@ struct DefaultMapSweepPolicy {
|
||||||
template <typename Key, typename Value,
|
template <typename Key, typename Value,
|
||||||
typename HashPolicy = js::DefaultHasher<Key>,
|
typename HashPolicy = js::DefaultHasher<Key>,
|
||||||
typename AllocPolicy = js::TempAllocPolicy,
|
typename AllocPolicy = js::TempAllocPolicy,
|
||||||
typename MapSweepPolicy = DefaultMapSweepPolicy<Key, Value>>
|
typename MapEntryGCPolicy = DefaultMapEntryGCPolicy<Key, Value>>
|
||||||
class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy> {
|
class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy> {
|
||||||
using Base = js::HashMap<Key, Value, HashPolicy, AllocPolicy>;
|
using Base = js::HashMap<Key, Value, HashPolicy, AllocPolicy>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using SweepPolicy = MapSweepPolicy;
|
using EntryGCPolicy = MapEntryGCPolicy;
|
||||||
|
|
||||||
explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(std::move(a)) {}
|
explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(std::move(a)) {}
|
||||||
explicit GCHashMap(size_t length) : Base(length) {}
|
explicit GCHashMap(size_t length) : Base(length) {}
|
||||||
|
@ -82,8 +82,8 @@ class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy> {
|
||||||
|
|
||||||
void traceWeakEntries(JSTracer* trc, typename Base::Enum& e) {
|
void traceWeakEntries(JSTracer* trc, typename Base::Enum& e) {
|
||||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||||
if (!MapSweepPolicy::traceWeak(trc, &e.front().mutableKey(),
|
if (!MapEntryGCPolicy::traceWeak(trc, &e.front().mutableKey(),
|
||||||
&e.front().value())) {
|
&e.front().value())) {
|
||||||
e.removeFront();
|
e.removeFront();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,9 @@ namespace js {
|
||||||
template <typename Key, typename Value,
|
template <typename Key, typename Value,
|
||||||
typename HashPolicy = DefaultHasher<Key>,
|
typename HashPolicy = DefaultHasher<Key>,
|
||||||
typename AllocPolicy = TempAllocPolicy,
|
typename AllocPolicy = TempAllocPolicy,
|
||||||
typename MapSweepPolicy = JS::DefaultMapSweepPolicy<Key, Value>>
|
typename MapEntryGCPolicy = JS::DefaultMapEntryGCPolicy<Key, Value>>
|
||||||
class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy,
|
class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy,
|
||||||
AllocPolicy, MapSweepPolicy> {
|
AllocPolicy, MapEntryGCPolicy> {
|
||||||
using Base = JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy>;
|
using Base = JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -129,7 +129,7 @@ class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy,
|
||||||
bool traceWeak(JSTracer* trc) {
|
bool traceWeak(JSTracer* trc) {
|
||||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||||
Key key(e.front().key());
|
Key key(e.front().key());
|
||||||
if (!MapSweepPolicy::traceWeak(trc, &key, &e.front().value())) {
|
if (!MapEntryGCPolicy::traceWeak(trc, &key, &e.front().value())) {
|
||||||
e.removeFront();
|
e.removeFront();
|
||||||
} else if (!HashPolicy::match(key, e.front().key())) {
|
} else if (!HashPolicy::match(key, e.front().key())) {
|
||||||
e.rekeyFront(key);
|
e.rekeyFront(key);
|
||||||
|
@ -373,10 +373,11 @@ namespace JS {
|
||||||
// Specialize WeakCache for GCHashMap to provide a barriered map that does not
|
// Specialize WeakCache for GCHashMap to provide a barriered map that does not
|
||||||
// need to be swept immediately.
|
// need to be swept immediately.
|
||||||
template <typename Key, typename Value, typename HashPolicy,
|
template <typename Key, typename Value, typename HashPolicy,
|
||||||
typename AllocPolicy, typename MapSweepPolicy>
|
typename AllocPolicy, typename MapEntryGCPolicy>
|
||||||
class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
class WeakCache<
|
||||||
|
GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapEntryGCPolicy>>
|
||||||
final : protected detail::WeakCacheBase {
|
final : protected detail::WeakCacheBase {
|
||||||
using Map = GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>;
|
using Map = GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapEntryGCPolicy>;
|
||||||
using Self = WeakCache<Map>;
|
using Self = WeakCache<Map>;
|
||||||
|
|
||||||
Map map;
|
Map map;
|
||||||
|
@ -426,7 +427,7 @@ class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
||||||
static bool entryNeedsSweep(JSTracer* barrierTracer, const Entry& prior) {
|
static bool entryNeedsSweep(JSTracer* barrierTracer, const Entry& prior) {
|
||||||
Key key(prior.key());
|
Key key(prior.key());
|
||||||
Value value(prior.value());
|
Value value(prior.value());
|
||||||
bool needsSweep = !MapSweepPolicy::traceWeak(barrierTracer, &key, &value);
|
bool needsSweep = !MapEntryGCPolicy::traceWeak(barrierTracer, &key, &value);
|
||||||
MOZ_ASSERT_IF(!needsSweep,
|
MOZ_ASSERT_IF(!needsSweep,
|
||||||
prior.key() == key); // We shouldn't update here.
|
prior.key() == key); // We shouldn't update here.
|
||||||
MOZ_ASSERT_IF(!needsSweep,
|
MOZ_ASSERT_IF(!needsSweep,
|
||||||
|
|
|
@ -1741,7 +1741,7 @@ void InnerViewTable::sweepAfterMinorGC(JSTracer* trc) {
|
||||||
JSObject* buffer = MaybeForwarded(nurseryKeys[i]);
|
JSObject* buffer = MaybeForwarded(nurseryKeys[i]);
|
||||||
Map::Ptr p = map.lookup(buffer);
|
Map::Ptr p = map.lookup(buffer);
|
||||||
if (p &&
|
if (p &&
|
||||||
!Map::SweepPolicy::traceWeak(trc, &p->mutableKey(), &p->value())) {
|
!Map::EntryGCPolicy::traceWeak(trc, &p->mutableKey(), &p->value())) {
|
||||||
map.remove(p);
|
map.remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,7 +612,7 @@ class XPCJSRuntime final : public mozilla::CycleCollectedJSRuntime {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SweepPolicy {
|
struct MapEntryGCPolicy {
|
||||||
static bool traceWeak(JSTracer* trc,
|
static bool traceWeak(JSTracer* trc,
|
||||||
RefPtr<mozilla::BasePrincipal>* /* unused */,
|
RefPtr<mozilla::BasePrincipal>* /* unused */,
|
||||||
JS::Heap<JSObject*>* value) {
|
JS::Heap<JSObject*>* value) {
|
||||||
|
@ -621,7 +621,7 @@ class XPCJSRuntime final : public mozilla::CycleCollectedJSRuntime {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef JS::GCHashMap<RefPtr<mozilla::BasePrincipal>, JS::Heap<JSObject*>,
|
typedef JS::GCHashMap<RefPtr<mozilla::BasePrincipal>, JS::Heap<JSObject*>,
|
||||||
Hasher, js::SystemAllocPolicy, SweepPolicy>
|
Hasher, js::SystemAllocPolicy, MapEntryGCPolicy>
|
||||||
Principal2JSObjectMap;
|
Principal2JSObjectMap;
|
||||||
|
|
||||||
mozilla::UniquePtr<JSObject2WrappedJSMap> mWrappedJSMap;
|
mozilla::UniquePtr<JSObject2WrappedJSMap> mWrappedJSMap;
|
||||||
|
@ -2644,7 +2644,7 @@ class CompartmentPrivate {
|
||||||
|
|
||||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||||
|
|
||||||
struct SweepPolicy {
|
struct MapEntryGCPolicy {
|
||||||
static bool traceWeak(JSTracer* trc, const void* /* unused */,
|
static bool traceWeak(JSTracer* trc, const void* /* unused */,
|
||||||
JS::Heap<JSObject*>* value) {
|
JS::Heap<JSObject*>* value) {
|
||||||
return JS::GCPolicy<JS::Heap<JSObject*>>::traceWeak(trc, value);
|
return JS::GCPolicy<JS::Heap<JSObject*>>::traceWeak(trc, value);
|
||||||
|
@ -2653,7 +2653,7 @@ class CompartmentPrivate {
|
||||||
|
|
||||||
typedef JS::GCHashMap<const void*, JS::Heap<JSObject*>,
|
typedef JS::GCHashMap<const void*, JS::Heap<JSObject*>,
|
||||||
mozilla::PointerHasher<const void*>,
|
mozilla::PointerHasher<const void*>,
|
||||||
js::SystemAllocPolicy, SweepPolicy>
|
js::SystemAllocPolicy, MapEntryGCPolicy>
|
||||||
RemoteProxyMap;
|
RemoteProxyMap;
|
||||||
RemoteProxyMap& GetRemoteProxyMap() { return mRemoteProxies; }
|
RemoteProxyMap& GetRemoteProxyMap() { return mRemoteProxies; }
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче