diff --git a/js/src/frontend/ParserAtom.cpp b/js/src/frontend/ParserAtom.cpp index 485772f53a38..9833379a032b 100644 --- a/js/src/frontend/ParserAtom.cpp +++ b/js/src/frontend/ParserAtom.cpp @@ -1238,8 +1238,7 @@ TaggedParserAtomIndex WellKnownParserAtoms::lookupTinyIndexUTF8( return lookupTinyIndex(reinterpret_cast(utf8Ptr), nbyte); } -bool WellKnownParserAtoms::initSingle(JSContext* cx, - const WellKnownAtomInfo& info, +bool WellKnownParserAtoms::initSingle(const WellKnownAtomInfo& info, TaggedParserAtomIndex index) { unsigned int len = info.length; const Latin1Char* str = reinterpret_cast(info.content); @@ -1259,34 +1258,33 @@ bool WellKnownParserAtoms::initSingle(JSContext* cx, // Save name for returning after moving entry into set. if (!wellKnownMap_.putNew(lookup, &info, index)) { - js::ReportOutOfMemory(cx); return false; } return true; } -bool WellKnownParserAtoms::init(JSContext* cx) { +bool WellKnownParserAtoms::init() { // Add well-known strings to the HashMap. The HashMap is used for dynamic // lookups later and does not change once this init method is complete. -#define COMMON_NAME_INIT_(_, NAME, _2) \ - if (!initSingle(cx, GetWellKnownAtomInfo(WellKnownAtomId::NAME), \ - TaggedParserAtomIndex::WellKnown::NAME())) { \ - return false; \ +#define COMMON_NAME_INIT_(_, NAME, _2) \ + if (!initSingle(GetWellKnownAtomInfo(WellKnownAtomId::NAME), \ + TaggedParserAtomIndex::WellKnown::NAME())) { \ + return false; \ } FOR_EACH_NONTINY_COMMON_PROPERTYNAME(COMMON_NAME_INIT_) #undef COMMON_NAME_INIT_ -#define COMMON_NAME_INIT_(NAME, _) \ - if (!initSingle(cx, GetWellKnownAtomInfo(WellKnownAtomId::NAME), \ - TaggedParserAtomIndex::WellKnown::NAME())) { \ - return false; \ +#define COMMON_NAME_INIT_(NAME, _) \ + if (!initSingle(GetWellKnownAtomInfo(WellKnownAtomId::NAME), \ + TaggedParserAtomIndex::WellKnown::NAME())) { \ + return false; \ } JS_FOR_EACH_PROTOTYPE(COMMON_NAME_INIT_) #undef COMMON_NAME_INIT_ -#define COMMON_NAME_INIT_(NAME) \ - if (!initSingle(cx, GetWellKnownAtomInfo(WellKnownAtomId::NAME), \ - TaggedParserAtomIndex::WellKnown::NAME())) { \ - return false; \ +#define COMMON_NAME_INIT_(NAME) \ + if (!initSingle(GetWellKnownAtomInfo(WellKnownAtomId::NAME), \ + TaggedParserAtomIndex::WellKnown::NAME())) { \ + return false; \ } JS_FOR_EACH_WELL_KNOWN_SYMBOL(COMMON_NAME_INIT_) #undef COMMON_NAME_INIT_ @@ -1307,7 +1305,8 @@ bool JSRuntime::initializeParserAtoms(JSContext* cx) { UniquePtr names( js_new()); - if (!names || !names->init(cx)) { + if (!names || !names->init()) { + js::ReportOutOfMemory(cx); return false; } diff --git a/js/src/frontend/ParserAtom.h b/js/src/frontend/ParserAtom.h index 016a89733c7b..e9726c8359e6 100644 --- a/js/src/frontend/ParserAtom.h +++ b/js/src/frontend/ParserAtom.h @@ -579,11 +579,10 @@ class WellKnownParserAtoms { WellKnownAtomInfoHasher, js::SystemAllocPolicy>; EntryMap wellKnownMap_; - bool initSingle(JSContext* cx, const WellKnownAtomInfo& info, - TaggedParserAtomIndex index); + bool initSingle(const WellKnownAtomInfo& info, TaggedParserAtomIndex index); public: - bool init(JSContext* cx); + bool init(); // Maximum length of any well known atoms. This can be increased if needed. static constexpr size_t MaxWellKnownLength = 32;