зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461938 part 34 - Move IteratorCache from JSCompartment to ObjectRealm. r=jonco
This commit is contained in:
Родитель
98ab8b6b91
Коммит
814de94fef
|
@ -823,7 +823,7 @@ LookupInIteratorCache(JSContext* cx, JSObject* obj, uint32_t* numGuards)
|
||||||
*numGuards = guards.length();
|
*numGuards = guards.length();
|
||||||
|
|
||||||
IteratorHashPolicy::Lookup lookup(guards.begin(), guards.length(), key);
|
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)
|
if (!p)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ StoreInIteratorCache(JSContext* cx, JSObject* obj, PropertyIteratorObject* itero
|
||||||
ni->guardCount(),
|
ni->guardCount(),
|
||||||
ni->guard_key);
|
ni->guard_key);
|
||||||
|
|
||||||
JSCompartment::IteratorCache& cache = cx->compartment()->iteratorCache;
|
ObjectRealm::IteratorCache& cache = ObjectRealm::get(obj).iteratorCache;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto p = cache.lookupForAdd(lookup);
|
auto p = cache.lookupForAdd(lookup);
|
||||||
if (MOZ_LIKELY(!p)) {
|
if (MOZ_LIKELY(!p)) {
|
||||||
|
|
|
@ -109,6 +109,12 @@ JSCompartment::init(JSContext* maybecx)
|
||||||
bool
|
bool
|
||||||
ObjectRealm::init(JSContext* maybecx)
|
ObjectRealm::init(JSContext* maybecx)
|
||||||
{
|
{
|
||||||
|
if (!iteratorCache.init()) {
|
||||||
|
if (maybecx)
|
||||||
|
ReportOutOfMemory(maybecx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
NativeIteratorSentinel sentinel(NativeIterator::allocateSentinel(maybecx));
|
NativeIteratorSentinel sentinel(NativeIterator::allocateSentinel(maybecx));
|
||||||
if (!sentinel)
|
if (!sentinel)
|
||||||
return false;
|
return false;
|
||||||
|
@ -141,8 +147,7 @@ Realm::init(JSContext* maybecx)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!savedStacks_.init() ||
|
if (!savedStacks_.init() ||
|
||||||
!varNames_.init() ||
|
!varNames_.init())
|
||||||
!iteratorCache.init())
|
|
||||||
{
|
{
|
||||||
if (maybecx)
|
if (maybecx)
|
||||||
ReportOutOfMemory(maybecx);
|
ReportOutOfMemory(maybecx);
|
||||||
|
@ -1013,7 +1018,7 @@ Realm::purge()
|
||||||
dtoaCache.purge();
|
dtoaCache.purge();
|
||||||
newProxyCache.purge();
|
newProxyCache.purge();
|
||||||
objectGroups.purge();
|
objectGroups.purge();
|
||||||
iteratorCache.clearAndShrink();
|
objects_.iteratorCache.clearAndShrink();
|
||||||
arraySpeciesLookup.purge();
|
arraySpeciesLookup.purge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,11 +592,6 @@ struct JSCompartment
|
||||||
public:
|
public:
|
||||||
js::RegExpCompartment regExps;
|
js::RegExpCompartment regExps;
|
||||||
|
|
||||||
using IteratorCache = js::HashSet<js::PropertyIteratorObject*,
|
|
||||||
js::IteratorHashPolicy,
|
|
||||||
js::SystemAllocPolicy>;
|
|
||||||
IteratorCache iteratorCache;
|
|
||||||
|
|
||||||
// Recompute the probability with which this compartment should record
|
// Recompute the probability with which this compartment should record
|
||||||
// profiling data (stack traces, allocations log, etc.) about each
|
// profiling data (stack traces, allocations log, etc.) about each
|
||||||
// allocation. We consult the probabilities requested by the Debugger
|
// allocation. We consult the probabilities requested by the Debugger
|
||||||
|
@ -752,6 +747,11 @@ class ObjectRealm
|
||||||
// object. Both keys and values are in this realm.
|
// object. Both keys and values are in this realm.
|
||||||
js::UniquePtr<js::ObjectWeakMap> objectMetadataTable;
|
js::UniquePtr<js::ObjectWeakMap> objectMetadataTable;
|
||||||
|
|
||||||
|
using IteratorCache = js::HashSet<js::PropertyIteratorObject*,
|
||||||
|
js::IteratorHashPolicy,
|
||||||
|
js::SystemAllocPolicy>;
|
||||||
|
IteratorCache iteratorCache;
|
||||||
|
|
||||||
static inline ObjectRealm& get(const JSObject* obj);
|
static inline ObjectRealm& get(const JSObject* obj);
|
||||||
|
|
||||||
explicit ObjectRealm(JS::Zone* zone);
|
explicit ObjectRealm(JS::Zone* zone);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче