зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1587678 - Part 3: Remove unnecessary JSContext* parameter. r=Yoric
Differential Revision: https://phabricator.services.mozilla.com/D49565 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
12567c5c43
Коммит
830d7f72e0
|
@ -544,7 +544,7 @@ class HuffmanPreludeReader {
|
|||
auto& table = dictionary_.tableForField(identity);
|
||||
if (table.is<HuffmanTableUnreachable>()) {
|
||||
// Effectively, an `Interface` is a sum with a single entry.
|
||||
HuffmanTableIndexedSymbolsSum sum(cx_);
|
||||
HuffmanTableIndexedSymbolsSum sum;
|
||||
MOZ_TRY(sum.initWithSingleValue(
|
||||
cx_, BinASTSymbol::fromKind(BinASTKind(interface.kind_))));
|
||||
table = {mozilla::VariantType<HuffmanTableIndexedSymbolsSum>{},
|
||||
|
@ -855,7 +855,7 @@ class HuffmanPreludeReader {
|
|||
switch (headerByte) {
|
||||
case TableHeader::SingleValue: {
|
||||
// Construct in-place.
|
||||
table = {mozilla::VariantType<typename Entry::Table>{}, cx_};
|
||||
table = {mozilla::VariantType<typename Entry::Table>{}};
|
||||
auto& tableRef = table.template as<typename Entry::Table>();
|
||||
|
||||
// The table contains a single value.
|
||||
|
@ -865,7 +865,7 @@ class HuffmanPreludeReader {
|
|||
case TableHeader::MultipleValues: {
|
||||
// Table contains multiple values.
|
||||
// Construct in-place.
|
||||
table = {mozilla::VariantType<typename Entry::Table>{}, cx_};
|
||||
table = {mozilla::VariantType<typename Entry::Table>{}};
|
||||
auto& tableRef = table.template as<typename Entry::Table>();
|
||||
|
||||
MOZ_TRY((readMultipleValuesTable<Entry>(tableRef, entry)));
|
||||
|
@ -1050,7 +1050,6 @@ BinASTTokenReaderContext::BinASTTokenReaderContext(JSContext* cx,
|
|||
const size_t length)
|
||||
: BinASTTokenReaderBase(cx, er, start, length),
|
||||
metadata_(nullptr),
|
||||
dictionary_(cx),
|
||||
posBeforeTree_(nullptr) {
|
||||
MOZ_ASSERT(er);
|
||||
}
|
||||
|
@ -1736,7 +1735,7 @@ const BinASTSymbol* GenericHuffmanTable::Iterator::operator->() const {
|
|||
});
|
||||
}
|
||||
|
||||
GenericHuffmanTable::GenericHuffmanTable(JSContext*)
|
||||
GenericHuffmanTable::GenericHuffmanTable()
|
||||
: implementation_(HuffmanTableUnreachable{}) {}
|
||||
|
||||
JS::Result<Ok> GenericHuffmanTable::initComplete(JSContext* cx) {
|
||||
|
@ -1849,7 +1848,7 @@ JS::Result<Ok> GenericHuffmanTable::initStart(JSContext* cx,
|
|||
// `largestBitLength`.
|
||||
// ...hopefully, only one lookup.
|
||||
if (largestBitLength <= SingleLookupHuffmanTable::MAX_BIT_LENGTH) {
|
||||
implementation_ = {mozilla::VariantType<SingleLookupHuffmanTable>{}, cx,
|
||||
implementation_ = {mozilla::VariantType<SingleLookupHuffmanTable>{},
|
||||
SingleLookupHuffmanTable::Use::ToplevelTable};
|
||||
return implementation_.template as<SingleLookupHuffmanTable>().initStart(
|
||||
cx, numberOfSymbols, largestBitLength);
|
||||
|
@ -1858,13 +1857,13 @@ JS::Result<Ok> GenericHuffmanTable::initStart(JSContext* cx,
|
|||
// ...if a single-lookup table would be too large, let's see if
|
||||
// we can fit in a two-lookup table.
|
||||
if (largestBitLength <= TwoLookupsHuffmanTable::MAX_BIT_LENGTH) {
|
||||
implementation_ = {mozilla::VariantType<TwoLookupsHuffmanTable>{}, cx};
|
||||
implementation_ = {mozilla::VariantType<TwoLookupsHuffmanTable>{}};
|
||||
return implementation_.template as<TwoLookupsHuffmanTable>().initStart(
|
||||
cx, numberOfSymbols, largestBitLength);
|
||||
}
|
||||
|
||||
// ...otherwise, we'll need three lookups.
|
||||
implementation_ = {mozilla::VariantType<ThreeLookupsHuffmanTable>{}, cx};
|
||||
implementation_ = {mozilla::VariantType<ThreeLookupsHuffmanTable>{}};
|
||||
return implementation_.template as<ThreeLookupsHuffmanTable>().initStart(
|
||||
cx, numberOfSymbols, largestBitLength);
|
||||
}
|
||||
|
@ -2288,7 +2287,7 @@ JS::Result<Ok> MultiLookupHuffmanTable<Subtable, PrefixBitLength>::initComplete(
|
|||
// We may now create the subtables.
|
||||
size_t i = 0;
|
||||
for (auto& bucket : buckets) {
|
||||
new (mozilla::KnownNotNull, &suffixTables_[i]) Subtable(cx);
|
||||
new (mozilla::KnownNotNull, &suffixTables_[i]) Subtable();
|
||||
suffixTablesIndices[i] = 0;
|
||||
|
||||
if (bucket.numberOfSymbols_ != 0) {
|
||||
|
@ -2831,7 +2830,7 @@ HuffmanPreludeReader::readSingleValueTable<UnsignedLong>(
|
|||
return Ok();
|
||||
}
|
||||
|
||||
HuffmanDictionary::HuffmanDictionary(JSContext* cx)
|
||||
HuffmanDictionary::HuffmanDictionary()
|
||||
: fields_(BINAST_PARAM_NUMBER_OF_INTERFACE_AND_FIELD(
|
||||
mozilla::AsVariant(HuffmanTableUnreachable()))),
|
||||
listLengths_(BINAST_PARAM_NUMBER_OF_LIST_TYPES(
|
||||
|
|
|
@ -452,7 +452,7 @@ class SingleLookupHuffmanTable {
|
|||
static const uint8_t MAX_BIT_LENGTH = sizeof(InternalIndex) * 8;
|
||||
|
||||
explicit SingleLookupHuffmanTable(
|
||||
JSContext* cx, Use use = Use::LeafOfMultiLookupHuffmanTable)
|
||||
Use use = Use::LeafOfMultiLookupHuffmanTable)
|
||||
: largestBitLength_(-1)
|
||||
#ifdef DEBUG
|
||||
,
|
||||
|
@ -476,7 +476,6 @@ class SingleLookupHuffmanTable {
|
|||
JS::Result<Ok> addSymbol(size_t index, uint32_t bits, uint8_t bitLength,
|
||||
const BinASTSymbol& value);
|
||||
|
||||
SingleLookupHuffmanTable() = delete;
|
||||
SingleLookupHuffmanTable(SingleLookupHuffmanTable&) = delete;
|
||||
|
||||
// Lookup a value in the table.
|
||||
|
@ -679,9 +678,8 @@ class MultiLookupHuffmanTable {
|
|||
static const uint8_t MAX_BIT_LENGTH =
|
||||
PrefixBitLength + Subtable::MAX_BIT_LENGTH;
|
||||
|
||||
explicit MultiLookupHuffmanTable(JSContext* cx)
|
||||
: cx_(cx),
|
||||
shortKeys_(cx, SingleLookupHuffmanTable::Use::ShortKeys),
|
||||
MultiLookupHuffmanTable()
|
||||
: shortKeys_(SingleLookupHuffmanTable::Use::ShortKeys),
|
||||
largestBitLength_(-1) {}
|
||||
MultiLookupHuffmanTable(MultiLookupHuffmanTable&& other) = default;
|
||||
|
||||
|
@ -699,7 +697,6 @@ class MultiLookupHuffmanTable {
|
|||
JS::Result<Ok> addSymbol(size_t index, uint32_t bits, uint8_t bitLength,
|
||||
const BinASTSymbol& value);
|
||||
|
||||
MultiLookupHuffmanTable() = delete;
|
||||
MultiLookupHuffmanTable(MultiLookupHuffmanTable&) = delete;
|
||||
|
||||
// Lookup a value in the table.
|
||||
|
@ -740,8 +737,6 @@ class MultiLookupHuffmanTable {
|
|||
using InternalIndex = uint8_t;
|
||||
|
||||
private:
|
||||
JSContext* cx_;
|
||||
|
||||
// Fast lookup for values whose keys fit within 8 bits.
|
||||
// Such values are not added to `suffixTables`.
|
||||
SingleLookupHuffmanTable shortKeys_;
|
||||
|
@ -794,8 +789,7 @@ struct HuffmanTableUnreachable {};
|
|||
//
|
||||
//
|
||||
struct GenericHuffmanTable {
|
||||
explicit GenericHuffmanTable(JSContext* cx);
|
||||
explicit GenericHuffmanTable() = delete;
|
||||
GenericHuffmanTable();
|
||||
|
||||
// Initialize a Huffman table containing a single value.
|
||||
JS::Result<Ok> initWithSingleValue(JSContext* cx, const BinASTSymbol& value);
|
||||
|
@ -876,30 +870,25 @@ struct HuffmanTableInitializing {};
|
|||
// These classes are all parts of variant `HuffmanTableValue`.
|
||||
|
||||
struct HuffmanTableExplicitSymbolsF64 : GenericHuffmanTable {
|
||||
explicit HuffmanTableExplicitSymbolsF64(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableExplicitSymbolsF64() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
struct HuffmanTableExplicitSymbolsU32 : GenericHuffmanTable {
|
||||
explicit HuffmanTableExplicitSymbolsU32(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableExplicitSymbolsU32() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
struct HuffmanTableIndexedSymbolsSum : GenericHuffmanTable {
|
||||
explicit HuffmanTableIndexedSymbolsSum(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableIndexedSymbolsSum() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
struct HuffmanTableIndexedSymbolsBool : GenericHuffmanTable {
|
||||
explicit HuffmanTableIndexedSymbolsBool(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableIndexedSymbolsBool() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
// A Huffman table that may only ever contain two values:
|
||||
// `BinASTKind::_Null` and another `BinASTKind`.
|
||||
struct HuffmanTableIndexedSymbolsMaybeInterface : GenericHuffmanTable {
|
||||
explicit HuffmanTableIndexedSymbolsMaybeInterface(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableIndexedSymbolsMaybeInterface() : GenericHuffmanTable() {}
|
||||
|
||||
// `true` if this table only contains values for `null`.
|
||||
bool isAlwaysNull() const {
|
||||
|
@ -917,18 +906,15 @@ struct HuffmanTableIndexedSymbolsMaybeInterface : GenericHuffmanTable {
|
|||
};
|
||||
|
||||
struct HuffmanTableIndexedSymbolsStringEnum : GenericHuffmanTable {
|
||||
explicit HuffmanTableIndexedSymbolsStringEnum(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableIndexedSymbolsStringEnum() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
struct HuffmanTableIndexedSymbolsLiteralString : GenericHuffmanTable {
|
||||
explicit HuffmanTableIndexedSymbolsLiteralString(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableIndexedSymbolsLiteralString() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
struct HuffmanTableIndexedSymbolsOptionalLiteralString : GenericHuffmanTable {
|
||||
explicit HuffmanTableIndexedSymbolsOptionalLiteralString(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableIndexedSymbolsOptionalLiteralString() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
// A single Huffman table, used for values.
|
||||
|
@ -942,8 +928,7 @@ using HuffmanTableValue = mozilla::Variant<
|
|||
HuffmanTableIndexedSymbolsOptionalLiteralString>;
|
||||
|
||||
struct HuffmanTableExplicitSymbolsListLength : GenericHuffmanTable {
|
||||
explicit HuffmanTableExplicitSymbolsListLength(JSContext* cx)
|
||||
: GenericHuffmanTable(cx) {}
|
||||
HuffmanTableExplicitSymbolsListLength() : GenericHuffmanTable() {}
|
||||
};
|
||||
|
||||
// A single Huffman table, specialized for list lengths.
|
||||
|
@ -959,7 +944,7 @@ using HuffmanTableListLength =
|
|||
// to predict list lengths.
|
||||
class HuffmanDictionary {
|
||||
public:
|
||||
explicit HuffmanDictionary(JSContext* cx);
|
||||
HuffmanDictionary();
|
||||
|
||||
HuffmanTableValue& tableForField(NormalizedInterfaceAndField index);
|
||||
HuffmanTableListLength& tableForListLength(BinASTList list);
|
||||
|
|
Загрузка…
Ссылка в новой задаче