Bug 1581875 - Renaming HuffmanTableImplementationXXXX;r=arai
authorDavid Teller <dteller@mozilla.com>
Mon, 30 Sep 2019 08:29:36 +0000
changeset 495649 ec1278a1a78fe9258abe57492e050595008e2f37
parent 495648 6df178697e9182228bc0d2573e318c3a0047a60c
child 495650 455940bf79772434906badfad4e29fe08d3bdad2
push id114140
push userdvarga@mozilla.com
push dateWed, 02 Oct 2019 18:04:51 +0000
treeherdermozilla-inbound@32eb0ea893f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1581875
milestone71.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 1581875 - Renaming HuffmanTableImplementationXXXX;r=arai Depends on D46454 Differential Revision: https://phabricator.services.mozilla.com/D46455
js/src/frontend/BinASTTokenReaderContext.cpp
js/src/frontend/BinASTTokenReaderContext.h
--- a/js/src/frontend/BinASTTokenReaderContext.cpp
+++ b/js/src/frontend/BinASTTokenReaderContext.cpp
@@ -1625,260 +1625,254 @@ FlatHuffmanKey::FlatHuffmanKey(const Huf
                 "32 bits MUST be sufficient to store bits and bitLength");
   MOZ_ASSERT(key->bits >> MAX_CODE_BIT_LENGTH == 0);
   MOZ_ASSERT(key->bitLength >> MAX_BIT_LENGTH_BIT_LENGTH == 0);
 }
 
 // ---- Implementation of Huffman Tables
 
 template <typename T>
-HuffmanTableImplementationGeneric<T>::Iterator::Iterator(
-    typename HuffmanTableImplementationSaturated<T>::Iterator&& iterator)
+GenericHuffmanTable<T>::Iterator::Iterator(
+    typename SingleLookupHuffmanTable<T>::Iterator&& iterator)
     : implementation(std::move(iterator)) {}
 
 template <typename T>
-HuffmanTableImplementationGeneric<T>::Iterator::Iterator(
-    typename HuffmanTableImplementationMap<T>::Iterator&& iterator)
+GenericHuffmanTable<T>::Iterator::Iterator(
+    typename MapBasedHuffmanTable<T>::Iterator&& iterator)
     : implementation(std::move(iterator)) {}
 
 template <typename T>
-void HuffmanTableImplementationGeneric<T>::Iterator::operator++() {
+void GenericHuffmanTable<T>::Iterator::operator++() {
   implementation.match(
-      [](typename HuffmanTableImplementationSaturated<T>::Iterator& iterator) {
+      [](typename SingleLookupHuffmanTable<T>::Iterator& iterator) {
         iterator.operator++();
       },
-      [](typename HuffmanTableImplementationMap<T>::Iterator& iterator) {
+      [](typename MapBasedHuffmanTable<T>::Iterator& iterator) {
         iterator.operator++();
       });
 }
 
 template <typename T>
-bool HuffmanTableImplementationGeneric<T>::Iterator::operator==(
-    const HuffmanTableImplementationGeneric<T>::Iterator& other) const {
+bool GenericHuffmanTable<T>::Iterator::operator==(
+    const GenericHuffmanTable<T>::Iterator& other) const {
   return implementation.match(
-      [other](const typename HuffmanTableImplementationSaturated<T>::Iterator&
-                  iterator) {
+      [other](const typename SingleLookupHuffmanTable<T>::Iterator& iterator) {
         return iterator ==
                other.implementation.template as<
-                   typename HuffmanTableImplementationSaturated<T>::Iterator>();
+                   typename SingleLookupHuffmanTable<T>::Iterator>();
       },
-      [other](
-          const typename HuffmanTableImplementationMap<T>::Iterator& iterator) {
+      [other](const typename MapBasedHuffmanTable<T>::Iterator& iterator) {
         return iterator ==
-               other.implementation.template as<
-                   typename HuffmanTableImplementationMap<T>::Iterator>();
+               other.implementation
+                   .template as<typename MapBasedHuffmanTable<T>::Iterator>();
       });
 }
 
 template <typename T>
-bool HuffmanTableImplementationGeneric<T>::Iterator::operator!=(
-    const HuffmanTableImplementationGeneric<T>::Iterator& other) const {
+bool GenericHuffmanTable<T>::Iterator::operator!=(
+    const GenericHuffmanTable<T>::Iterator& other) const {
   return implementation.match(
-      [other](const typename HuffmanTableImplementationSaturated<T>::Iterator&
-                  iterator) {
+      [other](const typename SingleLookupHuffmanTable<T>::Iterator& iterator) {
         return iterator !=
                other.implementation.template as<
-                   typename HuffmanTableImplementationSaturated<T>::Iterator>();
+                   typename SingleLookupHuffmanTable<T>::Iterator>();
       },
-      [other](
-          const typename HuffmanTableImplementationMap<T>::Iterator& iterator) {
+      [other](const typename MapBasedHuffmanTable<T>::Iterator& iterator) {
         return iterator !=
-               other.implementation.template as<
-                   typename HuffmanTableImplementationMap<T>::Iterator>();
+               other.implementation
+                   .template as<typename MapBasedHuffmanTable<T>::Iterator>();
       });
 }
 
 template <typename T>
-const T* HuffmanTableImplementationGeneric<T>::Iterator::operator*() const {
+const T* GenericHuffmanTable<T>::Iterator::operator*() const {
   return implementation.match(
-      [](const typename HuffmanTableImplementationSaturated<T>::Iterator&
-             iterator) { return iterator.operator*(); },
-      [](const typename HuffmanTableImplementationMap<T>::Iterator& iterator) {
+      [](const typename SingleLookupHuffmanTable<T>::Iterator& iterator) {
+        return iterator.operator*();
+      },
+      [](const typename MapBasedHuffmanTable<T>::Iterator& iterator) {
         return iterator.operator*();
       });
 }
 
 template <typename T>
-HuffmanTableImplementationGeneric<T>::HuffmanTableImplementationGeneric(
-    JSContext*)
+GenericHuffmanTable<T>::GenericHuffmanTable(JSContext*)
     : implementation(HuffmanTableUnreachable{}) {}
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationGeneric<T>::initComplete() {
+JS::Result<Ok> GenericHuffmanTable<T>::initComplete() {
   return this->implementation.match(
-      [](HuffmanTableImplementationSaturated<T>& implementation) -> JS::Result<Ok> {
+      [](SingleLookupHuffmanTable<T>& implementation) {
+        return implementation.initComplete();
+      },
+      [](MapBasedHuffmanTable<T>& implementation) {
         return implementation.initComplete();
       },
-      [](HuffmanTableImplementationMap<T>& implementation) -> JS::Result<Ok> {
-        return implementation.initComplete();
+      [](HuffmanTableUnreachable&) {
+        MOZ_CRASH("GenericHuffmanTable is unitialized!");
+      });
+}
+
+template <typename T>
+typename GenericHuffmanTable<T>::Iterator GenericHuffmanTable<T>::begin()
+    const {
+  return this->implementation.match(
+      [](const SingleLookupHuffmanTable<T>& implementation)
+          -> GenericHuffmanTable<T>::Iterator {
+        return Iterator(implementation.begin());
       },
-      [](HuffmanTableUnreachable&) -> JS::Result<Ok> {
-        MOZ_CRASH("HuffmanTableImplementationGeneric is unitialized!");
-        return Ok();
+      [](const MapBasedHuffmanTable<T>& implementation)
+          -> GenericHuffmanTable<T>::Iterator {
+        return Iterator(implementation.begin());
+      },
+      [](const HuffmanTableUnreachable&) -> GenericHuffmanTable<T>::Iterator {
+        MOZ_CRASH("GenericHuffmanTable is unitialized!");
       });
 }
 
 template <typename T>
-typename HuffmanTableImplementationGeneric<T>::Iterator
-HuffmanTableImplementationGeneric<T>::begin() const {
+typename GenericHuffmanTable<T>::Iterator GenericHuffmanTable<T>::end() const {
   return this->implementation.match(
-      [](const HuffmanTableImplementationSaturated<T>& implementation)
-          -> HuffmanTableImplementationGeneric<T>::Iterator {
-        return Iterator(implementation.begin());
+      [](const SingleLookupHuffmanTable<T>& implementation)
+          -> GenericHuffmanTable<T>::Iterator {
+        return Iterator(implementation.end());
       },
-      [](const HuffmanTableImplementationMap<T>& implementation)
-          -> HuffmanTableImplementationGeneric<T>::Iterator {
-        return Iterator(implementation.begin());
+      [](const MapBasedHuffmanTable<T>& implementation)
+          -> GenericHuffmanTable<T>::Iterator {
+        return Iterator(implementation.end());
       },
-      [](const HuffmanTableUnreachable&)
-          -> HuffmanTableImplementationGeneric<T>::Iterator {
-        MOZ_CRASH("HuffmanTableImplementationGeneric is unitialized!");
+      [](const HuffmanTableUnreachable&) -> GenericHuffmanTable<T>::Iterator {
+        MOZ_CRASH("GenericHuffmanTable is unitialized!");
       });
 }
 
 template <typename T>
-typename HuffmanTableImplementationGeneric<T>::Iterator
-HuffmanTableImplementationGeneric<T>::end() const {
-  return this->implementation.match(
-      [](const HuffmanTableImplementationSaturated<T>& implementation)
-          -> HuffmanTableImplementationGeneric<T>::Iterator {
-        return Iterator(implementation.end());
-      },
-      [](const HuffmanTableImplementationMap<T>& implementation)
-          -> HuffmanTableImplementationGeneric<T>::Iterator {
-        return Iterator(implementation.end());
-      },
-      [](const HuffmanTableUnreachable&)
-          -> HuffmanTableImplementationGeneric<T>::Iterator {
-        MOZ_CRASH("HuffmanTableImplementationGeneric is unitialized!");
-      });
-}
-
-template <typename T>
-JS::Result<Ok> HuffmanTableImplementationGeneric<T>::initWithSingleValue(
-    JSContext* cx, T&& value) {
+JS::Result<Ok> GenericHuffmanTable<T>::initWithSingleValue(JSContext* cx,
+                                                           T&& value) {
   // Only one value: use HuffmanImplementationSaturated
   MOZ_ASSERT(this->implementation.template is<
              HuffmanTableUnreachable>());  // Make sure that we're initializing.
 
-  this->implementation = {
-      mozilla::VariantType<HuffmanTableImplementationSaturated<T>>{}, cx};
+  this->implementation = {mozilla::VariantType<SingleLookupHuffmanTable<T>>{},
+                          cx};
 
-  MOZ_TRY(
-      this->implementation.template as<HuffmanTableImplementationSaturated<T>>()
-          .initWithSingleValue(cx, std::move(value)));
+  MOZ_TRY(this->implementation.template as<SingleLookupHuffmanTable<T>>()
+              .initWithSingleValue(cx, std::move(value)));
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationGeneric<T>::initStart(
-    JSContext* cx, size_t numberOfSymbols, uint8_t maxBitLength) {
+JS::Result<Ok> GenericHuffmanTable<T>::initStart(JSContext* cx,
+                                                 size_t numberOfSymbols,
+                                                 uint8_t maxBitLength) {
   MOZ_ASSERT(this->implementation.template is<
              HuffmanTableUnreachable>());  // Make sure that we're initializing.
   if (
       // If the bit length is too large, don't put it in a saturated table
       // as this would need too much space.
       maxBitLength > MAX_BIT_LENGTH_IN_SATURATED_TABLE ||
       // If there are too many symbols, don't put it in a saturated table
       // as indices  wouldn't fit into `InternalIndex` .
       numberOfSymbols >
-          mozilla::MaxValue<typename HuffmanTableImplementationSaturated<
-              T>::InternalIndex>::value) {
-    this->implementation = {
-        mozilla::VariantType<HuffmanTableImplementationMap<T>>{}, cx};
-    MOZ_TRY(this->implementation.template as<HuffmanTableImplementationMap<T>>()
-                .initStart(cx, numberOfSymbols, maxBitLength));
+          mozilla::MaxValue<
+              typename SingleLookupHuffmanTable<T>::InternalIndex>::value) {
+    this->implementation = {mozilla::VariantType<MapBasedHuffmanTable<T>>{},
+                            cx};
+    MOZ_TRY(
+        this->implementation.template as<MapBasedHuffmanTable<T>>().initStart(
+            cx, numberOfSymbols, maxBitLength));
   } else {
-    this->implementation = {
-        mozilla::VariantType<HuffmanTableImplementationSaturated<T>>{}, cx};
-    MOZ_TRY(this->implementation
-                .template as<HuffmanTableImplementationSaturated<T>>()
+    this->implementation = {mozilla::VariantType<SingleLookupHuffmanTable<T>>{},
+                            cx};
+    MOZ_TRY(this->implementation.template as<SingleLookupHuffmanTable<T>>()
                 .initStart(cx, numberOfSymbols, maxBitLength));
   }
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationGeneric<T>::addSymbol(
-    uint32_t bits, uint8_t bitLength, T&& value) {
+JS::Result<Ok> GenericHuffmanTable<T>::addSymbol(uint32_t bits,
+                                                 uint8_t bitLength, T&& value) {
   return this->implementation.match(
       [bits, bitLength, value = std::move(value)](
-          HuffmanTableImplementationSaturated<T>&
+          SingleLookupHuffmanTable<T>&
               implementation) mutable /* discard implicit const */
       -> JS::Result<Ok> {
         return implementation.addSymbol(bits, bitLength, std::move(value));
       },
       [bits, bitLength, value = std::move(value)](
-          HuffmanTableImplementationMap<T>&
+          MapBasedHuffmanTable<T>&
               implementation) mutable /* discard implicit const */
       -> JS::Result<Ok> {
         return implementation.addSymbol(bits, bitLength, std::move(value));
       },
       [](HuffmanTableUnreachable&) -> JS::Result<Ok> {
-        MOZ_CRASH("HuffmanTableImplementationGeneric is unitialized!");
+        MOZ_CRASH("GenericHuffmanTable is unitialized!");
         return Ok();
       });
 }
 
 template <typename T>
-HuffmanEntry<const T*> HuffmanTableImplementationGeneric<T>::lookup(
+HuffmanEntry<const T*> GenericHuffmanTable<T>::lookup(
     HuffmanLookup lookup) const {
   return this->implementation.match(
-      [lookup](const HuffmanTableImplementationSaturated<T>& implementation)
+      [lookup](const SingleLookupHuffmanTable<T>& implementation)
           -> HuffmanEntry<const T*> { return implementation.lookup(lookup); },
-      [lookup](const HuffmanTableImplementationMap<T>& implementation)
+      [lookup](const MapBasedHuffmanTable<T>& implementation)
           -> HuffmanEntry<const T*> { return implementation.lookup(lookup); },
       [](const HuffmanTableUnreachable&) -> HuffmanEntry<const T*> {
-        MOZ_CRASH("HuffmanTableImplementationGeneric is unitialized!");
+        MOZ_CRASH("GenericHuffmanTable is unitialized!");
       });
 }
 
 template <typename T, int N>
-JS::Result<Ok> HuffmanTableImplementationNaive<T, N>::initWithSingleValue(
-    JSContext* cx, T&& value) {
+JS::Result<Ok> NaiveHuffmanTable<T, N>::initWithSingleValue(JSContext* cx,
+                                                            T&& value) {
   MOZ_ASSERT(values.empty());  // Make sure that we're initializing.
   if (!values.append(HuffmanEntry<T>(0, 0, std::move(value)))) {
     return cx->alreadyReportedError();
   }
   return Ok();
 }
 
 template <typename T, int N>
-JS::Result<Ok> HuffmanTableImplementationNaive<T, N>::initStart(
-    JSContext* cx, size_t numberOfSymbols, uint8_t) {
+JS::Result<Ok> NaiveHuffmanTable<T, N>::initStart(JSContext* cx,
+                                                  size_t numberOfSymbols,
+                                                  uint8_t) {
   MOZ_ASSERT(values.empty());  // Make sure that we're initializing.
   if (!values.initCapacity(numberOfSymbols)) {
     return cx->alreadyReportedError();
   }
   return Ok();
 }
 
 template <typename T, int N>
-JS::Result<Ok> HuffmanTableImplementationNaive<T, N>::initComplete() {
+JS::Result<Ok> NaiveHuffmanTable<T, N>::initComplete() {
   MOZ_ASSERT(values.length() <= N);
   return Ok();
 }
 
 template <typename T, int N>
-JS::Result<Ok> HuffmanTableImplementationNaive<T, N>::addSymbol(
-    uint32_t bits, uint8_t bitLength, T&& value) {
+JS::Result<Ok> NaiveHuffmanTable<T, N>::addSymbol(uint32_t bits,
+                                                  uint8_t bitLength,
+                                                  T&& value) {
   MOZ_ASSERT(bitLength != 0,
              "Adding a symbol with a bitLength of 0 doesn't make sense.");
   MOZ_ASSERT(values.empty() || values.back().key.bitLength <= bitLength,
              "Symbols must be ranked by increasing bits length");
   MOZ_ASSERT_IF(bitLength != 32 /* >> 32 is UB */, bits >> bitLength == 0);
   if (!values.emplaceBack(bits, bitLength, std::move(value))) {
     MOZ_CRASH();  // Memory was reserved in `init()`.
   }
 
   return Ok();
 }
 
 template <typename T, int N>
-HuffmanEntry<const T*> HuffmanTableImplementationNaive<T, N>::lookup(
+HuffmanEntry<const T*> NaiveHuffmanTable<T, N>::lookup(
     HuffmanLookup key) const {
   // This current implementation is O(length) and designed mostly for testing.
   // Future versions will presumably adapt the underlying data structure to
   // provide bounded-time lookup.
   for (const auto& iter : values) {
     if (iter.key.bitLength > key.bitLength) {
       // We can't find the entry.
       break;
@@ -1892,131 +1886,132 @@ HuffmanEntry<const T*> HuffmanTableImple
     }
   }
 
   // Error: no entry found.
   return HuffmanEntry<const T*>(0, 0, nullptr);
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationMap<T>::initWithSingleValue(
-    JSContext* cx, T&& value) {
+JS::Result<Ok> MapBasedHuffmanTable<T>::initWithSingleValue(JSContext* cx,
+                                                            T&& value) {
   MOZ_ASSERT(values.empty());  // Make sure that we're initializing.
   const HuffmanKey key(0, 0);
   if (!values.put(FlatHuffmanKey(key), std::move(value)) || !keys.append(key)) {
     ReportOutOfMemory(cx);
     return cx->alreadyReportedError();
   }
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationMap<T>::initStart(
-    JSContext* cx, size_t numberOfSymbols, uint8_t) {
+JS::Result<Ok> MapBasedHuffmanTable<T>::initStart(JSContext* cx,
+                                                  size_t numberOfSymbols,
+                                                  uint8_t) {
   MOZ_ASSERT(values.empty());  // Make sure that we're initializing.
   if (!values.reserve(numberOfSymbols) || !keys.reserve(numberOfSymbols)) {
     ReportOutOfMemory(cx);
     return cx->alreadyReportedError();
   }
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationMap<T>::initComplete() {
+JS::Result<Ok> MapBasedHuffmanTable<T>::initComplete() {
 #if DEBUG
   // Check that there is a bijection between `keys` and `values`.
   // 1. Injection.
   for (const auto& key : keys) {
     if (!values.has(FlatHuffmanKey(key))) {
       MOZ_CRASH();
     }
   }
   // 2. Cardinality.
   MOZ_ASSERT(values.count() == keys.length());
 #endif  // DEBUG
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationMap<T>::addSymbol(uint32_t bits,
-                                                           uint8_t bitLength,
-                                                           T&& value) {
+JS::Result<Ok> MapBasedHuffmanTable<T>::addSymbol(uint32_t bits,
+                                                  uint8_t bitLength,
+                                                  T&& value) {
   MOZ_ASSERT(bitLength != 0,
              "Adding a symbol with a bitLength of 0 doesn't make sense.");
   MOZ_ASSERT_IF(bitLength != 32 /* >> 32 is UB */, bits >> bitLength == 0);
   const HuffmanKey key(bits, bitLength);
   const FlatHuffmanKey flat(key);
   values.putNewInfallible(
       flat, std::move(value));  // Memory was reserved in `init()`.
   keys.infallibleAppend(std::move(key));
 
   return Ok();
 }
 
 template <typename T>
-HuffmanEntry<const T*> HuffmanTableImplementationMap<T>::lookup(
+HuffmanEntry<const T*> MapBasedHuffmanTable<T>::lookup(
     HuffmanLookup lookup) const {
   for (auto bitLength = 0; bitLength < MAX_CODE_BIT_LENGTH; ++bitLength) {
     const uint32_t bits = lookup.leadingBits(bitLength);
     const HuffmanKey key(bits, bitLength);
     const FlatHuffmanKey flat(key);
     if (auto ptr = values.lookup(flat)) {
       // Entry found.
       return HuffmanEntry<const T*>(bits, bitLength, &ptr->value());
     }
   }
 
   // Error: no entry found.
   return HuffmanEntry<const T*>(0, 0, nullptr);
 }
 
 template <typename T>
-HuffmanTableImplementationSaturated<T>::Iterator::Iterator(
-    const HuffmanEntry<T>* position)
+SingleLookupHuffmanTable<T>::Iterator::Iterator(const HuffmanEntry<T>* position)
     : position(position) {}
 
 template <typename T>
-void HuffmanTableImplementationSaturated<T>::Iterator::operator++() {
+void SingleLookupHuffmanTable<T>::Iterator::operator++() {
   position++;
 }
 
 template <typename T>
-const T* HuffmanTableImplementationSaturated<T>::Iterator::operator*() const {
+const T* SingleLookupHuffmanTable<T>::Iterator::operator*() const {
   return &position->value;
 }
 
 template <typename T>
-bool HuffmanTableImplementationSaturated<T>::Iterator::operator==(
+bool SingleLookupHuffmanTable<T>::Iterator::operator==(
     const Iterator& other) const {
   return position == other.position;
 }
 
 template <typename T>
-bool HuffmanTableImplementationSaturated<T>::Iterator::operator!=(
+bool SingleLookupHuffmanTable<T>::Iterator::operator!=(
     const Iterator& other) const {
   return position != other.position;
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationSaturated<T>::initWithSingleValue(
-    JSContext* cx, T&& value) {
+JS::Result<Ok> SingleLookupHuffmanTable<T>::initWithSingleValue(JSContext* cx,
+                                                                T&& value) {
   MOZ_ASSERT(values.empty());  // Make sure that we're initializing.
   if (!values.emplaceBack(0, 0, std::move(value))) {
     return cx->alreadyReportedError();
   }
   if (!saturated.emplaceBack(0)) {
     return cx->alreadyReportedError();
   }
   this->maxBitLength = 0;
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationSaturated<T>::initStart(
-    JSContext* cx, size_t numberOfSymbols, uint8_t maxBitLength) {
+JS::Result<Ok> SingleLookupHuffmanTable<T>::initStart(JSContext* cx,
+                                                      size_t numberOfSymbols,
+                                                      uint8_t maxBitLength) {
   MOZ_ASSERT(maxBitLength <= MAX_BIT_LENGTH_IN_SATURATED_TABLE);
   MOZ_ASSERT(values.empty());  // Make sure that we're initializing.
 
   this->maxBitLength = maxBitLength;
 
   if (!values.initCapacity(numberOfSymbols)) {
     return cx->alreadyReportedError();
   }
@@ -2028,17 +2023,17 @@ JS::Result<Ok> HuffmanTableImplementatio
   for (size_t i = 0; i < saturatedLength; ++i) {
     // Capacity reserved in this method.
     saturated.infallibleAppend(uint8_t(-1));
   }
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationSaturated<T>::initComplete() {
+JS::Result<Ok> SingleLookupHuffmanTable<T>::initComplete() {
   // Double-check that we've initialized properly.
   MOZ_ASSERT(this->maxBitLength <= MAX_CODE_BIT_LENGTH);
 #ifdef DEBUG
   bool foundMaxBitLength = false;
   for (size_t i = 0; i < saturated.length(); ++i) {
     // Check that all indices have been properly initialized.
     // Note: this is an explicit `for(;;)` loop instead of
     // a `for(:)` range loop, as knowing `i` should simplify
@@ -2050,18 +2045,19 @@ JS::Result<Ok> HuffmanTableImplementatio
     }
   }
   MOZ_ASSERT(foundMaxBitLength);
 #endif  // DEBUG
   return Ok();
 }
 
 template <typename T>
-JS::Result<Ok> HuffmanTableImplementationSaturated<T>::addSymbol(
-    uint32_t bits, uint8_t bitLength, T&& value) {
+JS::Result<Ok> SingleLookupHuffmanTable<T>::addSymbol(uint32_t bits,
+                                                      uint8_t bitLength,
+                                                      T&& value) {
   MOZ_ASSERT(bitLength != 0,
              "Adding a symbol with a bitLength of 0 doesn't make sense.");
   MOZ_ASSERT(values.empty() || values.back().key.bitLength <= bitLength,
              "Symbols must be ranked by increasing bits length");
   MOZ_ASSERT_IF(bitLength != 32 /* >> 32 is UB */, bits >> bitLength == 0);
   MOZ_ASSERT(bitLength <= maxBitLength);
 
   const size_t index = values.length();
@@ -2095,17 +2091,17 @@ JS::Result<Ok> HuffmanTableImplementatio
   for (size_t i = begin; i < begin + length; ++i) {
     saturated[i] = index;
   }
 
   return Ok();
 }
 
 template <typename T>
-HuffmanEntry<const T*> HuffmanTableImplementationSaturated<T>::lookup(
+HuffmanEntry<const T*> SingleLookupHuffmanTable<T>::lookup(
     HuffmanLookup key) const {
   // Take the `maxBitLength` highest weight bits of `key`.
   // In the documentation of `addSymbol`, this is
   // `0bB...B`.
   const uint32_t bits = key.leadingBits(maxBitLength);
 
   // Invariants: `saturated.length() == 1 << maxBitLength`
   // and `bits <= 1 << maxBitLength`.
--- a/js/src/frontend/BinASTTokenReaderContext.h
+++ b/js/src/frontend/BinASTTokenReaderContext.h
@@ -177,20 +177,20 @@ enum class Nullable {
   Null,
   NonNull,
 };
 
 // An implementation of Huffman Tables as a vector, with `O(entries)`
 // lookup. Performance-wise, this implementation only makes sense for
 // very short tables.
 template <typename T, int N = HUFFMAN_TABLE_DEFAULT_INLINE_BUFFER_LENGTH>
-class HuffmanTableImplementationNaive {
+class NaiveHuffmanTable {
  public:
-  explicit HuffmanTableImplementationNaive(JSContext* cx) : values(cx) {}
-  HuffmanTableImplementationNaive(HuffmanTableImplementationNaive&& other)
+  explicit NaiveHuffmanTable(JSContext* cx) : values(cx) {}
+  NaiveHuffmanTable(NaiveHuffmanTable&& other) noexcept
       : values(std::move(other.values)) {}
 
   // Initialize a Huffman table containing a single value.
   JS::Result<Ok> initWithSingleValue(JSContext* cx, T&& value);
 
   // Initialize a Huffman table containing `numberOfSymbols`.
   // Symbols must be added with `addSymbol`.
   // If you initialize with `initStart`, you MUST call `initComplete()`
@@ -198,18 +198,18 @@ class HuffmanTableImplementationNaive {
   JS::Result<Ok> initStart(JSContext* cx, size_t numberOfSymbols,
                            uint8_t maxBitLength);
 
   JS::Result<Ok> initComplete();
 
   // Add a symbol to a value.
   JS::Result<Ok> addSymbol(uint32_t bits, uint8_t bits_length, T&& value);
 
-  HuffmanTableImplementationNaive() = delete;
-  HuffmanTableImplementationNaive(HuffmanTableImplementationNaive&) = delete;
+  NaiveHuffmanTable() = delete;
+  NaiveHuffmanTable(NaiveHuffmanTable&) = delete;
 
   // Lookup a value in the table.
   //
   // Return an entry with a value of `nullptr` if the value is not in the table.
   //
   // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a
   // table with a single instance, or if the value is not in the table, it
   // will advance by 0 bits. The caller is responsible for advancing its
@@ -227,37 +227,36 @@ class HuffmanTableImplementationNaive {
   // a bitlength by increasing value of `bits`. This representation
   // is good for small tables, but in the future, we may adopt a
   // representation more optimized for larger tables.
   Vector<HuffmanEntry<T>, N> values;
   friend class HuffmanPreludeReader;
 };
 
 // An implementation of Huffman Tables as a hash map. Space-Efficient,
-// faster than HuffmanTableImplementationNaive for large tables but not terribly
+// faster than NaiveHuffmanTable for large tables but not terribly
 // fast, either.
 //
 // Complexity:
 //
 // - We assume that hashing is sufficient to guarantee `O(1)` lookups
 //   inside the hashmap.
 // - On a well-formed file, all lookups are successful and a Huffman
 //   lookup will take exactly `bitLen` Hashmap lookups. This makes it
 //   `O(MAX_CODE_BIT_LENGTH)` worst case. This also makes it
 //   `O(ln(N))` in the best case (perfectly balanced Huffman table)
 //   and `O(N)` in the worst case (perfectly linear Huffman table),
 //   where `N` is the number of entries.
 // - On an invalid file, the number of lookups is also bounded by
 //   `MAX_CODE_BIT_LENGTH`.
 template <typename T>
-class HuffmanTableImplementationMap {
+class MapBasedHuffmanTable {
  public:
-  explicit HuffmanTableImplementationMap(JSContext* cx)
-      : values(cx), keys(cx) {}
-  HuffmanTableImplementationMap(HuffmanTableImplementationMap&& other) noexcept
+  explicit MapBasedHuffmanTable(JSContext* cx) : values(cx), keys(cx) {}
+  MapBasedHuffmanTable(MapBasedHuffmanTable&& other) noexcept
       : values(std::move(other.values)), keys(std::move(other.keys)) {}
 
   // Initialize a Huffman table containing a single value.
   JS::Result<Ok> initWithSingleValue(JSContext* cx, T&& value);
 
   // Initialize a Huffman table containing `numberOfSymbols`.
   // Symbols must be added with `addSymbol`.
   // If you initialize with `initStart`, you MUST call `initComplete()`
@@ -265,18 +264,18 @@ class HuffmanTableImplementationMap {
   JS::Result<Ok> initStart(JSContext* cx, size_t numberOfSymbols,
                            uint8_t maxBitLength);
 
   // Add a `(bit, bits_length) => value` mapping.
   JS::Result<Ok> addSymbol(uint32_t bits, uint8_t bits_length, T&& value);
 
   JS::Result<Ok> initComplete();
 
-  HuffmanTableImplementationMap() = delete;
-  HuffmanTableImplementationMap(HuffmanTableImplementationMap&) = delete;
+  MapBasedHuffmanTable() = delete;
+  MapBasedHuffmanTable(MapBasedHuffmanTable&) = delete;
 
   // Lookup a value in the table.
   //
   // Return an entry with a value of `nullptr` if the value is not in the table.
   //
   // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a
   // table with a single instance, or if the value is not in the table, it
   // will advance by 0 bits. The caller is responsible for advancing its
@@ -330,17 +329,17 @@ class HuffmanTableImplementationMap {
 //
 // # Time complexity
 //
 // Lookups take constant time, which essentially consists in two
 // simple vector lookups.
 //
 // # Space complexity
 //
-// After initialization, a `HuffmanTableImplementationSaturated`
+// After initialization, a `SingleLookupHuffmanTable`
 // requires O(2 ^ max bit length in the table) space:
 //
 // - A vector `values` containing one entry per symbol.
 // - A vector `saturated` containing exactly 2 ^ (max bit length in the
 //   table) entries, which we use to map any combination of `maxBitLength`
 //   bits onto the only `HuffmanEntry` that may be reached by a prefix
 //   of these `maxBitLength` bits. See below for more details.
 //
@@ -393,41 +392,39 @@ class HuffmanTableImplementationMap {
 // By using the next 5 bits in the bit buffer, we may, in
 // a single lookup, determine the symbol and the bit length.
 //
 // In the current implementation, to save some space, we have
 // two distinct arrays, one (`values`) with a single instance of each
 // symbols bit length, and one (`saturated`) with indices into that
 // array.
 template <typename T>
-class HuffmanTableImplementationSaturated {
+class SingleLookupHuffmanTable {
  public:
-  explicit HuffmanTableImplementationSaturated(JSContext* cx)
+  explicit SingleLookupHuffmanTable(JSContext* cx)
       : values(cx), saturated(cx), maxBitLength(-1) {}
-  HuffmanTableImplementationSaturated(
-      HuffmanTableImplementationSaturated&& other) = default;
+  SingleLookupHuffmanTable(SingleLookupHuffmanTable&& other) noexcept = default;
 
   // Initialize a Huffman table containing a single value.
   JS::Result<Ok> initWithSingleValue(JSContext* cx, T&& value);
 
   // Initialize a Huffman table containing `numberOfSymbols`.
   // Symbols must be added with `addSymbol`.
   // If you initialize with `initStart`, you MUST call `initComplete()`
   // at the end of initialization.
   JS::Result<Ok> initStart(JSContext* cx, size_t numberOfSymbols,
                            uint8_t maxBitLength);
 
   JS::Result<Ok> initComplete();
 
   // Add a `(bit, bits_length) => value` mapping.
   JS::Result<Ok> addSymbol(uint32_t bits, uint8_t bits_length, T&& value);
 
-  HuffmanTableImplementationSaturated() = delete;
-  HuffmanTableImplementationSaturated(HuffmanTableImplementationSaturated&) =
-      delete;
+  SingleLookupHuffmanTable() = delete;
+  SingleLookupHuffmanTable(SingleLookupHuffmanTable&) = delete;
 
   // Lookup a value in the table.
   //
   // Return an entry with a value of `nullptr` if the value is not in the table.
   //
   // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a
   // table with a single instance, or if the value is not in the table, it
   // will advance by 0 bits. The caller is responsible for advancing its
@@ -481,26 +478,26 @@ class HuffmanTableImplementationSaturate
   friend class HuffmanPreludeReader;
 };
 
 // An empty Huffman table. Attempting to get a value from this table is a syntax
 // error. This is the default value for `HuffmanTableValue` and represents all
 // states that may not be reached.
 //
 // Part of variants `HuffmanTableValue`, `HuffmanTableListLength` and
-// `HuffmanTableImplementationGeneric::implementation`.
+// `GenericHuffmanTable::implementation`.
 struct HuffmanTableUnreachable {};
 
 // Generic implementation of Huffman tables.
 //
 //
 template <typename T>
-struct HuffmanTableImplementationGeneric {
-  explicit HuffmanTableImplementationGeneric(JSContext* cx);
-  explicit HuffmanTableImplementationGeneric() = delete;
+struct GenericHuffmanTable {
+  explicit GenericHuffmanTable(JSContext* cx);
+  explicit GenericHuffmanTable() = delete;
 
   // Initialize a Huffman table containing a single value.
   JS::Result<Ok> initWithSingleValue(JSContext* cx, T&& value);
 
   // Initialize a Huffman table containing `numberOfSymbols`.
   // Symbols must be added with `addSymbol`.
   // If you initialize with `initStart`, you MUST call `initComplete()`
   // at the end of initialization.
@@ -511,29 +508,28 @@ struct HuffmanTableImplementationGeneric
   JS::Result<Ok> addSymbol(uint32_t bits, uint8_t bits_length, T&& value);
 
   JS::Result<Ok> initComplete();
 
   // The number of values in the table.
   size_t length() const;
 
   struct Iterator {
-    explicit Iterator(
-        typename HuffmanTableImplementationSaturated<T>::Iterator&&);
-    explicit Iterator(typename HuffmanTableImplementationMap<T>::Iterator&&);
+    explicit Iterator(typename SingleLookupHuffmanTable<T>::Iterator&&);
+    explicit Iterator(typename MapBasedHuffmanTable<T>::Iterator&&);
     Iterator(Iterator&&) = default;
     Iterator(const Iterator&) = default;
     void operator++();
     const T* operator*() const;
     bool operator==(const Iterator& other) const;
     bool operator!=(const Iterator& other) const;
 
    private:
-    mozilla::Variant<typename HuffmanTableImplementationSaturated<T>::Iterator,
-                     typename HuffmanTableImplementationMap<T>::Iterator>
+    mozilla::Variant<typename SingleLookupHuffmanTable<T>::Iterator,
+                     typename MapBasedHuffmanTable<T>::Iterator>
         implementation;
   };
 
   // Iterating in the order of insertion.
   Iterator begin() const;
   Iterator end() const;
 
   // Lookup a value in the table.
@@ -542,118 +538,112 @@ struct HuffmanTableImplementationGeneric
   //
   // The lookup may advance `key` by `[0, key.bitLength]` bits. Typically, in a
   // table with a single instance, or if the value is not in the table, it
   // will advance by 0 bits. The caller is responsible for advancing its
   // bitstream by `result.key.bitLength` bits.
   HuffmanEntry<const T*> lookup(HuffmanLookup key) const;
 
  private:
-  mozilla::Variant<HuffmanTableImplementationSaturated<T>,
-                   HuffmanTableImplementationMap<T>, HuffmanTableUnreachable>
+  mozilla::Variant<SingleLookupHuffmanTable<T>, MapBasedHuffmanTable<T>,
+                   HuffmanTableUnreachable>
       implementation;
 };
 
 // While reading the Huffman prelude, whenever we first encounter a
 // `HuffmanTableUnreachable`, we replace it with a `HuffmanTableInitializing`
 // to mark that we should not attempt to read/initialize it again.
 //
 // Attempting to get a value from this table is an internal error.
 //
 // Part of variants `HuffmanTableValue` and `HuffmanTableListLength`.
 struct HuffmanTableInitializing {};
 
 // These classes are all parts of variant `HuffmanTableValue`.
 
-struct HuffmanTableExplicitSymbolsF64
-    : HuffmanTableImplementationGeneric<double> {
+struct HuffmanTableExplicitSymbolsF64 : GenericHuffmanTable<double> {
   using Contents = double;
   explicit HuffmanTableExplicitSymbolsF64(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
-struct HuffmanTableExplicitSymbolsU32
-    : HuffmanTableImplementationGeneric<uint32_t> {
+struct HuffmanTableExplicitSymbolsU32 : GenericHuffmanTable<uint32_t> {
   using Contents = uint32_t;
   explicit HuffmanTableExplicitSymbolsU32(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
-struct HuffmanTableIndexedSymbolsSum
-    : HuffmanTableImplementationGeneric<BinASTKind> {
+struct HuffmanTableIndexedSymbolsSum : GenericHuffmanTable<BinASTKind> {
   using Contents = BinASTKind;
   explicit HuffmanTableIndexedSymbolsSum(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
-struct HuffmanTableIndexedSymbolsBool
-    : HuffmanTableImplementationNaive<bool, 2> {
+struct HuffmanTableIndexedSymbolsBool : NaiveHuffmanTable<bool, 2> {
   using Contents = bool;
   explicit HuffmanTableIndexedSymbolsBool(JSContext* cx)
-      : HuffmanTableImplementationNaive(cx) {}
+      : NaiveHuffmanTable(cx) {}
 };
 
 // A Huffman table that may only ever contain two values:
 // `BinASTKind::_Null` and another `BinASTKind`.
 struct HuffmanTableIndexedSymbolsMaybeInterface
-    : HuffmanTableImplementationNaive<BinASTKind, 2> {
+    : NaiveHuffmanTable<BinASTKind, 2> {
   using Contents = BinASTKind;
   explicit HuffmanTableIndexedSymbolsMaybeInterface(JSContext* cx)
-      : HuffmanTableImplementationNaive(cx) {}
+      : NaiveHuffmanTable(cx) {}
 
   // `true` if this table only contains values for `null`.
   bool isAlwaysNull() const {
     MOZ_ASSERT(length() > 0);
 
     // By definition, we have either 1 or 2 values.
     // By definition, if we have 2 values, one of them is not null.
     if (length() != 1) {
       return false;
     }
     // Otherwise, check the single value.
     return begin()->value == BinASTKind::_Null;
   }
 };
 
 struct HuffmanTableIndexedSymbolsStringEnum
-    : HuffmanTableImplementationGeneric<BinASTVariant> {
+    : GenericHuffmanTable<BinASTVariant> {
   using Contents = BinASTVariant;
   explicit HuffmanTableIndexedSymbolsStringEnum(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
-struct HuffmanTableIndexedSymbolsLiteralString
-    : HuffmanTableImplementationGeneric<JSAtom*> {
+struct HuffmanTableIndexedSymbolsLiteralString : GenericHuffmanTable<JSAtom*> {
   using Contents = JSAtom*;
   explicit HuffmanTableIndexedSymbolsLiteralString(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
 struct HuffmanTableIndexedSymbolsOptionalLiteralString
-    : HuffmanTableImplementationGeneric<JSAtom*> {
+    : GenericHuffmanTable<JSAtom*> {
   using Contents = JSAtom*;
   explicit HuffmanTableIndexedSymbolsOptionalLiteralString(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
 // A single Huffman table, used for values.
 using HuffmanTableValue = mozilla::Variant<
     HuffmanTableUnreachable,  // Default value.
     HuffmanTableInitializing, HuffmanTableExplicitSymbolsF64,
     HuffmanTableExplicitSymbolsU32, HuffmanTableIndexedSymbolsSum,
     HuffmanTableIndexedSymbolsMaybeInterface, HuffmanTableIndexedSymbolsBool,
     HuffmanTableIndexedSymbolsStringEnum,
     HuffmanTableIndexedSymbolsLiteralString,
     HuffmanTableIndexedSymbolsOptionalLiteralString>;
 
-struct HuffmanTableExplicitSymbolsListLength
-    : HuffmanTableImplementationGeneric<uint32_t> {
+struct HuffmanTableExplicitSymbolsListLength : GenericHuffmanTable<uint32_t> {
   using Contents = uint32_t;
   explicit HuffmanTableExplicitSymbolsListLength(JSContext* cx)
-      : HuffmanTableImplementationGeneric(cx) {}
+      : GenericHuffmanTable(cx) {}
 };
 
 // A single Huffman table, specialized for list lengths.
 using HuffmanTableListLength =
     mozilla::Variant<HuffmanTableUnreachable,  // Default value.
                      HuffmanTableInitializing,
                      HuffmanTableExplicitSymbolsListLength>;