зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461938 part 13 - Move dtoaCache and newProxyCache from JSCompartment to JS::Realm. r=anba
This commit is contained in:
Родитель
b4bf5c547f
Коммит
1da2a378bb
|
@ -4013,8 +4013,8 @@ GCRuntime::purgeRuntime()
|
|||
{
|
||||
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::PURGE);
|
||||
|
||||
for (GCCompartmentsIter comp(rt); !comp.done(); comp.next())
|
||||
comp->purge();
|
||||
for (GCRealmsIter realm(rt); !realm.done(); realm.next())
|
||||
realm->purge();
|
||||
|
||||
for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
|
||||
zone->atomCache().clearAndShrink();
|
||||
|
|
|
@ -89,7 +89,8 @@ class GCZonesIter
|
|||
JS::Zone* operator->() const { return get(); }
|
||||
};
|
||||
|
||||
typedef CompartmentsIterT<GCZonesIter> GCCompartmentsIter;
|
||||
using GCCompartmentsIter = CompartmentsIterT<GCZonesIter>;
|
||||
using GCRealmsIter = RealmsIterT<GCZonesIter>;
|
||||
|
||||
/* Iterates over all zones in the current sweep group. */
|
||||
class SweepGroupZonesIter {
|
||||
|
|
|
@ -56,7 +56,7 @@ BEGIN_TEST(testIndexToString)
|
|||
CHECK(str);
|
||||
|
||||
if (!js::StaticStrings::hasUint(u))
|
||||
CHECK(cx->compartment()->dtoaCache.lookup(10, u) == str);
|
||||
CHECK(cx->realm()->dtoaCache.lookup(10, u) == str);
|
||||
|
||||
bool match = false;
|
||||
CHECK(JS_StringEqualsAscii(cx, str, tests[i].expected, &match));
|
||||
|
|
|
@ -568,8 +568,8 @@ MOZ_ALWAYS_INLINE
|
|||
static JSFlatString*
|
||||
LookupDtoaCache(JSContext* cx, double d)
|
||||
{
|
||||
if (JSCompartment* comp = cx->compartment()) {
|
||||
if (JSFlatString* str = comp->dtoaCache.lookup(10, d))
|
||||
if (Realm* realm = cx->realm()) {
|
||||
if (JSFlatString* str = realm->dtoaCache.lookup(10, d))
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -580,8 +580,8 @@ MOZ_ALWAYS_INLINE
|
|||
static void
|
||||
CacheNumber(JSContext* cx, double d, JSFlatString* str)
|
||||
{
|
||||
if (JSCompartment* comp = cx->compartment())
|
||||
comp->dtoaCache.cache(10, d, str);
|
||||
if (Realm* realm = cx->realm())
|
||||
realm->dtoaCache.cache(10, d, str);
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE
|
||||
|
@ -1327,7 +1327,7 @@ NumberToStringWithBase(JSContext* cx, double d, int base)
|
|||
ToCStringBuf cbuf;
|
||||
char* numStr;
|
||||
|
||||
JSCompartment* comp = cx->compartment();
|
||||
Realm* realm = cx->realm();
|
||||
|
||||
int32_t i;
|
||||
bool isBase10Int = false;
|
||||
|
@ -1343,14 +1343,14 @@ NumberToStringWithBase(JSContext* cx, double d, int base)
|
|||
return cx->staticStrings().getUnit(c);
|
||||
}
|
||||
|
||||
if (JSFlatString* str = comp->dtoaCache.lookup(base, d))
|
||||
if (JSFlatString* str = realm->dtoaCache.lookup(base, d))
|
||||
return str;
|
||||
|
||||
size_t len;
|
||||
numStr = Int32ToCString(&cbuf, i, &len, base);
|
||||
MOZ_ASSERT(!cbuf.dbuf && numStr >= cbuf.sbuf && numStr < cbuf.sbuf + cbuf.sbufSize);
|
||||
} else {
|
||||
if (JSFlatString* str = comp->dtoaCache.lookup(base, d))
|
||||
if (JSFlatString* str = realm->dtoaCache.lookup(base, d))
|
||||
return str;
|
||||
|
||||
numStr = FracNumberToCString(cx, &cbuf, d, base);
|
||||
|
@ -1371,7 +1371,7 @@ NumberToStringWithBase(JSContext* cx, double d, int base)
|
|||
if (isBase10Int && i >= 0)
|
||||
s->maybeInitializeIndex(i);
|
||||
|
||||
comp->dtoaCache.cache(base, d, s);
|
||||
realm->dtoaCache.cache(base, d, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -1422,8 +1422,8 @@ js::IndexToString(JSContext* cx, uint32_t index)
|
|||
if (StaticStrings::hasUint(index))
|
||||
return cx->staticStrings().getUint(index);
|
||||
|
||||
JSCompartment* c = cx->compartment();
|
||||
if (JSFlatString* str = c->dtoaCache.lookup(10, index))
|
||||
Realm* realm = cx->realm();
|
||||
if (JSFlatString* str = realm->dtoaCache.lookup(10, index))
|
||||
return str;
|
||||
|
||||
Latin1Char buffer[JSFatInlineString::MAX_LENGTH_LATIN1 + 1];
|
||||
|
@ -1437,7 +1437,7 @@ js::IndexToString(JSContext* cx, uint32_t index)
|
|||
if (!str)
|
||||
return nullptr;
|
||||
|
||||
c->dtoaCache.cache(10, index, str);
|
||||
realm->dtoaCache.cache(10, index, str);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
|
@ -759,7 +759,9 @@ JSCompartment::sweepAfterMinorGC(JSTracer* trc)
|
|||
table.sweepAfterMinorGC();
|
||||
|
||||
crossCompartmentWrappers.sweepAfterMinorGC(trc);
|
||||
dtoaCache.purge();
|
||||
|
||||
Realm* realm = JS::GetRealmForCompartment(this);
|
||||
realm->dtoaCache.purge();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -902,7 +904,7 @@ JSCompartment::fixupAfterMovingGC()
|
|||
|
||||
Realm* realm = JS::GetRealmForCompartment(this);
|
||||
|
||||
purge();
|
||||
realm->purge();
|
||||
realm->fixupGlobal();
|
||||
objectGroups.fixupTablesAfterMovingGC();
|
||||
realm->fixupScriptMapsAfterMovingGC();
|
||||
|
@ -994,7 +996,7 @@ Realm::checkScriptMapsAfterMovingGC()
|
|||
#endif
|
||||
|
||||
void
|
||||
JSCompartment::purge()
|
||||
Realm::purge()
|
||||
{
|
||||
dtoaCache.purge();
|
||||
newProxyCache.purge();
|
||||
|
|
|
@ -851,8 +851,6 @@ struct JSCompartment
|
|||
void sweepNativeIterators();
|
||||
void sweepTemplateObjects();
|
||||
|
||||
void purge();
|
||||
|
||||
static void fixupCrossCompartmentWrappersAfterMovingGC(JSTracer* trc);
|
||||
void fixupAfterMovingGC();
|
||||
|
||||
|
@ -860,9 +858,6 @@ struct JSCompartment
|
|||
|
||||
void findOutgoingEdges(js::gc::ZoneComponentFinder& finder);
|
||||
|
||||
js::DtoaCache dtoaCache;
|
||||
js::NewProxyCache newProxyCache;
|
||||
|
||||
// Random number generator for Math.random().
|
||||
mozilla::Maybe<mozilla::non_crypto::XorShift128PlusRNG> randomNumberGenerator;
|
||||
|
||||
|
@ -881,10 +876,6 @@ struct JSCompartment
|
|||
return offsetof(JSCompartment, regExps);
|
||||
}
|
||||
|
||||
private:
|
||||
JSCompartment* thisForCtor() { return this; }
|
||||
|
||||
public:
|
||||
//
|
||||
// The Debugger observes execution on a frame-by-frame basis. The
|
||||
// invariants of JSCompartment's debug mode bits, JSScript::isDebuggee,
|
||||
|
@ -1071,6 +1062,9 @@ class JS::Realm : public JSCompartment
|
|||
// WebAssembly state for the realm.
|
||||
js::wasm::Realm wasm;
|
||||
|
||||
js::DtoaCache dtoaCache;
|
||||
js::NewProxyCache newProxyCache;
|
||||
|
||||
js::ScriptCountsMap* scriptCountsMap = nullptr;
|
||||
js::ScriptNameMap* scriptNameMap = nullptr;
|
||||
js::DebugScriptMap* debugScriptMap = nullptr;
|
||||
|
@ -1154,6 +1148,8 @@ class JS::Realm : public JSCompartment
|
|||
void clearScriptCounts();
|
||||
void clearScriptNames();
|
||||
|
||||
void purge();
|
||||
|
||||
void fixupScriptMapsAfterMovingGC();
|
||||
|
||||
#ifdef JSGC_HASH_TABLE_CHECKS
|
||||
|
|
|
@ -160,12 +160,12 @@ ProxyObject::create(JSContext* cx, const Class* clasp, Handle<TaggedProto> proto
|
|||
{
|
||||
MOZ_ASSERT(clasp->isProxy());
|
||||
|
||||
JSCompartment* comp = cx->compartment();
|
||||
Realm* realm = cx->realm();
|
||||
RootedObjectGroup group(cx);
|
||||
RootedShape shape(cx);
|
||||
|
||||
// Try to look up the group and shape in the NewProxyCache.
|
||||
if (!comp->newProxyCache.lookup(clasp, proto, group.address(), shape.address())) {
|
||||
if (!realm->newProxyCache.lookup(clasp, proto, group.address(), shape.address())) {
|
||||
group = ObjectGroup::defaultNewGroup(cx, clasp, proto, nullptr);
|
||||
if (!group)
|
||||
return cx->alreadyReportedOOM();
|
||||
|
@ -174,7 +174,8 @@ ProxyObject::create(JSContext* cx, const Class* clasp, Handle<TaggedProto> proto
|
|||
if (!shape)
|
||||
return cx->alreadyReportedOOM();
|
||||
|
||||
comp->newProxyCache.add(group, shape);
|
||||
MOZ_ASSERT(group->realm() == realm);
|
||||
realm->newProxyCache.add(group, shape);
|
||||
}
|
||||
|
||||
gc::InitialHeap heap = GetInitialHeap(newKind, clasp);
|
||||
|
|
Загрузка…
Ссылка в новой задаче