зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1746382 - Remove static string lookup from stencil instantiation. r=tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D135099
This commit is contained in:
Родитель
21b3090758
Коммит
3262a82616
|
@ -138,9 +138,9 @@ JSAtom* ParserAtom::instantiateAtom(JSContext* cx, ParserAtomIndex index,
|
|||
|
||||
JSAtom* atom;
|
||||
if (hasLatin1Chars()) {
|
||||
atom = AtomizeChars(cx, hash(), latin1Chars(), length());
|
||||
atom = AtomizeCharsNonStatic(cx, hash(), latin1Chars(), length());
|
||||
} else {
|
||||
atom = AtomizeChars(cx, hash(), twoByteChars(), length());
|
||||
atom = AtomizeCharsNonStatic(cx, hash(), twoByteChars(), length());
|
||||
}
|
||||
if (!atom) {
|
||||
return nullptr;
|
||||
|
@ -157,8 +157,8 @@ JSAtom* ParserAtom::instantiatePermanentAtom(
|
|||
MOZ_ASSERT(!cx->zone());
|
||||
|
||||
MOZ_ASSERT(hasLatin1Chars());
|
||||
JSAtom* atom =
|
||||
PermanentlyAtomizeChars(cx, atomSet, hash(), latin1Chars(), length());
|
||||
JSAtom* atom = PermanentlyAtomizeCharsNonStatic(cx, atomSet, hash(),
|
||||
latin1Chars(), length());
|
||||
if (!atom) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -193,6 +193,10 @@ MOZ_ALWAYS_INLINE AtomSet::Ptr js::FrozenAtomSet::readonlyThreadsafeLookup(
|
|||
return mSet->readonlyThreadsafeLookup(l);
|
||||
}
|
||||
|
||||
static JSAtom* PermanentlyAtomizeChars(JSContext* cx, AtomSet& atomSet,
|
||||
mozilla::HashNumber hash,
|
||||
const Latin1Char* chars, size_t length);
|
||||
|
||||
bool JSRuntime::initializeAtoms(JSContext* cx) {
|
||||
JS::AutoAssertNoGC nogc;
|
||||
|
||||
|
@ -261,7 +265,7 @@ bool JSRuntime::initializeAtoms(JSContext* cx) {
|
|||
}
|
||||
|
||||
for (const auto& info : symbolDescInfo) {
|
||||
JSAtom* atom = PermanentlyAtomizeChars(
|
||||
JSAtom* atom = PermanentlyAtomizeCharsNonStatic(
|
||||
cx, *atomSet, info.hash,
|
||||
reinterpret_cast<const Latin1Char*>(info.content), info.length);
|
||||
if (!atom) {
|
||||
|
@ -816,39 +820,42 @@ template JSAtom* js::AtomizeChars(JSContext* cx, const char16_t* chars,
|
|||
|
||||
/* |chars| must not point into an inline or short string. */
|
||||
template <typename CharT>
|
||||
JSAtom* js::AtomizeChars(JSContext* cx, HashNumber hash, const CharT* chars,
|
||||
size_t length) {
|
||||
if (JSAtom* s = cx->staticStrings().lookup(chars, length)) {
|
||||
return s;
|
||||
}
|
||||
JSAtom* js::AtomizeCharsNonStatic(JSContext* cx, HashNumber hash,
|
||||
const CharT* chars, size_t length) {
|
||||
MOZ_ASSERT(!cx->staticStrings().lookup(chars, length));
|
||||
|
||||
AtomHasher::Lookup lookup(hash, chars, length);
|
||||
return AtomizeAndCopyCharsFromLookup(cx, chars, length, lookup, Nothing());
|
||||
}
|
||||
|
||||
template JSAtom* js::AtomizeChars(JSContext* cx, HashNumber hash,
|
||||
const Latin1Char* chars, size_t length);
|
||||
template JSAtom* js::AtomizeCharsNonStatic(JSContext* cx, HashNumber hash,
|
||||
const Latin1Char* chars,
|
||||
size_t length);
|
||||
|
||||
template JSAtom* js::AtomizeChars(JSContext* cx, HashNumber hash,
|
||||
const char16_t* chars, size_t length);
|
||||
template JSAtom* js::AtomizeCharsNonStatic(JSContext* cx, HashNumber hash,
|
||||
const char16_t* chars,
|
||||
size_t length);
|
||||
|
||||
template <typename CharT>
|
||||
JSAtom* js::PermanentlyAtomizeChars(JSContext* cx, AtomSet& atomSet,
|
||||
HashNumber hash, const CharT* chars,
|
||||
size_t length) {
|
||||
static JSAtom* PermanentlyAtomizeChars(JSContext* cx, AtomSet& atomSet,
|
||||
HashNumber hash, const Latin1Char* chars,
|
||||
size_t length) {
|
||||
if (JSAtom* s = cx->staticStrings().lookup(chars, length)) {
|
||||
return s;
|
||||
}
|
||||
|
||||
return PermanentlyAtomizeCharsNonStatic(cx, atomSet, hash, chars, length);
|
||||
}
|
||||
|
||||
JSAtom* js::PermanentlyAtomizeCharsNonStatic(JSContext* cx, AtomSet& atomSet,
|
||||
HashNumber hash,
|
||||
const Latin1Char* chars,
|
||||
size_t length) {
|
||||
MOZ_ASSERT(!cx->staticStrings().lookup(chars, length));
|
||||
|
||||
AtomHasher::Lookup lookup(hash, chars, length);
|
||||
return PermanentlyAtomizeAndCopyChars(cx, atomSet, chars, length, lookup);
|
||||
}
|
||||
|
||||
template JSAtom* js::PermanentlyAtomizeChars(JSContext* cx, AtomSet& atomSet,
|
||||
HashNumber hash,
|
||||
const Latin1Char* chars,
|
||||
size_t length);
|
||||
|
||||
JSAtom* js::AtomizeUTF8Chars(JSContext* cx, const char* utf8Chars,
|
||||
size_t utf8ByteLength) {
|
||||
{
|
||||
|
|
|
@ -49,13 +49,13 @@ extern JSAtom* AtomizeChars(JSContext* cx, const CharT* chars, size_t length);
|
|||
|
||||
/* Atomize characters when the value of HashString is already known. */
|
||||
template <typename CharT>
|
||||
extern JSAtom* AtomizeChars(JSContext* cx, mozilla::HashNumber hash,
|
||||
const CharT* chars, size_t length);
|
||||
extern JSAtom* AtomizeCharsNonStatic(JSContext* cx, mozilla::HashNumber hash,
|
||||
const CharT* chars, size_t length);
|
||||
|
||||
template <typename CharT>
|
||||
extern JSAtom* PermanentlyAtomizeChars(JSContext* cx, AtomSet& atomSet,
|
||||
mozilla::HashNumber hash,
|
||||
const CharT* chars, size_t length);
|
||||
extern JSAtom* PermanentlyAtomizeCharsNonStatic(JSContext* cx, AtomSet& atomSet,
|
||||
mozilla::HashNumber hash,
|
||||
const Latin1Char* chars,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* Create an atom whose contents are those of the |utf8ByteLength| code units
|
||||
|
|
Загрузка…
Ссылка в новой задаче