Bug 1664189 - Share hash computation when looking up atoms. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 11 Sep 2020 03:37:15 +0000
changeset 548290 691a86eef68649b434b921080f5b55960b3c9f91
parent 548289 62480de389ffba353998de24760993b2e1531232
child 548291 1fc282e54b7a584087712a870dce62e0bf4c942b
push id37776
push userbtara@mozilla.com
push dateFri, 11 Sep 2020 15:10:42 +0000
treeherdermozilla-central@b133e2d673e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
bugs1664189
milestone82.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1664189 - Share hash computation when looking up atoms. r=djvj Differential Revision: https://phabricator.services.mozilla.com/D89731
js/src/frontend/ParserAtom.cpp
js/src/frontend/ParserAtom.h
--- a/js/src/frontend/ParserAtom.cpp
+++ b/js/src/frontend/ParserAtom.cpp
@@ -225,23 +225,23 @@ JS::Result<const ParserAtom*, OOM&> Pars
                                                addPtr.inner().hash));
   return addEntry(cx, addPtr, std::move(entry));
 }
 
 template <typename CharT>
 ParserAtomsTable::AddPtr ParserAtomsTable::lookupForAdd(
     JSContext* cx, InflatedChar16Sequence<CharT> seq) {
   // Check against well-known.
-  const ParserAtom* wk = wellKnownTable_.lookupChar16Seq(seq);
+  SpecificParserAtomLookup<CharT> lookup(seq);
+  const ParserAtom* wk = wellKnownTable_.lookupChar16Seq(lookup);
   if (wk) {
     return AddPtr(wk);
   }
 
   // Check for existing atom.
-  SpecificParserAtomLookup<CharT> lookup(seq);
   return AddPtr(entrySet_.lookupForAdd(lookup), lookup.hash());
 }
 
 template <typename CharT>
 JS::Result<const ParserAtom*, OOM&> ParserAtomsTable::lookupOrInternChar16Seq(
     JSContext* cx, InflatedChar16Sequence<CharT> seq) {
   // Check for well-known or existing.
   AddPtr addPtr = lookupForAdd(cx, seq);
@@ -472,18 +472,17 @@ JS::Result<const ParserAtom*, OOM&> Pars
   UniquePtr<ParserAtomEntry> entry;
   MOZ_TRY_VAR(entry, ParserAtomEntry::allocate(cx, std::move(copy), catLen,
                                                addPtr.inner().hash));
   return addEntry(cx, addPtr, std::move(entry));
 }
 
 template <typename CharT>
 const ParserAtom* WellKnownParserAtoms::lookupChar16Seq(
-    InflatedChar16Sequence<CharT> seq) const {
-  SpecificParserAtomLookup<CharT> lookup(seq);
+    const SpecificParserAtomLookup<CharT>& lookup) const {
   EntrySet::Ptr get = entrySet_.readonlyThreadsafeLookup(lookup);
   if (get) {
     return get->get()->asAtom();
   }
   return nullptr;
 }
 
 bool WellKnownParserAtoms::initSingle(JSContext* cx, const ParserName** name,
--- a/js/src/frontend/ParserAtom.h
+++ b/js/src/frontend/ParserAtom.h
@@ -392,17 +392,18 @@ class WellKnownParserAtoms {
                   WellKnownAtomId kind);
 
  public:
   WellKnownParserAtoms() = default;
 
   bool init(JSContext* cx);
 
   template <typename CharT>
-  const ParserAtom* lookupChar16Seq(InflatedChar16Sequence<CharT> seq) const;
+  const ParserAtom* lookupChar16Seq(
+      const SpecificParserAtomLookup<CharT>& lookup) const;
 };
 
 /**
  * A ParserAtomsTable owns and manages the vector of ParserAtom entries
  * associated with a given compile session.
  */
 class ParserAtomsTable {
  private: