Bug 1551470 - Add Context parameter to BinASTTokenReaderContext methods. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Mon, 20 May 2019 10:39:33 +0000
changeset 474502 db45f0c580bb9c8f84d1ef46281e842903d06c4f
parent 474501 d806a12ca46833286baf4c2f320db7d667a28883
child 474503 62f8232e95795381a6b8a14b25121f73d9a1877a
push id36041
push userccoroiu@mozilla.com
push dateMon, 20 May 2019 21:55:28 +0000
treeherdermozilla-central@29bdbbe89264 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1551470
milestone68.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 1551470 - Add Context parameter to BinASTTokenReaderContext methods. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D31053
js/src/frontend/BinASTTokenReaderContext.cpp
js/src/frontend/BinASTTokenReaderContext.h
--- a/js/src/frontend/BinASTTokenReaderContext.cpp
+++ b/js/src/frontend/BinASTTokenReaderContext.cpp
@@ -77,64 +77,68 @@ JS::Result<Ok> BinASTTokenReaderContext:
 }
 
 void BinASTTokenReaderContext::traceMetadata(JSTracer* trc) {
   if (metadata_) {
     metadata_->trace(trc);
   }
 }
 
-JS::Result<bool> BinASTTokenReaderContext::readBool() {
+JS::Result<bool> BinASTTokenReaderContext::readBool(const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<double> BinASTTokenReaderContext::readDouble() {
+JS::Result<double> BinASTTokenReaderContext::readDouble(const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<JSAtom*> BinASTTokenReaderContext::readMaybeAtom() {
+JS::Result<JSAtom*> BinASTTokenReaderContext::readMaybeAtom(const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<JSAtom*> BinASTTokenReaderContext::readAtom() {
+JS::Result<JSAtom*> BinASTTokenReaderContext::readAtom(const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<JSAtom*> BinASTTokenReaderContext::readMaybeIdentifierName() {
+JS::Result<JSAtom*> BinASTTokenReaderContext::readMaybeIdentifierName(
+    const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<JSAtom*> BinASTTokenReaderContext::readIdentifierName() {
+JS::Result<JSAtom*> BinASTTokenReaderContext::readIdentifierName(
+    const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<JSAtom*> BinASTTokenReaderContext::readPropertyKey() {
+JS::Result<JSAtom*> BinASTTokenReaderContext::readPropertyKey(const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<Ok> BinASTTokenReaderContext::readChars(Chars& out) {
+JS::Result<Ok> BinASTTokenReaderContext::readChars(Chars& out, const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
-JS::Result<BinASTVariant> BinASTTokenReaderContext::readVariant() {
+JS::Result<BinASTVariant> BinASTTokenReaderContext::readVariant(
+    const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
 JS::Result<BinASTTokenReaderBase::SkippableSubTree>
-BinASTTokenReaderContext::readSkippableSubTree() {
+BinASTTokenReaderContext::readSkippableSubTree(const Context&) {
   return raiseError("Not Yet Implemented");
 }
 
 JS::Result<Ok> BinASTTokenReaderContext::enterTaggedTuple(
-    BinASTKind& tag, BinASTTokenReaderContext::BinASTFields&,
+    BinASTKind& tag, BinASTTokenReaderContext::BinASTFields&, const Context&,
     AutoTaggedTuple& guard) {
   return raiseError("Not Yet Implemented");
 }
 
 JS::Result<Ok> BinASTTokenReaderContext::enterList(uint32_t& items,
+                                                   const Context&,
                                                    AutoList& guard) {
   return raiseError("Not Yet Implemented");
 }
 
 void BinASTTokenReaderContext::AutoBase::init() { initialized_ = true; }
 
 BinASTTokenReaderContext::AutoBase::AutoBase(BinASTTokenReaderContext& reader)
     : initialized_(false), reader_(reader) {}
--- a/js/src/frontend/BinASTTokenReaderContext.h
+++ b/js/src/frontend/BinASTTokenReaderContext.h
@@ -48,16 +48,17 @@ class ErrorReporter;
  * - the reader does not support lookahead or pushback.
  */
 class MOZ_STACK_CLASS BinASTTokenReaderContext : public BinASTTokenReaderBase {
  public:
   class AutoList;
   class AutoTaggedTuple;
 
   using CharSlice = BinaryASTSupport::CharSlice;
+  using Context = BinASTTokenReaderBase::Context;
 
   // This implementation of `BinASTFields` is effectively `void`, as the format
   // does not embed field information.
   class BinASTFields {
    public:
     explicit BinASTFields(JSContext*) {}
   };
   using Chars = CharSlice;
@@ -94,63 +95,65 @@ class MOZ_STACK_CLASS BinASTTokenReaderC
   // Reading will return an error either in case of I/O error or in case of
   // a format problem. Reading if an exception in pending is an error and
   // will cause assertion failures. Do NOT attempt to read once an exception
   // has been cleared: the token reader does NOT support recovery, by design.
 
   /**
    * Read a single `true | false` value.
    */
-  MOZ_MUST_USE JS::Result<bool> readBool();
+  MOZ_MUST_USE JS::Result<bool> readBool(const Context&);
 
   /**
    * Read a single `number` value.
    */
-  MOZ_MUST_USE JS::Result<double> readDouble();
+  MOZ_MUST_USE JS::Result<double> readDouble(const Context&);
 
   /**
    * Read a single `string | null` value.
    *
    * Fails if that string is not valid UTF-8.
    */
-  MOZ_MUST_USE JS::Result<JSAtom*> readMaybeAtom();
-  MOZ_MUST_USE JS::Result<JSAtom*> readAtom();
+  MOZ_MUST_USE JS::Result<JSAtom*> readMaybeAtom(const Context&);
+  MOZ_MUST_USE JS::Result<JSAtom*> readAtom(const Context&);
 
   /**
    * Read a single IdentifierName value.
    */
-  MOZ_MUST_USE JS::Result<JSAtom*> readMaybeIdentifierName();
-  MOZ_MUST_USE JS::Result<JSAtom*> readIdentifierName();
+  MOZ_MUST_USE JS::Result<JSAtom*> readMaybeIdentifierName(const Context&);
+  MOZ_MUST_USE JS::Result<JSAtom*> readIdentifierName(const Context&);
 
   /**
    * Read a single PropertyKey value.
    */
-  MOZ_MUST_USE JS::Result<JSAtom*> readPropertyKey();
+  MOZ_MUST_USE JS::Result<JSAtom*> readPropertyKey(const Context&);
 
   /**
    * Read a single `string | null` value.
    *
    * MAY check if that string is not valid UTF-8.
    */
-  MOZ_MUST_USE JS::Result<Ok> readChars(Chars&);
+  MOZ_MUST_USE JS::Result<Ok> readChars(Chars&, const Context&);
 
   /**
    * Read a single `BinASTVariant | null` value.
    */
-  MOZ_MUST_USE JS::Result<mozilla::Maybe<BinASTVariant>> readMaybeVariant();
-  MOZ_MUST_USE JS::Result<BinASTVariant> readVariant();
+  MOZ_MUST_USE JS::Result<mozilla::Maybe<BinASTVariant>> readMaybeVariant(
+      const Context&);
+  MOZ_MUST_USE JS::Result<BinASTVariant> readVariant(const Context&);
 
   /**
    * Read over a single `[Skippable]` subtree value.
    *
    * This does *not* attempt to parse the subtree itself. Rather, the
    * returned `SkippableSubTree` contains the necessary information
    * to parse/tokenize the subtree at a later stage
    */
-  MOZ_MUST_USE JS::Result<SkippableSubTree> readSkippableSubTree();
+  MOZ_MUST_USE JS::Result<SkippableSubTree> readSkippableSubTree(
+      const Context&);
 
   // --- Composite values.
   //
   // The underlying format does NOT allows for a `null` composite value.
   //
   // Reading will return an error either in case of I/O error or in case of
   // a format problem. Reading from a poisoned tokenizer is an error and
   // will cause assertion failures.
@@ -162,17 +165,18 @@ class MOZ_STACK_CLASS BinASTTokenReaderC
    * @param guard (OUT) A guard, ensuring that we read the list correctly.
    *
    * The `guard` is dedicated to ensuring that reading the list has consumed
    * exactly all the bytes from that list. The `guard` MUST therefore be
    * destroyed at the point where the caller has reached the end of the list.
    * If the caller has consumed too few/too many bytes, this will be reported
    * in the call go `guard.done()`.
    */
-  MOZ_MUST_USE JS::Result<Ok> enterList(uint32_t& length, AutoList& guard);
+  MOZ_MUST_USE JS::Result<Ok> enterList(uint32_t& length, const Context&,
+                                        AutoList& guard);
 
   /**
    * Start reading a tagged tuple.
    *
    * @param tag (OUT) The tag of the tuple.
    * @param fields Ignored, provided for API compatibility.
    * @param guard (OUT) A guard, ensuring that we read the tagged tuple
    * correctly.
@@ -182,22 +186,24 @@ class MOZ_STACK_CLASS BinASTTokenReaderC
    * destroyed at the point where the caller has reached the end of the tuple.
    * If the caller has consumed too few/too many bytes, this will be reported
    * in the call go `guard.done()`.
    *
    * @return out If the header of the tuple is invalid.
    */
   MOZ_MUST_USE JS::Result<Ok> enterTaggedTuple(
       BinASTKind& tag, BinASTTokenReaderContext::BinASTFields& fields,
-      AutoTaggedTuple& guard);
+      const Context&, AutoTaggedTuple& guard);
 
   /**
    * Read a single unsigned long.
    */
-  MOZ_MUST_USE JS::Result<uint32_t> readUnsignedLong() { return readVarU32(); }
+  MOZ_MUST_USE JS::Result<uint32_t> readUnsignedLong(const Context&) {
+    return readVarU32();
+  }
 
  private:
   /**
    * Read a single uint32_t.
    */
   MOZ_MUST_USE JS::Result<uint32_t> readVarU32();
 
  private: