From bdf9e9a1bf6fb9dbf7000892463351e49acd7f0b Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Wed, 13 Mar 2019 02:46:32 +0000 Subject: [PATCH] Bug 1505343 - Part 2: Rename BinToken* to BinASTToken*. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D23098 --HG-- rename : js/src/frontend/BinToken.cpp => js/src/frontend/BinASTToken.cpp rename : js/src/frontend/BinToken.h => js/src/frontend/BinASTToken.h rename : js/src/frontend/BinTokenReaderBase.cpp => js/src/frontend/BinASTTokenReaderBase.cpp rename : js/src/frontend/BinTokenReaderBase.h => js/src/frontend/BinASTTokenReaderBase.h rename : js/src/frontend/BinTokenReaderMultipart.cpp => js/src/frontend/BinASTTokenReaderMultipart.cpp rename : js/src/frontend/BinTokenReaderMultipart.h => js/src/frontend/BinASTTokenReaderMultipart.h extra : moz-landing-system : lando --- js/src/frontend/BinAST.yaml | 18 ++-- js/src/frontend/BinASTParser.cpp | 4 +- js/src/frontend/BinASTParser.h | 6 +- js/src/frontend/BinASTParserPerTokenizer.cpp | 4 +- js/src/frontend/BinASTParserPerTokenizer.h | 6 +- js/src/frontend/BinASTRuntimeSupport.h | 2 +- .../{BinToken.cpp => BinASTToken.cpp} | 2 +- js/src/frontend/{BinToken.h => BinASTToken.h} | 6 +- ...aderBase.cpp => BinASTTokenReaderBase.cpp} | 26 +++--- ...enReaderBase.h => BinASTTokenReaderBase.h} | 20 ++--- ...art.cpp => BinASTTokenReaderMultipart.cpp} | 87 ++++++++++--------- ...ltipart.h => BinASTTokenReaderMultipart.h} | 43 ++++----- js/src/frontend/BytecodeCompiler.cpp | 6 +- js/src/frontend/binast/README.md | 2 +- js/src/frontend/binast/build.sh | 6 +- js/src/frontend/binast/src/main.rs | 2 +- js/src/frontend/moz.build | 12 +-- js/src/jsapi-tests/testBinASTReader.cpp | 4 +- js/src/shell/js.cpp | 7 +- 19 files changed, 134 insertions(+), 129 deletions(-) rename js/src/frontend/{BinToken.cpp => BinASTToken.cpp} (99%) rename js/src/frontend/{BinToken.h => BinASTToken.h} (99%) rename js/src/frontend/{BinTokenReaderBase.cpp => BinASTTokenReaderBase.cpp} (75%) rename js/src/frontend/{BinTokenReaderBase.h => BinASTTokenReaderBase.h} (90%) rename js/src/frontend/{BinTokenReaderMultipart.cpp => BinASTTokenReaderMultipart.cpp} (81%) rename js/src/frontend/{BinTokenReaderMultipart.h => BinASTTokenReaderMultipart.h} (87%) diff --git a/js/src/frontend/BinAST.yaml b/js/src/frontend/BinAST.yaml index 84bf07c67f14..f8dc75d301f1 100644 --- a/js/src/frontend/BinAST.yaml +++ b/js/src/frontend/BinAST.yaml @@ -39,7 +39,7 @@ cpp: #include "mozilla/Vector.h" #include "frontend/BinAST-macros.h" - #include "frontend/BinTokenReaderMultipart.h" + #include "frontend/BinASTTokenReaderMultipart.h" #include "frontend/FullParseHandler.h" #include "frontend/ParseNode.h" #include "frontend/Parser.h" @@ -64,7 +64,7 @@ cpp: // Force class instantiation. // This ensures that the symbols are built, without having to export all our // code (and its baggage of #include and macros) in the header. - template class BinASTParser; + template class BinASTParser; } // namespace frontend } // namespace js @@ -89,8 +89,8 @@ hpp: #include "frontend/BCEParserHandle.h" #include "frontend/BinASTParserPerTokenizer.h" - #include "frontend/BinToken.h" - #include "frontend/BinTokenReaderMultipart.h" + #include "frontend/BinASTToken.h" + #include "frontend/BinASTTokenReaderMultipart.h" #include "frontend/FullParseHandler.h" #include "frontend/ParseContext.h" #include "frontend/ParseNode.h" @@ -193,7 +193,7 @@ hpp: footer: | }; - extern template class BinASTParser; + extern template class BinASTParser; } // namespace frontend } // namespace js @@ -224,7 +224,7 @@ hpp: #endif // frontend_BinASTEnum_h - # Rules for generating BinToken.h + # Rules for generating BinASTToken.h tokens: kind: doc: | @@ -289,8 +289,8 @@ hpp: // To generate this file, see the documentation in // js/src/frontend/binast/README.md. - #ifndef frontend_BinToken_h - #define frontend_BinToken_h + #ifndef frontend_BinASTToken_h + #define frontend_BinASTToken_h #include @@ -342,7 +342,7 @@ hpp: } // namespace frontend } // namespace js - #endif // frontend_BinToken_h + #endif // frontend_BinASTToken_h Arguments: init: | diff --git a/js/src/frontend/BinASTParser.cpp b/js/src/frontend/BinASTParser.cpp index d44850fa2de2..5d45b9749532 100644 --- a/js/src/frontend/BinASTParser.cpp +++ b/js/src/frontend/BinASTParser.cpp @@ -19,7 +19,7 @@ #include "mozilla/Vector.h" #include "frontend/BinAST-macros.h" -#include "frontend/BinTokenReaderMultipart.h" +#include "frontend/BinASTTokenReaderMultipart.h" #include "frontend/FullParseHandler.h" #include "frontend/ParseNode.h" #include "frontend/Parser.h" @@ -4964,7 +4964,7 @@ BinASTParser::parseOptionalVariableDeclarationOrExpression() { // Force class instantiation. // This ensures that the symbols are built, without having to export all our // code (and its baggage of #include and macros) in the header. -template class BinASTParser; +template class BinASTParser; } // namespace frontend } // namespace js diff --git a/js/src/frontend/BinASTParser.h b/js/src/frontend/BinASTParser.h index b061520befa3..d505500d798e 100644 --- a/js/src/frontend/BinASTParser.h +++ b/js/src/frontend/BinASTParser.h @@ -16,8 +16,8 @@ #include "frontend/BCEParserHandle.h" #include "frontend/BinASTParserPerTokenizer.h" -#include "frontend/BinToken.h" -#include "frontend/BinTokenReaderMultipart.h" +#include "frontend/BinASTToken.h" +#include "frontend/BinASTTokenReaderMultipart.h" #include "frontend/FullParseHandler.h" #include "frontend/ParseContext.h" #include "frontend/ParseNode.h" @@ -487,7 +487,7 @@ class BinASTParser : public BinASTParserPerTokenizer { JS::Result parseOptionalVariableDeclarationOrExpression(); }; -extern template class BinASTParser; +extern template class BinASTParser; } // namespace frontend } // namespace js diff --git a/js/src/frontend/BinASTParserPerTokenizer.cpp b/js/src/frontend/BinASTParserPerTokenizer.cpp index 95102a069e07..15f3fb1d89e9 100644 --- a/js/src/frontend/BinASTParserPerTokenizer.cpp +++ b/js/src/frontend/BinASTParserPerTokenizer.cpp @@ -16,7 +16,7 @@ #include "frontend/BinAST-macros.h" #include "frontend/BinASTParser.h" -#include "frontend/BinTokenReaderMultipart.h" +#include "frontend/BinASTTokenReaderMultipart.h" #include "frontend/FullParseHandler.h" #include "frontend/ParseNode.h" #include "frontend/Parser.h" @@ -806,7 +806,7 @@ BinASTParserPerTokenizer::asFinalParser() const { // Force class instantiation. // This ensures that the symbols are built, without having to export all our // code (and its baggage of #include and macros) in the header. -template class BinASTParserPerTokenizer; +template class BinASTParserPerTokenizer; } // namespace frontend } // namespace js diff --git a/js/src/frontend/BinASTParserPerTokenizer.h b/js/src/frontend/BinASTParserPerTokenizer.h index 35ce42691207..3090a4fe18a2 100644 --- a/js/src/frontend/BinASTParserPerTokenizer.h +++ b/js/src/frontend/BinASTParserPerTokenizer.h @@ -19,8 +19,8 @@ #include "frontend/BCEParserHandle.h" #include "frontend/BinASTEnum.h" #include "frontend/BinASTParserBase.h" -#include "frontend/BinToken.h" -#include "frontend/BinTokenReaderMultipart.h" +#include "frontend/BinASTToken.h" +#include "frontend/BinASTTokenReaderMultipart.h" #include "frontend/FullParseHandler.h" #include "frontend/ParseContext.h" #include "frontend/ParseNode.h" @@ -325,7 +325,7 @@ class BinASTParseContext : public ParseContext { void TraceBinASTParser(JSTracer* trc, JS::AutoGCRooter* parser); -extern template class BinASTParserPerTokenizer; +extern template class BinASTParserPerTokenizer; } // namespace frontend } // namespace js diff --git a/js/src/frontend/BinASTRuntimeSupport.h b/js/src/frontend/BinASTRuntimeSupport.h index af7f3663ff50..442230de9161 100644 --- a/js/src/frontend/BinASTRuntimeSupport.h +++ b/js/src/frontend/BinASTRuntimeSupport.h @@ -9,7 +9,7 @@ #include "mozilla/HashFunctions.h" -#include "frontend/BinToken.h" +#include "frontend/BinASTToken.h" #include "gc/DeletePolicy.h" #include "js/AllocPolicy.h" diff --git a/js/src/frontend/BinToken.cpp b/js/src/frontend/BinASTToken.cpp similarity index 99% rename from js/src/frontend/BinToken.cpp rename to js/src/frontend/BinASTToken.cpp index 4110658296aa..42cfed69da86 100644 --- a/js/src/frontend/BinToken.cpp +++ b/js/src/frontend/BinASTToken.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "frontend/BinToken.h" +#include "frontend/BinASTToken.h" #include "mozilla/Maybe.h" diff --git a/js/src/frontend/BinToken.h b/js/src/frontend/BinASTToken.h similarity index 99% rename from js/src/frontend/BinToken.h rename to js/src/frontend/BinASTToken.h index bb9160e91679..f80da0548e17 100644 --- a/js/src/frontend/BinToken.h +++ b/js/src/frontend/BinASTToken.h @@ -9,8 +9,8 @@ // To generate this file, see the documentation in // js/src/frontend/binast/README.md. -#ifndef frontend_BinToken_h -#define frontend_BinToken_h +#ifndef frontend_BinASTToken_h +#define frontend_BinASTToken_h #include @@ -381,4 +381,4 @@ const char* describeBinVariant(const BinVariant& kind); } // namespace frontend } // namespace js -#endif // frontend_BinToken_h +#endif // frontend_BinASTToken_h diff --git a/js/src/frontend/BinTokenReaderBase.cpp b/js/src/frontend/BinASTTokenReaderBase.cpp similarity index 75% rename from js/src/frontend/BinTokenReaderBase.cpp rename to js/src/frontend/BinASTTokenReaderBase.cpp index 008b8c1545e9..9dcbebb94a9b 100644 --- a/js/src/frontend/BinTokenReaderBase.cpp +++ b/js/src/frontend/BinASTTokenReaderBase.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "frontend/BinTokenReaderBase.h" +#include "frontend/BinASTTokenReaderBase.h" #include "frontend/BinAST-macros.h" #include "js/Result.h" @@ -19,26 +19,26 @@ using ErrorResult = mozilla::GenericErrorResult; // to represent a `null` number. const uint64_t NULL_FLOAT_REPRESENTATION = 0x7FF0000000000001; -void BinTokenReaderBase::updateLatestKnownGood() { +void BinASTTokenReaderBase::updateLatestKnownGood() { MOZ_ASSERT(current_ >= start_); const size_t update = current_ - start_; MOZ_ASSERT(update >= latestKnownGoodPos_); latestKnownGoodPos_ = update; } -ErrorResult BinTokenReaderBase::raiseError( +ErrorResult BinASTTokenReaderBase::raiseError( const char* description) { MOZ_ASSERT(!hasRaisedError()); errorReporter_->errorNoOffset(JSMSG_BINAST, description); return cx_->alreadyReportedError(); } -ErrorResult BinTokenReaderBase::raiseOOM() { +ErrorResult BinASTTokenReaderBase::raiseOOM() { ReportOutOfMemory(cx_); return cx_->alreadyReportedError(); } -ErrorResult BinTokenReaderBase::raiseInvalidNumberOfFields( +ErrorResult BinASTTokenReaderBase::raiseInvalidNumberOfFields( const BinKind kind, const uint32_t expected, const uint32_t got) { Sprinter out(cx_); BINJS_TRY(out.init()); @@ -47,7 +47,7 @@ ErrorResult BinTokenReaderBase::raiseInvalidNumberOfFields( return raiseError(out.string()); } -ErrorResult BinTokenReaderBase::raiseInvalidField( +ErrorResult BinASTTokenReaderBase::raiseInvalidField( const char* kind, const BinField field) { Sprinter out(cx_); BINJS_TRY(out.init()); @@ -56,7 +56,7 @@ ErrorResult BinTokenReaderBase::raiseInvalidField( return raiseError(out.string()); } -bool BinTokenReaderBase::hasRaisedError() const { +bool BinASTTokenReaderBase::hasRaisedError() const { if (cx_->helperThread()) { // When performing off-main-thread parsing, we don't set a pending // exception but instead add a pending compile error. @@ -66,11 +66,11 @@ bool BinTokenReaderBase::hasRaisedError() const { return cx_->isExceptionPending(); } -size_t BinTokenReaderBase::offset() const { return current_ - start_; } +size_t BinASTTokenReaderBase::offset() const { return current_ - start_; } -TokenPos BinTokenReaderBase::pos() { return pos(offset()); } +TokenPos BinASTTokenReaderBase::pos() { return pos(offset()); } -TokenPos BinTokenReaderBase::pos(size_t start) { +TokenPos BinASTTokenReaderBase::pos(size_t start) { TokenPos pos; pos.begin = start; pos.end = current_ - start_; @@ -78,12 +78,12 @@ TokenPos BinTokenReaderBase::pos(size_t start) { return pos; } -void BinTokenReaderBase::seek(size_t offset) { +void BinASTTokenReaderBase::seek(size_t offset) { MOZ_ASSERT(start_ + offset >= start_ && start_ + offset < stop_); current_ = start_ + offset; } -JS::Result BinTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len) { +JS::Result BinASTTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len) { MOZ_ASSERT(!hasRaisedError()); MOZ_ASSERT(len > 0); @@ -98,7 +98,7 @@ JS::Result BinTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len) { return Ok(); } -JS::Result BinTokenReaderBase::readByte() { +JS::Result BinASTTokenReaderBase::readByte() { uint8_t byte; MOZ_TRY(readBuf(&byte, 1)); return byte; diff --git a/js/src/frontend/BinTokenReaderBase.h b/js/src/frontend/BinASTTokenReaderBase.h similarity index 90% rename from js/src/frontend/BinTokenReaderBase.h rename to js/src/frontend/BinASTTokenReaderBase.h index 9221e53776a7..cfb4515991d3 100644 --- a/js/src/frontend/BinTokenReaderBase.h +++ b/js/src/frontend/BinASTTokenReaderBase.h @@ -4,10 +4,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef frontend_BinTokenReaderBase_h -#define frontend_BinTokenReaderBase_h +#ifndef frontend_BinASTTokenReaderBase_h +#define frontend_BinASTTokenReaderBase_h -#include "frontend/BinToken.h" +#include "frontend/BinASTToken.h" #include "frontend/ErrorReporter.h" #include "frontend/TokenStream.h" @@ -20,7 +20,7 @@ namespace frontend { // A constant used by tokenizers to represent a null float. extern const uint64_t NULL_FLOAT_REPRESENTATION; -class MOZ_STACK_CLASS BinTokenReaderBase { +class MOZ_STACK_CLASS BinASTTokenReaderBase { public: template using ErrorResult = mozilla::GenericErrorResult; @@ -72,8 +72,8 @@ class MOZ_STACK_CLASS BinTokenReaderBase { const BinField field); protected: - BinTokenReaderBase(JSContext* cx, ErrorReporter* er, const uint8_t* start, - const size_t length) + BinASTTokenReaderBase(JSContext* cx, ErrorReporter* er, const uint8_t* start, + const size_t length) : cx_(cx), errorReporter_(er), poisoned_(false), @@ -172,12 +172,12 @@ class MOZ_STACK_CLASS BinTokenReaderBase { size_t latestKnownGoodPos_; private: - BinTokenReaderBase(const BinTokenReaderBase&) = delete; - BinTokenReaderBase(BinTokenReaderBase&&) = delete; - BinTokenReaderBase& operator=(BinTokenReaderBase&) = delete; + BinASTTokenReaderBase(const BinASTTokenReaderBase&) = delete; + BinASTTokenReaderBase(BinASTTokenReaderBase&&) = delete; + BinASTTokenReaderBase& operator=(BinASTTokenReaderBase&) = delete; }; } // namespace frontend } // namespace js -#endif // frontend_BinTokenReaderBase_h +#endif // frontend_BinASTTokenReaderBase_h diff --git a/js/src/frontend/BinTokenReaderMultipart.cpp b/js/src/frontend/BinASTTokenReaderMultipart.cpp similarity index 81% rename from js/src/frontend/BinTokenReaderMultipart.cpp rename to js/src/frontend/BinASTTokenReaderMultipart.cpp index 98ccc94011ed..f72fa7ad5f02 100644 --- a/js/src/frontend/BinTokenReaderMultipart.cpp +++ b/js/src/frontend/BinASTTokenReaderMultipart.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "frontend/BinTokenReaderMultipart.h" +#include "frontend/BinASTTokenReaderMultipart.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Casting.h" @@ -40,34 +40,34 @@ const char COMPRESSION_IDENTITY[] = "identity;"; // single file. const uint32_t MAX_NUMBER_OF_STRINGS = 32768; -using AutoList = BinTokenReaderMultipart::AutoList; -using AutoTaggedTuple = BinTokenReaderMultipart::AutoTaggedTuple; +using AutoList = BinASTTokenReaderMultipart::AutoList; +using AutoTaggedTuple = BinASTTokenReaderMultipart::AutoTaggedTuple; using CharSlice = BinaryASTSupport::CharSlice; -using Chars = BinTokenReaderMultipart::Chars; +using Chars = BinASTTokenReaderMultipart::Chars; -BinTokenReaderMultipart::BinTokenReaderMultipart(JSContext* cx, - ErrorReporter* er, - const uint8_t* start, - const size_t length) - : BinTokenReaderBase(cx, er, start, length), +BinASTTokenReaderMultipart::BinASTTokenReaderMultipart(JSContext* cx, + ErrorReporter* er, + const uint8_t* start, + const size_t length) + : BinASTTokenReaderBase(cx, er, start, length), metadata_(nullptr), posBeforeTree_(nullptr) { MOZ_ASSERT(er); } -BinTokenReaderMultipart::~BinTokenReaderMultipart() { +BinASTTokenReaderMultipart::~BinASTTokenReaderMultipart() { if (metadata_ && metadataOwned_ == MetadataOwnership::Owned) { UniqueBinASTSourceMetadataPtr ptr(metadata_); } } -BinASTSourceMetadata* BinTokenReaderMultipart::takeMetadata() { +BinASTSourceMetadata* BinASTTokenReaderMultipart::takeMetadata() { MOZ_ASSERT(metadataOwned_ == MetadataOwnership::Owned); metadataOwned_ = MetadataOwnership::Unowned; return metadata_; } -JS::Result BinTokenReaderMultipart::initFromScriptSource( +JS::Result BinASTTokenReaderMultipart::initFromScriptSource( ScriptSource* scriptSource) { metadata_ = scriptSource->binASTSourceMetadata(); metadataOwned_ = MetadataOwnership::Unowned; @@ -75,7 +75,7 @@ JS::Result BinTokenReaderMultipart::initFromScriptSource( return Ok(); } -JS::Result BinTokenReaderMultipart::readHeader() { +JS::Result BinASTTokenReaderMultipart::readHeader() { // Check that we don't call this function twice. MOZ_ASSERT(!posBeforeTree_); @@ -215,13 +215,13 @@ JS::Result BinTokenReaderMultipart::readHeader() { return Ok(); } -void BinTokenReaderMultipart::traceMetadata(JSTracer* trc) { +void BinASTTokenReaderMultipart::traceMetadata(JSTracer* trc) { if (metadata_) { metadata_->trace(trc); } } -JS::Result BinTokenReaderMultipart::readBool() { +JS::Result BinASTTokenReaderMultipart::readBool() { updateLatestKnownGood(); BINJS_MOZ_TRY_DECL(byte, readByte()); @@ -241,7 +241,7 @@ JS::Result BinTokenReaderMultipart::readBool() { // // NULL_FLOAT_REPRESENTATION (signaling NaN) => null // anything other 64 bit sequence => IEEE-764 64-bit floating point number -JS::Result BinTokenReaderMultipart::readDouble() { +JS::Result BinASTTokenReaderMultipart::readDouble() { updateLatestKnownGood(); uint8_t bytes[8]; @@ -262,7 +262,7 @@ JS::Result BinTokenReaderMultipart::readDouble() { } // A single atom is represented as an index into the table of strings. -JS::Result BinTokenReaderMultipart::readMaybeAtom() { +JS::Result BinASTTokenReaderMultipart::readMaybeAtom() { updateLatestKnownGood(); BINJS_MOZ_TRY_DECL(index, readInternalUint32()); @@ -272,7 +272,7 @@ JS::Result BinTokenReaderMultipart::readMaybeAtom() { return metadata_->getAtom(index); } -JS::Result BinTokenReaderMultipart::readAtom() { +JS::Result BinASTTokenReaderMultipart::readAtom() { BINJS_MOZ_TRY_DECL(maybe, readMaybeAtom()); if (!maybe) { @@ -282,7 +282,7 @@ JS::Result BinTokenReaderMultipart::readAtom() { return maybe; } -JS::Result BinTokenReaderMultipart::readMaybeIdentifierName() { +JS::Result BinASTTokenReaderMultipart::readMaybeIdentifierName() { BINJS_MOZ_TRY_DECL(result, readMaybeAtom()); if (result) { if (!IsIdentifier(result)) { @@ -292,7 +292,7 @@ JS::Result BinTokenReaderMultipart::readMaybeIdentifierName() { return result; } -JS::Result BinTokenReaderMultipart::readIdentifierName() { +JS::Result BinASTTokenReaderMultipart::readIdentifierName() { BINJS_MOZ_TRY_DECL(result, readMaybeAtom()); if (!IsIdentifier(result)) { return raiseError("Invalid identifier"); @@ -300,15 +300,15 @@ JS::Result BinTokenReaderMultipart::readIdentifierName() { return result; } -JS::Result BinTokenReaderMultipart::readMaybePropertyKey() { +JS::Result BinASTTokenReaderMultipart::readMaybePropertyKey() { return readMaybeAtom(); } -JS::Result BinTokenReaderMultipart::readPropertyKey() { +JS::Result BinASTTokenReaderMultipart::readPropertyKey() { return readAtom(); } -JS::Result BinTokenReaderMultipart::readChars(Chars& out) { +JS::Result BinASTTokenReaderMultipart::readChars(Chars& out) { updateLatestKnownGood(); BINJS_MOZ_TRY_DECL(index, readInternalUint32()); @@ -320,7 +320,7 @@ JS::Result BinTokenReaderMultipart::readChars(Chars& out) { return Ok(); } -JS::Result BinTokenReaderMultipart::readVariant() { +JS::Result BinASTTokenReaderMultipart::readVariant() { updateLatestKnownGood(); BINJS_MOZ_TRY_DECL(index, readInternalUint32()); @@ -353,8 +353,8 @@ JS::Result BinTokenReaderMultipart::readVariant() { return *variant; } -JS::Result -BinTokenReaderMultipart::readSkippableSubTree() { +JS::Result +BinASTTokenReaderMultipart::readSkippableSubTree() { updateLatestKnownGood(); BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32()); @@ -366,14 +366,15 @@ BinTokenReaderMultipart::readSkippableSubTree() { current_ += byteLen; - return BinTokenReaderBase::SkippableSubTree(start, byteLen); + return BinASTTokenReaderBase::SkippableSubTree(start, byteLen); } // Tagged tuples: // - uint32_t index in table [grammar]; // - content (specified by the higher-level grammar); -JS::Result BinTokenReaderMultipart::enterTaggedTuple( - BinKind& tag, BinTokenReaderMultipart::BinFields&, AutoTaggedTuple& guard) { +JS::Result BinASTTokenReaderMultipart::enterTaggedTuple( + BinKind& tag, BinASTTokenReaderMultipart::BinFields&, + AutoTaggedTuple& guard) { BINJS_MOZ_TRY_DECL(index, readInternalUint32()); if (index >= metadata_->numBinKinds()) { return raiseError("Invalid index to grammar table"); @@ -393,8 +394,8 @@ JS::Result BinTokenReaderMultipart::enterTaggedTuple( // // The total byte length of `number of items` + `contents` must be `byte // length`. -JS::Result BinTokenReaderMultipart::enterList(uint32_t& items, - AutoList& guard) { +JS::Result BinASTTokenReaderMultipart::enterList(uint32_t& items, + AutoList& guard) { guard.init(); MOZ_TRY_VAR(items, readInternalUint32()); @@ -402,19 +403,20 @@ JS::Result BinTokenReaderMultipart::enterList(uint32_t& items, return Ok(); } -void BinTokenReaderMultipart::AutoBase::init() { initialized_ = true; } +void BinASTTokenReaderMultipart::AutoBase::init() { initialized_ = true; } -BinTokenReaderMultipart::AutoBase::AutoBase(BinTokenReaderMultipart& reader) +BinASTTokenReaderMultipart::AutoBase::AutoBase( + BinASTTokenReaderMultipart& reader) : initialized_(false), reader_(reader) {} -BinTokenReaderMultipart::AutoBase::~AutoBase() { +BinASTTokenReaderMultipart::AutoBase::~AutoBase() { // By now, the `AutoBase` must have been deinitialized by calling `done()`. // The only case in which we can accept not calling `done()` is if we have // bailed out because of an error. MOZ_ASSERT_IF(initialized_, reader_.hasRaisedError()); } -JS::Result BinTokenReaderMultipart::AutoBase::checkPosition( +JS::Result BinASTTokenReaderMultipart::AutoBase::checkPosition( const uint8_t* expectedEnd) { if (reader_.current_ != expectedEnd) { return reader_.raiseError( @@ -424,12 +426,13 @@ JS::Result BinTokenReaderMultipart::AutoBase::checkPosition( return Ok(); } -BinTokenReaderMultipart::AutoList::AutoList(BinTokenReaderMultipart& reader) +BinASTTokenReaderMultipart::AutoList::AutoList( + BinASTTokenReaderMultipart& reader) : AutoBase(reader) {} -void BinTokenReaderMultipart::AutoList::init() { AutoBase::init(); } +void BinASTTokenReaderMultipart::AutoList::init() { AutoBase::init(); } -JS::Result BinTokenReaderMultipart::AutoList::done() { +JS::Result BinASTTokenReaderMultipart::AutoList::done() { MOZ_ASSERT(initialized_); initialized_ = false; if (reader_.hasRaisedError()) { @@ -445,7 +448,7 @@ JS::Result BinTokenReaderMultipart::AutoList::done() { // Encoded as variable length number. MOZ_MUST_USE JS::Result -BinTokenReaderMultipart::readInternalUint32() { +BinASTTokenReaderMultipart::readInternalUint32() { uint32_t result = 0; uint32_t shift = 0; while (true) { @@ -471,11 +474,11 @@ BinTokenReaderMultipart::readInternalUint32() { } } -BinTokenReaderMultipart::AutoTaggedTuple::AutoTaggedTuple( - BinTokenReaderMultipart& reader) +BinASTTokenReaderMultipart::AutoTaggedTuple::AutoTaggedTuple( + BinASTTokenReaderMultipart& reader) : AutoBase(reader) {} -JS::Result BinTokenReaderMultipart::AutoTaggedTuple::done() { +JS::Result BinASTTokenReaderMultipart::AutoTaggedTuple::done() { MOZ_ASSERT(initialized_); initialized_ = false; if (reader_.hasRaisedError()) { diff --git a/js/src/frontend/BinTokenReaderMultipart.h b/js/src/frontend/BinASTTokenReaderMultipart.h similarity index 87% rename from js/src/frontend/BinTokenReaderMultipart.h rename to js/src/frontend/BinASTTokenReaderMultipart.h index ba1903404e8a..af6e620f0335 100644 --- a/js/src/frontend/BinTokenReaderMultipart.h +++ b/js/src/frontend/BinASTTokenReaderMultipart.h @@ -4,14 +4,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef frontend_BinTokenReaderMultipart_h -#define frontend_BinTokenReaderMultipart_h +#ifndef frontend_BinASTTokenReaderMultipart_h +#define frontend_BinASTTokenReaderMultipart_h #include "mozilla/Maybe.h" #include "frontend/BinASTRuntimeSupport.h" -#include "frontend/BinToken.h" -#include "frontend/BinTokenReaderBase.h" +#include "frontend/BinASTToken.h" +#include "frontend/BinASTTokenReaderBase.h" #include "js/Result.h" @@ -30,7 +30,8 @@ namespace frontend { * - the reader does not support error recovery; * - the reader does not support lookahead or pushback. */ -class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase { +class MOZ_STACK_CLASS BinASTTokenReaderMultipart + : public BinASTTokenReaderBase { public: class AutoList; class AutoTaggedTuple; @@ -51,18 +52,18 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase { * * Does NOT copy the buffer. */ - BinTokenReaderMultipart(JSContext* cx, ErrorReporter* er, - const uint8_t* start, const size_t length); + BinASTTokenReaderMultipart(JSContext* cx, ErrorReporter* er, + const uint8_t* start, const size_t length); /** * Construct a token reader. * * Does NOT copy the buffer. */ - BinTokenReaderMultipart(JSContext* cx, ErrorReporter* er, - const Vector& chars); + BinASTTokenReaderMultipart(JSContext* cx, ErrorReporter* er, + const Vector& chars); - ~BinTokenReaderMultipart(); + ~BinASTTokenReaderMultipart(); /** * Read the header of the file. @@ -170,7 +171,7 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase { * @return out If the header of the tuple is invalid. */ MOZ_MUST_USE JS::Result enterTaggedTuple( - BinKind& tag, BinTokenReaderMultipart::BinFields& fields, + BinKind& tag, BinASTTokenReaderMultipart::BinFields& fields, AutoTaggedTuple& guard); /** @@ -198,9 +199,9 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase { const uint8_t* posBeforeTree_; - BinTokenReaderMultipart(const BinTokenReaderMultipart&) = delete; - BinTokenReaderMultipart(BinTokenReaderMultipart&&) = delete; - BinTokenReaderMultipart& operator=(BinTokenReaderMultipart&) = delete; + BinASTTokenReaderMultipart(const BinASTTokenReaderMultipart&) = delete; + BinASTTokenReaderMultipart(BinASTTokenReaderMultipart&&) = delete; + BinASTTokenReaderMultipart& operator=(BinASTTokenReaderMultipart&) = delete; public: void traceMetadata(JSTracer* trc); @@ -224,38 +225,38 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase { // Base class used by other Auto* classes. class MOZ_STACK_CLASS AutoBase { protected: - explicit AutoBase(BinTokenReaderMultipart& reader); + explicit AutoBase(BinASTTokenReaderMultipart& reader); ~AutoBase(); // Raise an error if we are not in the expected position. MOZ_MUST_USE JS::Result checkPosition(const uint8_t* expectedPosition); - friend BinTokenReaderMultipart; + friend BinASTTokenReaderMultipart; void init(); // Set to `true` if `init()` has been called. Reset to `false` once // all conditions have been checked. bool initialized_; - BinTokenReaderMultipart& reader_; + BinASTTokenReaderMultipart& reader_; }; // Guard class used to ensure that `enterList` is used properly. class MOZ_STACK_CLASS AutoList : public AutoBase { public: - explicit AutoList(BinTokenReaderMultipart& reader); + explicit AutoList(BinASTTokenReaderMultipart& reader); // Check that we have properly read to the end of the list. MOZ_MUST_USE JS::Result done(); protected: - friend BinTokenReaderMultipart; + friend BinASTTokenReaderMultipart; void init(); }; // Guard class used to ensure that `enterTaggedTuple` is used properly. class MOZ_STACK_CLASS AutoTaggedTuple : public AutoBase { public: - explicit AutoTaggedTuple(BinTokenReaderMultipart& reader); + explicit AutoTaggedTuple(BinASTTokenReaderMultipart& reader); // Check that we have properly read to the end of the tuple. MOZ_MUST_USE JS::Result done(); @@ -295,4 +296,4 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase { } // namespace frontend } // namespace js -#endif // frontend_BinTokenReaderMultipart_h +#endif // frontend_BinASTTokenReaderMultipart_h diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index cb7e54b8aac8..682c26f1545b 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -766,8 +766,8 @@ JSScript* frontend::CompileGlobalBinASTScript( GlobalSharedContext globalsc(cx, ScopeKind::Global, directives, options.extraWarningsOption); - frontend::BinASTParser parser(cx, alloc, usedNames, - options, sourceObj); + frontend::BinASTParser parser( + cx, alloc, usedNames, options, sourceObj); // Metadata stores internal pointers, so we must use the same buffer every // time, including for lazy parses @@ -1057,7 +1057,7 @@ bool frontend::CompileLazyBinASTFunction(JSContext* cx, script->setHasBeenCloned(); } - frontend::BinASTParser parser( + frontend::BinASTParser parser( cx, cx->tempLifoAlloc(), usedNames, options, sourceObj, lazy); auto parsed = diff --git a/js/src/frontend/binast/README.md b/js/src/frontend/binast/README.md index 68a712a37819..739c0d44bd8d 100644 --- a/js/src/frontend/binast/README.md +++ b/js/src/frontend/binast/README.md @@ -2,7 +2,7 @@ A parser generator used to generate the following files: - js/src/frontend/BinASTParser.h - js/src/frontend/BinASTParser.cpp -- js/src/frontent/BinToken.h +- js/src/frontent/BinASTToken.h from the following files: diff --git a/js/src/frontend/binast/build.sh b/js/src/frontend/binast/build.sh index 42cf1a345be3..6acb70d78505 100755 --- a/js/src/frontend/binast/build.sh +++ b/js/src/frontend/binast/build.sh @@ -6,7 +6,7 @@ cargo run -- \ --out-class ../BinASTParser-tmp.h \ --out-impl ../BinASTParser-tmp.cpp \ --out-enum ../BinASTEnum-tmp.h \ - --out-token ../BinToken-tmp.h + --out-token ../BinASTToken-tmp.h MACH=../../../../mach @@ -14,7 +14,7 @@ ${MACH} clang-format --path \ ../BinASTParser-tmp.h \ ../BinASTParser-tmp.cpp \ ../BinASTEnum-tmp.h \ - ../BinToken-tmp.h + ../BinASTToken-tmp.h # Usage: update SRC DST # @@ -36,4 +36,4 @@ update() { update ../BinASTParser-tmp.h ../BinASTParser.h update ../BinASTParser-tmp.cpp ../BinASTParser.cpp update ../BinASTEnum-tmp.h ../BinASTEnum.h -update ../BinToken-tmp.h ../BinToken.h +update ../BinASTToken-tmp.h ../BinASTToken.h diff --git a/js/src/frontend/binast/src/main.rs b/js/src/frontend/binast/src/main.rs index 9d7151d53a93..42bb743a0d7f 100644 --- a/js/src/frontend/binast/src/main.rs +++ b/js/src/frontend/binast/src/main.rs @@ -1755,7 +1755,7 @@ impl CPPExporter { } Some(IsNullable { is_nullable: false, content: Primitive::Offset }) => { if needs_block { - (Some(format!("BinTokenReaderBase::SkippableSubTree {var_name};", var_name = var_name)), + (Some(format!("BinASTTokenReaderBase::SkippableSubTree {var_name};", var_name = var_name)), Some(format!("MOZ_TRY_VAR({var_name}, tokenizer_->readSkippableSubTree());", var_name = var_name))) } else { (None, diff --git a/js/src/frontend/moz.build b/js/src/frontend/moz.build index ff924cbb7639..8730697212db 100644 --- a/js/src/frontend/moz.build +++ b/js/src/frontend/moz.build @@ -73,9 +73,9 @@ if CONFIG['JS_BUILD_BINAST']: 'BinASTParserBase.cpp', 'BinASTParserPerTokenizer.cpp', 'BinASTRuntimeSupport.cpp', - 'BinToken.cpp', - 'BinTokenReaderBase.cpp', - 'BinTokenReaderMultipart.cpp', + 'BinASTToken.cpp', + 'BinASTTokenReaderBase.cpp', + 'BinASTTokenReaderMultipart.cpp', ] DIRS += [ @@ -89,6 +89,6 @@ if CONFIG['JS_BUILD_BINAST']: SOURCES['BinASTParser.cpp'].flags += libfuzzer_flags SOURCES['BinASTParserBase.cpp'].flags += libfuzzer_flags SOURCES['BinASTParserPerTokenizer.cpp'].flags += libfuzzer_flags - SOURCES['BinToken.cpp'].flags += libfuzzer_flags - SOURCES['BinTokenReaderBase.cpp'].flags += libfuzzer_flags - SOURCES['BinTokenReaderMultipart.cpp'].flags += libfuzzer_flags + SOURCES['BinASTToken.cpp'].flags += libfuzzer_flags + SOURCES['BinASTTokenReaderBase.cpp'].flags += libfuzzer_flags + SOURCES['BinASTTokenReaderMultipart.cpp'].flags += libfuzzer_flags diff --git a/js/src/jsapi-tests/testBinASTReader.cpp b/js/src/jsapi-tests/testBinASTReader.cpp index ae336f786414..a9a4f51e0eb3 100644 --- a/js/src/jsapi-tests/testBinASTReader.cpp +++ b/js/src/jsapi-tests/testBinASTReader.cpp @@ -459,10 +459,10 @@ void runTestFromPath(JSContext* cx, const char* path) { BEGIN_TEST(testBinASTReaderMultipartECMAScript2) { #if defined(XP_WIN) - runTestFromPath( + runTestFromPath( cx, "jsapi-tests\\binast\\parser\\multipart\\"); #else - runTestFromPath( + runTestFromPath( cx, "jsapi-tests/binast/parser/multipart/"); #endif // defined(XP_XIN) return true; diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index d154846a207d..5ec996197f7e 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -85,7 +85,7 @@ #include "jit/JitRealm.h" #include "jit/shared/CodeGenerator-shared.h" #include "js/ArrayBuffer.h" // JS::{CreateMappedArrayBufferContents,NewMappedArrayBufferWithContents,IsArrayBufferObject,GetArrayBufferLengthAndData} -#include "js/BuildId.h" // JS::BuildIdCharVector, JS::SetProcessBuildIdOp +#include "js/BuildId.h" // JS::BuildIdCharVector, JS::SetProcessBuildIdOp #include "js/CharacterEncoding.h" #include "js/CompilationAndEvaluation.h" #include "js/CompileOptions.h" @@ -5109,7 +5109,7 @@ static bool BinParse(JSContext* cx, unsigned argc, Value* vp) { Directives directives(false); GlobalSharedContext globalsc(cx, ScopeKind::Global, directives, false); - auto parseFunc = ParseBinASTData; + auto parseFunc = ParseBinASTData; if (!parseFunc(cx, buf_data, buf_length, &globalsc, usedNames, options, sourceObj)) { return false; @@ -10889,7 +10889,8 @@ int main(int argc, char** argv, char** envp) { "Forcibly activate tiering and block " "instantiation on completion of tier2") #ifdef ENABLE_WASM_GC - || !op.addBoolOption('\0', "wasm-gc", "Enable experimental wasm GC features") + || + !op.addBoolOption('\0', "wasm-gc", "Enable experimental wasm GC features") #else || !op.addBoolOption('\0', "wasm-gc", "No-op") #endif