Bug 1461938 part 34 - Move IteratorCache from JSCompartment to ObjectRealm. r=jonco

This commit is contained in:
Jan de Mooij 2018-05-24 12:02:54 +02:00
Родитель 98ab8b6b91
Коммит 814de94fef
3 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -823,7 +823,7 @@ LookupInIteratorCache(JSContext* cx, JSObject* obj, uint32_t* numGuards)
*numGuards = guards.length();
IteratorHashPolicy::Lookup lookup(guards.begin(), guards.length(), key);
auto p = cx->compartment()->iteratorCache.lookup(lookup);
auto p = ObjectRealm::get(obj).iteratorCache.lookup(lookup);
if (!p)
return nullptr;
@ -873,7 +873,7 @@ StoreInIteratorCache(JSContext* cx, JSObject* obj, PropertyIteratorObject* itero
ni->guardCount(),
ni->guard_key);
JSCompartment::IteratorCache& cache = cx->compartment()->iteratorCache;
ObjectRealm::IteratorCache& cache = ObjectRealm::get(obj).iteratorCache;
bool ok;
auto p = cache.lookupForAdd(lookup);
if (MOZ_LIKELY(!p)) {

Просмотреть файл

@ -109,6 +109,12 @@ JSCompartment::init(JSContext* maybecx)
bool
ObjectRealm::init(JSContext* maybecx)
{
if (!iteratorCache.init()) {
if (maybecx)
ReportOutOfMemory(maybecx);
return false;
}
NativeIteratorSentinel sentinel(NativeIterator::allocateSentinel(maybecx));
if (!sentinel)
return false;
@ -141,8 +147,7 @@ Realm::init(JSContext* maybecx)
return false;
if (!savedStacks_.init() ||
!varNames_.init() ||
!iteratorCache.init())
!varNames_.init())
{
if (maybecx)
ReportOutOfMemory(maybecx);
@ -1013,7 +1018,7 @@ Realm::purge()
dtoaCache.purge();
newProxyCache.purge();
objectGroups.purge();
iteratorCache.clearAndShrink();
objects_.iteratorCache.clearAndShrink();
arraySpeciesLookup.purge();
}

Просмотреть файл

@ -592,11 +592,6 @@ struct JSCompartment
public:
js::RegExpCompartment regExps;
using IteratorCache = js::HashSet<js::PropertyIteratorObject*,
js::IteratorHashPolicy,
js::SystemAllocPolicy>;
IteratorCache iteratorCache;
// Recompute the probability with which this compartment should record
// profiling data (stack traces, allocations log, etc.) about each
// allocation. We consult the probabilities requested by the Debugger
@ -752,6 +747,11 @@ class ObjectRealm
// object. Both keys and values are in this realm.
js::UniquePtr<js::ObjectWeakMap> objectMetadataTable;
using IteratorCache = js::HashSet<js::PropertyIteratorObject*,
js::IteratorHashPolicy,
js::SystemAllocPolicy>;
IteratorCache iteratorCache;
static inline ObjectRealm& get(const JSObject* obj);
explicit ObjectRealm(JS::Zone* zone);