forked from mirrors/gecko-dev
Bug 1879918 - Move NON_DEDUP_BIT to bit 15 to free up a bit r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D204836
This commit is contained in:
parent
a12e130f8d
commit
33c87443b9
3 changed files with 29 additions and 12 deletions
|
|
@ -920,6 +920,7 @@ JSString* js::gc::TenuringTracer::promoteString(JSString* src) {
|
|||
// the atom. Don't do this for dependent strings because they're more
|
||||
// complicated. See StringRelocationOverlay and DeduplicationStringHasher
|
||||
// comments.
|
||||
MOZ_ASSERT(!src->isAtom());
|
||||
if (src->isLinear() && src->inStringToAtomCache() &&
|
||||
src->isDeduplicatable() && !src->hasBase()) {
|
||||
JSLinearString* linear = &src->asLinear();
|
||||
|
|
@ -963,6 +964,7 @@ JSString* js::gc::TenuringTracer::promoteString(JSString* src) {
|
|||
if (shouldTenure(zone, JS::TraceKind::String, src) &&
|
||||
src->length() < MAX_DEDUPLICATABLE_STRING_LENGTH && src->isLinear() &&
|
||||
src->isDeduplicatable() && stringDeDupSet.isSome()) {
|
||||
src->clearBitsOnTenure();
|
||||
auto p = stringDeDupSet->lookupForAdd(src);
|
||||
if (p) {
|
||||
// Deduplicate to the looked-up string!
|
||||
|
|
@ -987,14 +989,15 @@ JSString* js::gc::TenuringTracer::promoteString(JSString* src) {
|
|||
} else {
|
||||
dst = allocString(src, zone, dstKind);
|
||||
if (dst->isTenured()) {
|
||||
dst->clearNonDeduplicatable();
|
||||
src->clearBitsOnTenure();
|
||||
dst->clearBitsOnTenure();
|
||||
}
|
||||
}
|
||||
|
||||
zone->stringStats.ref().noteTenured(src->allocSize());
|
||||
|
||||
auto* overlay = StringRelocationOverlay::forwardCell(src, dst);
|
||||
MOZ_ASSERT_IF(dst->isTenured(), dst->isDeduplicatable());
|
||||
MOZ_ASSERT_IF(dst->isTenured() && dst->isLinear(), dst->isDeduplicatable());
|
||||
|
||||
if (dst->hasBase() || dst->isRope()) {
|
||||
// dst or one of its leaves might have a base that will be deduplicated.
|
||||
|
|
@ -1114,7 +1117,8 @@ void js::gc::TenuringTracer::collectToStringFixedPoint() {
|
|||
MOZ_ASSERT_IF(IsInsideNursery(str), !nursery().inCollectedRegion(str));
|
||||
|
||||
// To ensure the NON_DEDUP_BIT was reset properly.
|
||||
MOZ_ASSERT_IF(str->isTenured(), str->isDeduplicatable());
|
||||
MOZ_ASSERT(!str->isAtom());
|
||||
MOZ_ASSERT_IF(str->isTenured() && str->isLinear(), str->isDeduplicatable());
|
||||
|
||||
// The nursery root base might not be forwarded before
|
||||
// traceString(str). traceString(str) will forward the root
|
||||
|
|
|
|||
|
|
@ -411,9 +411,6 @@ void ForEachStringFlag(const JSString* str, uint32_t flags, KnownF known,
|
|||
case JSString::INDEX_VALUE_BIT:
|
||||
known("INDEX_VALUE_BIT");
|
||||
break;
|
||||
case JSString::NON_DEDUP_BIT:
|
||||
known("NON_DEDUP_BIT");
|
||||
break;
|
||||
case JSString::IN_STRING_TO_ATOM_CACHE:
|
||||
known("IN_STRING_TO_ATOM_CACHE");
|
||||
break;
|
||||
|
|
@ -421,7 +418,7 @@ void ForEachStringFlag(const JSString* str, uint32_t flags, KnownF known,
|
|||
if (str->isRope()) {
|
||||
known("FLATTEN_VISIT_RIGHT");
|
||||
} else {
|
||||
unknown(i);
|
||||
known("NON_DEDUP_BIT");
|
||||
}
|
||||
break;
|
||||
case JSString::FLATTEN_FINISH_NODE:
|
||||
|
|
|
|||
|
|
@ -407,8 +407,10 @@ class JSString : public js::gc::CellWithLengthAndFlags {
|
|||
static const uint32_t INDEX_VALUE_BIT = js::Bit(11);
|
||||
static const uint32_t INDEX_VALUE_SHIFT = 16;
|
||||
|
||||
// NON_DEDUP_BIT is used in string deduplication during tenuring.
|
||||
static const uint32_t NON_DEDUP_BIT = js::Bit(12);
|
||||
// NON_DEDUP_BIT is used in string deduplication during tenuring. This bit is
|
||||
// shared with both FLATTEN_FINISH_NODE and ATOM_IS_PERMANENT_BIT, since it
|
||||
// only applies to linear non-atoms.
|
||||
static const uint32_t NON_DEDUP_BIT = js::Bit(15);
|
||||
|
||||
// If IN_STRING_TO_ATOM_CACHE is set, this string had an entry in the
|
||||
// StringToAtomCache at some point. Note that GC can purge the cache without
|
||||
|
|
@ -627,13 +629,27 @@ class JSString : public js::gc::CellWithLengthAndFlags {
|
|||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE
|
||||
void setNonDeduplicatable() { setFlagBit(NON_DEDUP_BIT); }
|
||||
void setNonDeduplicatable() {
|
||||
MOZ_ASSERT(isLinear());
|
||||
MOZ_ASSERT(!isAtom());
|
||||
setFlagBit(NON_DEDUP_BIT);
|
||||
}
|
||||
|
||||
// After copying a string from the nursery to the tenured heap, adjust bits
|
||||
// that no longer apply.
|
||||
MOZ_ALWAYS_INLINE
|
||||
void clearNonDeduplicatable() { clearFlagBit(NON_DEDUP_BIT); }
|
||||
void clearBitsOnTenure() {
|
||||
MOZ_ASSERT(!isAtom());
|
||||
clearFlagBit(NON_DEDUP_BIT | IN_STRING_TO_ATOM_CACHE);
|
||||
}
|
||||
|
||||
// NON_DEDUP_BIT is only valid for linear non-atoms.
|
||||
MOZ_ALWAYS_INLINE
|
||||
bool isDeduplicatable() { return !(flags() & NON_DEDUP_BIT); }
|
||||
bool isDeduplicatable() {
|
||||
MOZ_ASSERT(isLinear());
|
||||
MOZ_ASSERT(!isAtom());
|
||||
return !(flags() & NON_DEDUP_BIT);
|
||||
}
|
||||
|
||||
void setInStringToAtomCache() {
|
||||
MOZ_ASSERT(!isAtom());
|
||||
|
|
|
|||
Loading…
Reference in a new issue