Bug 1661079 - Part 12: Use SystemAllocPolicy in WellKnownParserAtoms.entrySet_ and ParserAtomsTable.entrySet_. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D88350
This commit is contained in:
Tooru Fujisawa 2020-08-28 14:34:47 +00:00
Родитель 7c52b93514
Коммит 7dd156c524
2 изменённых файлов: 7 добавлений и 8 удалений

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

@ -163,8 +163,7 @@ JS::Result<JSAtom*, OOM&> ParserAtomEntry::toJSAtom(
}
auto index = compilationInfo.input.atoms.length();
if (!compilationInfo.input.atoms.append(atom)) {
js::ReportOutOfMemory(cx);
return mozilla::Err(PARSER_ATOMS_OOM);
return RaiseParserAtomsOOMError(cx);
}
atomIndex_.construct<AtomIndex>(index);
return atom;
@ -186,7 +185,7 @@ void ParserAtomEntry::dumpCharsNoQuote(js::GenericPrinter& out) const {
#endif
ParserAtomsTable::ParserAtomsTable(JSContext* cx)
: entrySet_(cx), wellKnownTable_(*cx->runtime()->commonParserNames) {}
: wellKnownTable_(*cx->runtime()->commonParserNames) {}
JS::Result<const ParserAtom*, OOM&> ParserAtomsTable::addEntry(
JSContext* cx, AddPtr& addPtr, UniquePtr<ParserAtomEntry> entry) {
@ -349,8 +348,7 @@ JS::Result<const ParserAtom*, OOM&> ParserAtomsTable::internJSAtom(
auto index = AtomIndex(compilationInfo.input.atoms.length());
if (!compilationInfo.input.atoms.append(atom)) {
js::ReportOutOfMemory(cx);
return mozilla::Err(PARSER_ATOMS_OOM);
return RaiseParserAtomsOOMError(cx);
}
id->setAtomIndex(index);
} else {
@ -531,6 +529,7 @@ bool WellKnownParserAtoms::initSingle(JSContext* cx, const ParserName** name,
// Save name for returning after moving entry into set.
const ParserName* nm = entry.get()->asName();
if (!entrySet_.putNew(lookup, std::move(entry))) {
js::ReportOutOfMemory(cx);
return false;
}

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

@ -385,14 +385,14 @@ class WellKnownParserAtoms {
private:
using EntrySet = HashSet<UniquePtr<ParserAtomEntry>, ParserAtomLookupHasher,
TempAllocPolicy>;
js::SystemAllocPolicy>;
EntrySet entrySet_;
bool initSingle(JSContext* cx, const ParserName** name, const char* str,
WellKnownAtomId kind);
public:
explicit WellKnownParserAtoms(JSContext* cx) : entrySet_(cx) {}
explicit WellKnownParserAtoms(JSContext* cx) {}
bool init(JSContext* cx);
@ -407,7 +407,7 @@ class WellKnownParserAtoms {
class ParserAtomsTable {
private:
using EntrySet = HashSet<UniquePtr<ParserAtomEntry>, ParserAtomLookupHasher,
TempAllocPolicy>;
js::SystemAllocPolicy>;
EntrySet entrySet_;
const WellKnownParserAtoms& wellKnownTable_;