Bug 1515224 - Part 1: Remove BinTokenReaderTester. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Wed, 19 Dec 2018 13:52:45 +0000
changeset 508411 2aa7e3b9ab8b4089b590355ad8356118f1747d1e
parent 508410 40332638e058ec65f8c1f71535988d5bb5dba1b5
child 508412 6c607dfcb6272b03df3e8a1f00efa4334fd3361f
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1515224
milestone66.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 1515224 - Part 1: Remove BinTokenReaderTester. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D14934
js/src/frontend/BinASTParser.cpp
js/src/frontend/BinASTParser.h
js/src/frontend/BinASTParserBase.h
js/src/frontend/BinASTParserPerTokenizer.cpp
js/src/frontend/BinASTParserPerTokenizer.h
js/src/frontend/BinSource.yaml
js/src/frontend/BinTokenReaderTester.cpp
js/src/frontend/BinTokenReaderTester.h
js/src/frontend/moz.build
js/src/jsapi-tests/moz.build
js/src/jsapi-tests/testBinASTReader.cpp
js/src/jsapi-tests/testBinTokenReaderTester.cpp
js/src/shell/js.cpp
--- a/js/src/frontend/BinASTParser.cpp
+++ b/js/src/frontend/BinASTParser.cpp
@@ -14,17 +14,17 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Casting.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/Move.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Vector.h"
 
 #include "frontend/BinSource-macros.h"
-#include "frontend/BinTokenReaderTester.h"
+#include "frontend/BinTokenReaderMultipart.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/ParseNode.h"
 #include "frontend/Parser.h"
 #include "frontend/SharedContext.h"
 
 #include "vm/RegExpObject.h"
 
 #include "frontend/ParseContext-inl.h"
@@ -4960,12 +4960,11 @@ BinASTParser<Tok>::parseOptionalVariable
 
   return result;
 }
 
 // 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<BinTokenReaderMultipart>;
-template class BinASTParser<BinTokenReaderTester>;
 
 }  // namespace frontend
 }  // namespace js
--- a/js/src/frontend/BinASTParser.h
+++ b/js/src/frontend/BinASTParser.h
@@ -13,17 +13,16 @@
 #define frontend_BinASTParser_h
 
 #include "mozilla/Maybe.h"
 
 #include "frontend/BCEParserHandle.h"
 #include "frontend/BinASTParserPerTokenizer.h"
 #include "frontend/BinToken.h"
 #include "frontend/BinTokenReaderMultipart.h"
-#include "frontend/BinTokenReaderTester.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/ParseContext.h"
 #include "frontend/ParseNode.h"
 #include "frontend/SharedContext.h"
 
 #include "js/CompileOptions.h"
 #include "js/GCHashTable.h"
 #include "js/GCVector.h"
@@ -484,14 +483,13 @@ class BinASTParser : public BinASTParser
   JS::Result<LexicalScopeNode*> parseOptionalCatchClause();
   JS::Result<ParseNode*> parseOptionalExpression();
   JS::Result<ParseNode*> parseOptionalSpreadElementOrExpression();
   JS::Result<ParseNode*> parseOptionalStatement();
   JS::Result<ParseNode*> parseOptionalVariableDeclarationOrExpression();
 };
 
 extern template class BinASTParser<BinTokenReaderMultipart>;
-extern template class BinASTParser<BinTokenReaderTester>;
 
 }  // namespace frontend
 }  // namespace js
 
 #endif  // frontend_BinASTParser_h
--- a/js/src/frontend/BinASTParserBase.h
+++ b/js/src/frontend/BinASTParserBase.h
@@ -5,18 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef frontend_BinASTParserBase_h
 #define frontend_BinASTParserBase_h
 
 #include <stddef.h>
 
 #include "ds/LifoAlloc.h"
-#include "frontend/BinTokenReaderMultipart.h"
-#include "frontend/BinTokenReaderTester.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/ParseContext.h"
 #include "frontend/ParseNode.h"
 #include "frontend/SharedContext.h"
 #include "js/RootingAPI.h"
 #include "js/TracingAPI.h"
 #include "js/Utility.h"
 #include "vm/JSContext.h"
--- a/js/src/frontend/BinASTParserPerTokenizer.cpp
+++ b/js/src/frontend/BinASTParserPerTokenizer.cpp
@@ -11,17 +11,17 @@
 #include "mozilla/Maybe.h"
 #include "mozilla/Move.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/Vector.h"
 
 #include "frontend/BinASTParser.h"
 #include "frontend/BinSource-macros.h"
-#include "frontend/BinTokenReaderTester.h"
+#include "frontend/BinTokenReaderMultipart.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/ParseNode.h"
 #include "frontend/Parser.h"
 #include "frontend/SharedContext.h"
 
 #include "js/Result.h"
 #include "vm/RegExpObject.h"
 
@@ -842,12 +842,11 @@ BinASTParserPerTokenizer<Tok>::asFinalPa
 
   return static_cast<const FinalParser*>(this);
 }
 
 // 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<BinTokenReaderMultipart>;
-template class BinASTParserPerTokenizer<BinTokenReaderTester>;
 
 }  // namespace frontend
 }  // namespace js
--- a/js/src/frontend/BinASTParserPerTokenizer.h
+++ b/js/src/frontend/BinASTParserPerTokenizer.h
@@ -16,17 +16,16 @@
 
 #include "mozilla/Maybe.h"
 
 #include "frontend/BCEParserHandle.h"
 #include "frontend/BinASTEnum.h"
 #include "frontend/BinASTParserBase.h"
 #include "frontend/BinToken.h"
 #include "frontend/BinTokenReaderMultipart.h"
-#include "frontend/BinTokenReaderTester.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/ParseContext.h"
 #include "frontend/ParseNode.h"
 #include "frontend/SharedContext.h"
 
 #include "js/CompileOptions.h"
 #include "js/GCHashTable.h"
 #include "js/GCVector.h"
@@ -314,14 +313,13 @@ class BinParseContext : public ParseCont
   template <typename Tok>
   BinParseContext(JSContext* cx, BinASTParserPerTokenizer<Tok>* parser,
                   SharedContext* sc, Directives* newDirectives)
       : ParseContext(cx, parser->parseContext_, sc, *parser, parser->usedNames_,
                      newDirectives, /* isFull = */ true) {}
 };
 
 extern template class BinASTParserPerTokenizer<BinTokenReaderMultipart>;
-extern template class BinASTParserPerTokenizer<BinTokenReaderTester>;
 
 }  // namespace frontend
 }  // namespace js
 
 #endif  // frontend_BinASTParserPerTokenizer_h
--- a/js/src/frontend/BinSource.yaml
+++ b/js/src/frontend/BinSource.yaml
@@ -32,17 +32,17 @@ cpp:
         #include "mozilla/ArrayUtils.h"
         #include "mozilla/Casting.h"
         #include "mozilla/Maybe.h"
         #include "mozilla/Move.h"
         #include "mozilla/PodOperations.h"
         #include "mozilla/Vector.h"
 
         #include "frontend/BinSource-macros.h"
-        #include "frontend/BinTokenReaderTester.h"
+        #include "frontend/BinTokenReaderMultipart.h"
         #include "frontend/FullParseHandler.h"
         #include "frontend/ParseNode.h"
         #include "frontend/Parser.h"
         #include "frontend/SharedContext.h"
 
         #include "vm/RegExpObject.h"
 
         #include "frontend/ParseContext-inl.h"
@@ -58,17 +58,16 @@ cpp:
         }
 
     footer: |
 
         // 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<BinTokenReaderMultipart>;
-        template class BinASTParser<BinTokenReaderTester>;
 
         } // namespace frontend
         } // namespace js
 
 
 
 hpp:
     # Rules for generating BinASTParser.h
@@ -87,17 +86,16 @@ hpp:
             #define frontend_BinASTParser_h
 
             #include "mozilla/Maybe.h"
 
             #include "frontend/BCEParserHandle.h"
             #include "frontend/BinASTParserPerTokenizer.h"
             #include "frontend/BinToken.h"
             #include "frontend/BinTokenReaderMultipart.h"
-            #include "frontend/BinTokenReaderTester.h"
             #include "frontend/FullParseHandler.h"
             #include "frontend/ParseContext.h"
             #include "frontend/ParseNode.h"
             #include "frontend/SharedContext.h"
 
             #include "js/CompileOptions.h"
             #include "js/GCHashTable.h"
             #include "js/GCVector.h"
@@ -192,17 +190,16 @@ hpp:
 
                 using Base::forceStrictIfNecessary;
 
               public:
         footer: |
             };
 
             extern template class BinASTParser<BinTokenReaderMultipart>;
-            extern template class BinASTParser<BinTokenReaderTester>;
 
             } // namespace frontend
             } // namespace js
 
             #endif // frontend_BinASTParser_h
 
     enums:
         header: |
deleted file mode 100644
--- a/js/src/frontend/BinTokenReaderTester.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: set ts=8 sts=2 et sw=2 tw=80:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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/BinTokenReaderTester.h"
-
-#include "mozilla/ArrayUtils.h"
-#include "mozilla/Casting.h"
-#include "mozilla/EndianUtils.h"
-#include "mozilla/PodOperations.h"
-
-#include "frontend/BinSource-macros.h"
-#include "js/Result.h"
-
-namespace js {
-namespace frontend {
-
-using BinFields = BinTokenReaderTester::BinFields;
-using AutoList = BinTokenReaderTester::AutoList;
-using AutoTaggedTuple = BinTokenReaderTester::AutoTaggedTuple;
-using AutoTuple = BinTokenReaderTester::AutoTuple;
-
-BinTokenReaderTester::BinTokenReaderTester(JSContext* cx, ErrorReporter* er,
-                                           const uint8_t* start,
-                                           const size_t length)
-    : BinTokenReaderBase(cx, er, start, length) {}
-
-BinTokenReaderTester::BinTokenReaderTester(JSContext* cx, ErrorReporter* er,
-                                           const Vector<uint8_t>& buf)
-    : BinTokenReaderBase(cx, er, buf.begin(), buf.length()) {}
-
-JS::Result<Ok> BinTokenReaderTester::readHeader() {
-  // This format does not have a header.
-  return Ok();
-}
-
-JS::Result<bool> BinTokenReaderTester::readBool() {
-  updateLatestKnownGood();
-  BINJS_MOZ_TRY_DECL(byte, readByte());
-
-  switch (byte) {
-    case 0:
-      return false;
-    case 1:
-      return true;
-    case 2:
-      return raiseError("Not implemented: null boolean value");
-    default:
-      return raiseError("Invalid boolean value");
-  }
-}
-
-// Nullable doubles (little-endian)
-//
-// NULL_FLOAT_REPRESENTATION (signaling NaN) => null
-// anything other 64 bit sequence => IEEE-764 64-bit floating point number
-JS::Result<double> BinTokenReaderTester::readDouble() {
-  updateLatestKnownGood();
-
-  uint8_t bytes[8];
-  MOZ_ASSERT(sizeof(bytes) == sizeof(double));
-  MOZ_TRY(
-      readBuf(reinterpret_cast<uint8_t*>(bytes), mozilla::ArrayLength(bytes)));
-
-  // Decode little-endian.
-  const uint64_t asInt = mozilla::LittleEndian::readUint64(bytes);
-
-  if (asInt == NULL_FLOAT_REPRESENTATION) {
-    return raiseError("Not implemented: null double value");
-  }
-
-  // Canonicalize NaN, just to make sure another form of signalling NaN
-  // doesn't slip past us.
-  return JS::CanonicalizeNaN(mozilla::BitwiseCast<double>(asInt));
-}
-
-// Internal uint32_t
-//
-// Encoded as 4 bytes, little-endian.
-MOZ_MUST_USE JS::Result<uint32_t> BinTokenReaderTester::readInternalUint32() {
-  uint8_t bytes[4];
-  MOZ_ASSERT(sizeof(bytes) == sizeof(uint32_t));
-  MOZ_TRY(readBuf(bytes, 4));
-
-  // Decode little-endian.
-  return mozilla::LittleEndian::readUint32(bytes);
-}
-
-// Nullable strings:
-// - "<string>" (not counted in byte length)
-// - byte length (not counted in byte length)
-// - bytes (UTF-8)
-// - "</string>" (not counted in byte length)
-//
-// The special sequence of bytes `[255, 0]` (which is an invalid UTF-8 sequence)
-// is reserved to `null`.
-JS::Result<JSAtom*> BinTokenReaderTester::readMaybeAtom() {
-  updateLatestKnownGood();
-
-  MOZ_TRY(readConst("<string>"));
-
-  RootedAtom result(cx_);
-
-  // 1. Read byteLength
-  BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
-
-  // 2. Reject if we can't read
-  if (current_ + byteLen < current_) {  // Check for overflows
-    return raiseError("Arithmetics overflow: string is too long");
-  }
-
-  if (current_ + byteLen > stop_) {
-    return raiseError("Not enough bytes to read chars");
-  }
-
-  if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
-    // 3. Special case: null string.
-    result = nullptr;
-  } else {
-    // 4. Other strings (bytes are copied)
-    BINJS_TRY_VAR(result, Atomize(cx_, (const char*)current_, byteLen));
-  }
-
-  current_ += byteLen;
-  MOZ_TRY(readConst("</string>"));
-  return result.get();
-}
-
-JS::Result<JSAtom*> BinTokenReaderTester::readMaybeIdentifierName() {
-  return readMaybeAtom();
-}
-
-JS::Result<JSAtom*> BinTokenReaderTester::readIdentifierName() {
-  return readAtom();
-}
-
-JS::Result<JSAtom*> BinTokenReaderTester::readMaybePropertyKey() {
-  return readMaybeAtom();
-}
-
-JS::Result<JSAtom*> BinTokenReaderTester::readPropertyKey() {
-  return readAtom();
-}
-
-// Nullable strings:
-// - "<string>" (not counted in byte length)
-// - byte length (not counted in byte length)
-// - bytes (UTF-8)
-// - "</string>" (not counted in byte length)
-//
-// The special sequence of bytes `[255, 0]` (which is an invalid UTF-8 sequence)
-// is reserved to `null`.
-JS::Result<Ok> BinTokenReaderTester::readChars(Chars& out) {
-  updateLatestKnownGood();
-
-  MOZ_TRY(readConst("<string>"));
-
-  // 1. Read byteLength
-  BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
-
-  // 2. Reject if we can't read
-  if (current_ + byteLen < current_) {  // Check for overflows
-    return raiseError("Arithmetics overflow: string is too long");
-  }
-
-  if (current_ + byteLen > stop_) {
-    return raiseError("Not enough bytes to read chars");
-  }
-
-  if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
-    // 3. Special case: null string.
-    return raiseError("Empty string");
-  }
-
-  // 4. Other strings (bytes are copied)
-  if (!out.resize(byteLen)) {
-    return raiseOOM();
-  }
-
-  mozilla::PodCopy(out.begin(), current_, byteLen);
-
-  current_ += byteLen;
-
-  MOZ_TRY(readConst("</string>"));
-  return Ok();
-}
-
-JS::Result<JSAtom*> BinTokenReaderTester::readAtom() {
-  RootedAtom atom(cx_);
-  MOZ_TRY_VAR(atom, readMaybeAtom());
-
-  if (!atom) {
-    return raiseError("Empty string");
-  }
-  return atom.get();
-}
-
-JS::Result<BinVariant> BinTokenReaderTester::readVariant() {
-  MOZ_TRY(readConst("<string>"));
-  BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
-
-  // 2. Reject if we can't read
-  if (current_ + byteLen < current_) {  // Check for overflows
-    return raiseError("Arithmetics overflow: string is too long");
-  }
-
-  if (current_ + byteLen > stop_) {
-    return raiseError("Not enough bytes to read chars");
-  }
-
-  if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
-    // 3. Special case: null string.
-    return raiseError("Empty variant");
-  }
-
-  BinaryASTSupport::CharSlice slice((const char*)current_, byteLen);
-  current_ += byteLen;
-
-  BINJS_MOZ_TRY_DECL(variant, cx_->runtime()->binast().binVariant(cx_, slice));
-  if (!variant) {
-    return raiseError("Not a variant");
-  }
-
-  MOZ_TRY(readConst("</string>"));
-  return *variant;
-}
-
-JS::Result<BinTokenReaderBase::SkippableSubTree>
-BinTokenReaderTester::readSkippableSubTree() {
-  updateLatestKnownGood();
-  BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
-
-  if (current_ + byteLen > stop_ || current_ + byteLen < current_) {
-    return raiseError("Invalid byte length in readSkippableSubTree");
-  }
-
-  const auto start = offset();
-
-  current_ += byteLen;
-
-  return BinTokenReaderBase::SkippableSubTree(start, byteLen);
-}
-
-// Untagged tuple:
-// - "<tuple>";
-// - contents (specified by the higher-level grammar);
-// - "</tuple>"
-JS::Result<Ok> BinTokenReaderTester::enterUntaggedTuple(AutoTuple& guard) {
-  MOZ_TRY(readConst("<tuple>"));
-
-  guard.init();
-  return Ok();
-}
-
-// Tagged tuples:
-// - "<tuple>";
-// - "<head>";
-// - non-null string `name`, followed by \0 (see `readString()`);
-// - uint32_t number of fields;
-// - array of `number of fields` non-null strings followed each by \0 (see
-// `readString()`);
-// - "</head>";
-// - content (specified by the higher-level grammar);
-// - "</tuple>"
-JS::Result<Ok> BinTokenReaderTester::enterTaggedTuple(BinKind& tag,
-                                                      BinFields& fields,
-                                                      AutoTaggedTuple& guard) {
-  // Header
-  MOZ_TRY(readConst("<tuple>"));
-  MOZ_TRY(readConst("<head>"));
-
-  // This would probably be much faster with a HashTable, but we don't
-  // really care about the speed of BinTokenReaderTester.
-  do {
-#define FIND_MATCH(CONSTRUCTOR, NAME) \
-  if (matchConst(NAME, true)) {       \
-    tag = BinKind::CONSTRUCTOR;       \
-    break;                            \
-  }  // else
-
-    FOR_EACH_BIN_KIND(FIND_MATCH)
-#undef FIND_MATCH
-
-    // else
-    return raiseError("Invalid tag");
-  } while (false);
-
-  // Now fields.
-  BINJS_MOZ_TRY_DECL(fieldNum, readInternalUint32());
-
-  if (fieldNum > FIELD_NUM_MAX) {
-    return raiseError("Too many fields");
-  }
-
-  fields.clear();
-  if (!fields.reserve(fieldNum)) {
-    return raiseOOM();
-  }
-
-  for (uint32_t i = 0; i < fieldNum; ++i) {
-    // This would probably be much faster with a HashTable, but we don't
-    // really care about the speed of BinTokenReaderTester.
-    BinField field;
-    do {
-#define FIND_MATCH(CONSTRUCTOR, NAME) \
-  if (matchConst(NAME, true)) {       \
-    field = BinField::CONSTRUCTOR;    \
-    break;                            \
-  }  // else
-
-      FOR_EACH_BIN_FIELD(FIND_MATCH)
-#undef FIND_MATCH
-
-      // else
-      return raiseError("Invalid field");
-    } while (false);
-
-    // Make sure that we do not have duplicate fields.
-    // Search is linear, but again, we don't really care
-    // in this implementation.
-    for (uint32_t j = 0; j < i; ++j) {
-      if (fields[j] == field) {
-        return raiseError("Duplicate field");
-      }
-    }
-
-    fields.infallibleAppend(field);  // Already checked.
-  }
-
-  // End of header
-  MOZ_TRY(readConst("</head>"));
-
-  // Enter the body.
-  guard.init();
-  return Ok();
-}
-
-// List:
-//
-// - "<list>" (not counted in byte length);
-// - uint32_t byte length (not counted in byte length);
-// - uint32_t number of items;
-// - contents (specified by higher-level grammar);
-// - "</list>" (not counted in byte length)
-//
-// The total byte length of `number of items` + `contents` must be `byte
-// length`.
-JS::Result<Ok> BinTokenReaderTester::enterList(uint32_t& items,
-                                               AutoList& guard) {
-  MOZ_TRY(readConst("<list>"));
-  guard.init();
-
-  MOZ_TRY_VAR(items, readInternalUint32());
-  return Ok();
-}
-
-void BinTokenReaderTester::AutoBase::init() { initialized_ = true; }
-
-BinTokenReaderTester::AutoBase::AutoBase(BinTokenReaderTester& reader)
-    : initialized_(false), reader_(reader) {}
-
-BinTokenReaderTester::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<Ok> BinTokenReaderTester::AutoBase::checkPosition(
-    const uint8_t* expectedEnd) {
-  if (reader_.current_ != expectedEnd) {
-    return reader_.raiseError(
-        "Caller did not consume the expected set of bytes");
-  }
-
-  return Ok();
-}
-
-BinTokenReaderTester::AutoList::AutoList(BinTokenReaderTester& reader)
-    : AutoBase(reader) {}
-
-void BinTokenReaderTester::AutoList::init() { AutoBase::init(); }
-
-JS::Result<Ok> BinTokenReaderTester::AutoList::done() {
-  MOZ_ASSERT(initialized_);
-  initialized_ = false;
-  if (reader_.hasRaisedError()) {
-    // Already errored, no need to check further.
-    return reader_.cx_->alreadyReportedError();
-  }
-
-  // Check suffix.
-  MOZ_TRY(reader_.readConst("</list>"));
-
-  return Ok();
-}
-
-BinTokenReaderTester::AutoTaggedTuple::AutoTaggedTuple(
-    BinTokenReaderTester& reader)
-    : AutoBase(reader) {}
-
-JS::Result<Ok> BinTokenReaderTester::AutoTaggedTuple::done() {
-  MOZ_ASSERT(initialized_);
-  initialized_ = false;
-  if (reader_.hasRaisedError()) {
-    // Already errored, no need to check further.
-    return reader_.cx_->alreadyReportedError();
-  }
-
-  // Check suffix.
-  MOZ_TRY(reader_.readConst("</tuple>"));
-
-  return Ok();
-}
-
-BinTokenReaderTester::AutoTuple::AutoTuple(BinTokenReaderTester& reader)
-    : AutoBase(reader) {}
-
-JS::Result<Ok> BinTokenReaderTester::AutoTuple::done() {
-  MOZ_ASSERT(initialized_);
-  initialized_ = false;
-  if (reader_.hasRaisedError()) {
-    // Already errored, no need to check further.
-    return reader_.cx_->alreadyReportedError();
-  }
-
-  // Check suffix.
-  MOZ_TRY(reader_.readConst("</tuple>"));
-
-  return Ok();
-}
-
-}  // namespace frontend
-}  // namespace js
deleted file mode 100644
--- a/js/src/frontend/BinTokenReaderTester.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: set ts=8 sts=2 et sw=2 tw=80:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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_BinTokenReaderTester_h
-#define frontend_BinTokenReaderTester_h
-
-#include "mozilla/Maybe.h"
-
-#include "frontend/BinToken.h"
-#include "frontend/BinTokenReaderBase.h"
-
-#include "js/Result.h"
-#include "js/TypeDecls.h"
-
-#if !defined(NIGHTLY_BUILD)
-#error \
-    "BinTokenReaderTester.* is designed to help test implementations of successive versions of JS BinaryAST. It is available only on Nightly."
-#endif  // !defined(NIGHTLY_BUILD)
-
-namespace js {
-namespace frontend {
-
-class BinASTSourceMetadata;
-
-/**
- * A token reader for a simple, alternative serialization format for BinAST.
- *
- * This serialization format, which is also supported by the reference
- * implementation of the BinAST compression suite, is designed to be
- * mostly human-readable and easy to check for all sorts of deserialization
- * errors. While this format is NOT designed to be shipped to end-users, it
- * is nevertheless a very useful tool for implementing and testing parsers.
- *
- * Both the format and the implementation are ridiculously inefficient:
- *
- * - the underlying format tags almost all its data with e.g. `<tuple>`,
- * `</tuple>` to aid with detecting offset errors or format error;
- * - the underlying format copies list of fields into every single node, instead
- *   of keeping them once in the header;
- * - every kind/field extraction requires memory allocation and plenty of string
- *   comparisons;
- * - ...
- *
- * This token reader is designed to be API-compatible with the standard,
- * shipped, token reader. For these reasons:
- *
- * - it does not support any form of look ahead, push back;
- * - it does not support any form of error recovery.
- */
-class MOZ_STACK_CLASS BinTokenReaderTester : public BinTokenReaderBase {
- public:
-  // A list of fields, in the order in which they appear in the stream.
-  using BinFields = Vector<BinField, 8>;
-
-  // A bunch of characters. At this stage, there is no guarantee on whether
-  // they are valid UTF-8. Future versions may replace this by slice into
-  // the buffer.
-  using Chars = Vector<uint8_t, 32>;
-
-  class AutoList;
-  class AutoTuple;
-  class AutoTaggedTuple;
-
-  // The maximum number of fields in single tagged tuple.
-  static const uint32_t FIELD_NUM_MAX = 32;
-
- public:
-  /**
-   * Construct a token reader.
-   *
-   * Does NOT copy the buffer.
-   */
-  BinTokenReaderTester(JSContext* cx, ErrorReporter* er, const uint8_t* start,
-                       const size_t length);
-
-  /**
-   * Construct a token reader.
-   *
-   * Does NOT copy the buffer.
-   */
-  BinTokenReaderTester(JSContext* cx, ErrorReporter* er,
-                       const Vector<uint8_t>& chars);
-
-  /**
-   * Read the header of the file.
-   */
-  MOZ_MUST_USE JS::Result<Ok> readHeader();
-
-  // --- Primitive values.
-  //
-  // Note that the underlying format allows for a `null` value for primitive
-  // values.
-  //
-  // 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();
-
-  /**
-   * Read a single `number` value.
-   * @return false If a double could not be read. In this case, an error
-   * has been raised.
-   */
-  MOZ_MUST_USE JS::Result<double> readDouble();
-
-  /**
-   * Read a single `string | null` value.
-   *
-   * Fails if that string is not valid UTF-8.
-   *
-   * The returned `JSAtom*` may be `nullptr`.
-   */
-  MOZ_MUST_USE JS::Result<JSAtom*> readMaybeAtom();
-
-  /**
-   * Read a single `string` value.
-   *
-   * Fails if that string is not valid UTF-8 or in case of `null` string.
-   *
-   * The returned `JSAtom*` is never `nullptr`.
-   */
-  MOZ_MUST_USE JS::Result<JSAtom*> readAtom();
-
-  /**
-   * Read a single IdentifierName value.
-   */
-  MOZ_MUST_USE JS::Result<JSAtom*> readMaybeIdentifierName();
-  MOZ_MUST_USE JS::Result<JSAtom*> readIdentifierName();
-
-  /**
-   * Read a single PropertyKey value.
-   */
-  MOZ_MUST_USE JS::Result<JSAtom*> readMaybePropertyKey();
-  MOZ_MUST_USE JS::Result<JSAtom*> readPropertyKey();
-
-  /**
-   * Read a single `string | null` value.
-   *
-   * There is no guarantee that the string is valid UTF-8.
-   */
-  MOZ_MUST_USE JS::Result<Ok> readChars(Chars&);
-
-  /**
-   * Read a single `BinVariant | null` value.
-   */
-  MOZ_MUST_USE JS::Result<mozilla::Maybe<BinVariant>> readMaybeVariant();
-  MOZ_MUST_USE JS::Result<BinVariant> readVariant();
-
-  /**
-   * 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();
-
-  // --- 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.
-
-  /**
-   * Start reading a list.
-   *
-   * @param length (OUT) The number of elements in the list.
-   * @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()`.
-   *
-   * @return out If the header of the list is invalid.
-   */
-  MOZ_MUST_USE JS::Result<Ok> enterList(uint32_t& length, AutoList& guard);
-
-  /**
-   * Start reading a tagged tuple.
-   *
-   * @param tag (OUT) The tag of the tuple.
-   * @param fields (OUT) The ORDERED list of fields encoded in this tuple.
-   * @param guard (OUT) A guard, ensuring that we read the tagged tuple
-   * correctly.
-   *
-   * The `guard` is dedicated to ensuring that reading the list has consumed
-   * exactly all the bytes from that tuple. The `guard` MUST therefore be
-   * 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(
-      BinKind& tag, BinTokenReaderTester::BinFields& fields,
-      AutoTaggedTuple& guard);
-
-  /**
-   * Start reading an untagged tuple.
-   *
-   * @param guard (OUT) A guard, ensuring that we read the tuple correctly.
-   *
-   * The `guard` is dedicated to ensuring that reading the list has consumed
-   * exactly all the bytes from that tuple. The `guard` MUST therefore be
-   * 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> enterUntaggedTuple(AutoTuple& guard);
-
-  /**
-   * Read a single unsigned long.
-   */
-  MOZ_MUST_USE JS::Result<uint32_t> readUnsignedLong() {
-    return readInternalUint32();
-  }
-
-  /**
-   * Read a single uint32_t.
-   */
-  MOZ_MUST_USE JS::Result<uint32_t> readInternalUint32();
-
- public:
-  void traceMetadata(JSTracer*) {}
-  BinASTSourceMetadata* takeMetadata() {
-    MOZ_CRASH("Tester format has no metadata to take!");
-  }
-  MOZ_MUST_USE JS::Result<Ok> initFromScriptSource(ScriptSource*) {
-    MOZ_CRASH("Tester format not for dynamic use");
-  }
-
- public:
-  // The following classes are used whenever we encounter a tuple/tagged
-  // tuple/list to make sure that:
-  //
-  // - if the construct "knows" its byte length, we have exactly consumed all
-  //   the bytes (otherwise, this means that the file is corrupted, perhaps on
-  //   purpose, so we need to reject the stream);
-  // - if the construct has a footer, once we are done reading it, we have
-  //   reached the footer (this is to aid with debugging).
-  //
-  // In either case, the caller MUST call method `done()` of the guard once
-  // it is done reading the tuple/tagged tuple/list, to report any pending
-  // error.
-
-  // Base class used by other Auto* classes.
-  class MOZ_STACK_CLASS AutoBase {
-   protected:
-    explicit AutoBase(BinTokenReaderTester& reader);
-    ~AutoBase();
-
-    // Raise an error if we are not in the expected position.
-    MOZ_MUST_USE JS::Result<Ok> checkPosition(const uint8_t* expectedPosition);
-
-    friend BinTokenReaderTester;
-    void init();
-
-    // Set to `true` if `init()` has been called. Reset to `false` once
-    // all conditions have been checked.
-    bool initialized_;
-    BinTokenReaderTester& reader_;
-  };
-
-  // Guard class used to ensure that `enterList` is used properly.
-  class MOZ_STACK_CLASS AutoList : public AutoBase {
-   public:
-    explicit AutoList(BinTokenReaderTester& reader);
-
-    // Check that we have properly read to the end of the list.
-    MOZ_MUST_USE JS::Result<Ok> done();
-
-   protected:
-    friend BinTokenReaderTester;
-    void init();
-  };
-
-  // Guard class used to ensure that `enterTaggedTuple` is used properly.
-  class MOZ_STACK_CLASS AutoTaggedTuple : public AutoBase {
-   public:
-    explicit AutoTaggedTuple(BinTokenReaderTester& reader);
-
-    // Check that we have properly read to the end of the tuple.
-    MOZ_MUST_USE JS::Result<Ok> done();
-  };
-
-  // Guard class used to ensure that `readTuple` is used properly.
-  class MOZ_STACK_CLASS AutoTuple : public AutoBase {
-   public:
-    explicit AutoTuple(BinTokenReaderTester& reader);
-
-    // Check that we have properly read to the end of the tuple.
-    MOZ_MUST_USE JS::Result<Ok> done();
-  };
-
-  // Compare a `Chars` and a string literal (ONLY a string literal).
-  template <size_t N>
-  static bool equals(const Chars& left, const char (&right)[N]) {
-    MOZ_ASSERT(N > 0);
-    MOZ_ASSERT(right[N - 1] == 0);
-    if (left.length() + 1 /* implicit NUL */ != N) {
-      return false;
-    }
-
-    if (!std::equal(left.begin(), left.end(), right)) {
-      return false;
-    }
-
-    return true;
-  }
-
-  // Ensure that we are visiting the right fields.
-  template <size_t N>
-  JS::Result<Ok, JS::Error&> checkFields(const BinKind kind,
-                                         const BinFields& actual,
-                                         const BinField (&expected)[N]) {
-    if (actual.length() != N) {
-      return raiseInvalidNumberOfFields(kind, N, actual.length());
-    }
-
-    for (size_t i = 0; i < N; ++i) {
-      if (actual[i] != expected[i]) {
-        return raiseInvalidField(describeBinKind(kind), actual[i]);
-      }
-    }
-
-    return Ok();
-  }
-
-  // Special case for N=0, as empty arrays are not permitted in C++
-  JS::Result<Ok, JS::Error&> checkFields0(const BinKind kind,
-                                          const BinFields& actual) {
-    if (actual.length() != 0) {
-      return raiseInvalidNumberOfFields(kind, 0, actual.length());
-    }
-
-    return Ok();
-  }
-};
-
-}  // namespace frontend
-}  // namespace js
-
-#endif  // frontend_BinTokenReaderTester_h
--- a/js/src/frontend/moz.build
+++ b/js/src/frontend/moz.build
@@ -56,20 +56,19 @@ UNIFIED_SOURCES += [
 
 # Parser.cpp cannot be built in unified mode because of explicit
 #   template instantiations.
 SOURCES += [
     'Parser.cpp',
 ]
 
 if CONFIG['JS_BUILD_BINAST']:
-    # Using SOURCES, as UNIFIED_SOURCES causes mysterious bugs on 32-bit platforms.
-    # These parts of BinAST are designed only to test evolutions of the
-    # specification.
-    SOURCES += ['BinTokenReaderTester.cpp']
+    # Using SOURCES, as UNIFIED_SOURCES causes mysterious bugs on 32-bit
+    # platforms.
+
     # These parts of BinAST should eventually move to release.
     SOURCES += [
         'BinASTParser.cpp',
         'BinASTParserBase.cpp',
         'BinASTParserPerTokenizer.cpp',
         'BinSourceRuntimeSupport.cpp',
         'BinToken.cpp',
         'BinTokenReaderBase.cpp',
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -152,17 +152,16 @@ if CONFIG['JS_BUILD_BINAST'] and CONFIG[
     # Standalone builds leave the source directory untouched,
     # which lets us run tests with the data files intact.
     # Otherwise, in the current state of the build system,
     # we can't have data files in js/src tests.
     # Also, fuzzing builds modify the const matching in the
     # token reader and hence affect the correctness of the tests.
     UNIFIED_SOURCES += [
         'testBinASTReader.cpp',
-        'testBinTokenReaderTester.cpp'
     ]
 
 
 DEFINES['EXPORT_JS_API'] = True
 
 LOCAL_INCLUDES += [
     '!..',
     '..',
--- a/js/src/jsapi-tests/testBinASTReader.cpp
+++ b/js/src/jsapi-tests/testBinASTReader.cpp
@@ -31,19 +31,129 @@
 #include "jsapi-tests/tests.h"
 
 #include "vm/Interpreter.h"
 
 using UsedNameTracker = js::frontend::UsedNameTracker;
 using namespace JS;
 using namespace js;
 
-extern void enterJsDirectory();
-extern void exitJsDirectory();
-extern void readFull(const char* path, js::Vector<uint8_t>& buf);
+// Hack: These tests need access to resources, which are present in the source
+// dir but not copied by our build system. To simplify things, we chdir to the
+// source dir at the start of each test and return to the previous directory
+// afterwards.
+
+#if defined(XP_UNIX)
+
+#include <sys/param.h>
+
+static int gJsDirectory(0);
+void enterJsDirectory() {
+  // Save current directory.
+  MOZ_ASSERT(gJsDirectory == 0);
+  gJsDirectory = open(".", O_RDONLY);
+  MOZ_ASSERT(gJsDirectory != 0, "Could not open directory '.'");
+  // Go to the directory provided by the test harness, if any.
+  const char* destination = getenv("CPP_UNIT_TESTS_DIR_JS_SRC");
+  if (destination) {
+    if (chdir(destination) == -1) {
+      MOZ_CRASH_UNSAFE_PRINTF("Could not chdir to %s", destination);
+    }
+  }
+}
+
+void exitJsDirectory() {
+  MOZ_ASSERT(gJsDirectory);
+  if (fchdir(gJsDirectory) == -1) {
+    MOZ_CRASH("Could not return to original directory");
+  }
+  if (close(gJsDirectory) != 0) {
+    MOZ_CRASH("Could not close js directory");
+  }
+  gJsDirectory = 0;
+}
+
+#else
+
+char gJsDirectory[MAX_PATH] = {0};
+
+void enterJsDirectory() {
+  // Save current directory.
+  MOZ_ASSERT(strlen(gJsDirectory) == 0);
+  auto result = GetCurrentDirectory(MAX_PATH, gJsDirectory);
+  if (result <= 0) {
+    MOZ_CRASH("Could not get current directory");
+  }
+  if (result > MAX_PATH) {
+    MOZ_CRASH_UNSAFE_PRINTF(
+        "Could not get current directory: needed %ld bytes, got %ld\n", result,
+        MAX_PATH);
+  }
+
+  // Find destination directory, if any.
+  char destination[MAX_PATH];
+  result = GetEnvironmentVariable("CPP_UNIT_TESTS_DIR_JS_SRC", destination,
+                                  MAX_PATH);
+  if (result == 0) {
+    if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+      return;  // No need to chdir
+    } else {
+      MOZ_CRASH("Could not get CPP_UNIT_TESTS_DIR_JS_SRC");
+    }
+  }
+  if (result > MAX_PATH) {
+    MOZ_CRASH_UNSAFE_PRINTF(
+        "Could not get CPP_UNIT_TESTS_DIR_JS_SRC: needed %ld bytes, got %ld\n",
+        result, MAX_PATH);
+  }
+
+  // Go to the directory.
+  if (SetCurrentDirectory(destination) == 0) {
+    MOZ_CRASH_UNSAFE_PRINTF("Could not chdir to %s", destination);
+  }
+}
+
+void exitJsDirectory() {
+  MOZ_ASSERT(strlen(gJsDirectory) > 0);
+  if (SetCurrentDirectory(gJsDirectory) == 0) {
+    MOZ_CRASH("Could not return to original directory");
+  }
+  gJsDirectory[0] = 0;
+}
+
+#endif  // defined(XP_UNIX) || defined(XP_WIN)
+
+void readFull(const char* path, js::Vector<uint8_t>& buf) {
+  enterJsDirectory();
+  buf.shrinkTo(0);
+  FILE* in = fopen(path, "rb");
+  if (!in) {
+    MOZ_CRASH_UNSAFE_PRINTF("Could not open %s: %s", path, strerror(errno));
+  }
+
+  struct stat info;
+  if (stat(path, &info) < 0) {
+    MOZ_CRASH_UNSAFE_PRINTF("Could not get stat on %s", path);
+  }
+
+  if (!buf.growBy(info.st_size)) {
+    MOZ_CRASH("OOM");
+  }
+
+  int result = fread(buf.begin(), 1, info.st_size, in);
+  if (fclose(in) != 0) {
+    MOZ_CRASH("Could not close input file");
+  }
+  if (result != info.st_size) {
+    MOZ_CRASH_UNSAFE_PRINTF(
+        "Read error while reading %s: expected %llu bytes, got %llu", path,
+        (unsigned long long)info.st_size, (unsigned long long)result);
+  }
+  exitJsDirectory();
+}
 
 void readFull(JSContext* cx, const char* path, js::Vector<char16_t>& buf) {
   buf.shrinkTo(0);
 
   js::Vector<uint8_t> intermediate(cx);
   readFull(path, intermediate);
 
   if (!buf.appendAll(intermediate)) {
@@ -342,28 +452,16 @@ void runTestFromPath(JSContext* cx, cons
   }
 #elif defined(XP_UNIX)
   if (closedir(dir) != 0) {
     MOZ_CRASH("Could not close dir");
   }
 #endif  // defined(XP_WIN)
 }
 
-BEGIN_TEST(testBinASTReaderSimpleECMAScript2) {
-#if defined(XP_WIN)
-  runTestFromPath<js::frontend::BinTokenReaderTester>(
-      cx, "jsapi-tests\\binast\\parser\\tester\\");
-#else
-  runTestFromPath<js::frontend::BinTokenReaderTester>(
-      cx, "jsapi-tests/binast/parser/tester/");
-#endif  // defined(XP_XIN)
-  return true;
-}
-END_TEST(testBinASTReaderSimpleECMAScript2)
-
 BEGIN_TEST(testBinASTReaderMultipartECMAScript2) {
 #if defined(XP_WIN)
   runTestFromPath<js::frontend::BinTokenReaderMultipart>(
       cx, "jsapi-tests\\binast\\parser\\multipart\\");
 #else
   runTestFromPath<js::frontend::BinTokenReaderMultipart>(
       cx, "jsapi-tests/binast/parser/multipart/");
 #endif  // defined(XP_XIN)
deleted file mode 100644
--- a/js/src/jsapi-tests/testBinTokenReaderTester.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: set ts=8 sts=2 et sw=2 tw=80:
- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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 <string.h>
-#include <sys/stat.h>
-
-#if defined(XP_WIN)
-#include <windows.h>
-#elif defined(XP_UNIX)
-#include <fcntl.h>
-#include <unistd.h>
-#endif  // defined (XP_WIN) || defined (XP_UNIX)
-
-#include "mozilla/Maybe.h"
-
-#include "frontend/BinTokenReaderTester.h"
-#include "frontend/ErrorReporter.h"
-
-#include "js/UniquePtr.h"
-#include "js/Vector.h"
-
-#include "jsapi-tests/tests.h"
-
-using mozilla::Maybe;
-
-using Tokenizer = js::frontend::BinTokenReaderTester;
-using Chars = js::frontend::BinTokenReaderTester::Chars;
-
-// Hack: These tests need access to resources, which are present in the source
-// dir but not copied by our build system. To simplify things, we chdir to the
-// source dir at the start of each test and return to the previous directory
-// afterwards.
-
-#if defined(XP_UNIX)
-
-#include <sys/param.h>
-
-static int gJsDirectory(0);
-void enterJsDirectory() {
-  // Save current directory.
-  MOZ_ASSERT(gJsDirectory == 0);
-  gJsDirectory = open(".", O_RDONLY);
-  MOZ_ASSERT(gJsDirectory != 0, "Could not open directory '.'");
-  // Go to the directory provided by the test harness, if any.
-  const char* destination = getenv("CPP_UNIT_TESTS_DIR_JS_SRC");
-  if (destination) {
-    if (chdir(destination) == -1) {
-      MOZ_CRASH_UNSAFE_PRINTF("Could not chdir to %s", destination);
-    }
-  }
-}
-
-void exitJsDirectory() {
-  MOZ_ASSERT(gJsDirectory);
-  if (fchdir(gJsDirectory) == -1) {
-    MOZ_CRASH("Could not return to original directory");
-  }
-  if (close(gJsDirectory) != 0) {
-    MOZ_CRASH("Could not close js directory");
-  }
-  gJsDirectory = 0;
-}
-
-#else
-
-char gJsDirectory[MAX_PATH] = {0};
-
-void enterJsDirectory() {
-  // Save current directory.
-  MOZ_ASSERT(strlen(gJsDirectory) == 0);
-  auto result = GetCurrentDirectory(MAX_PATH, gJsDirectory);
-  if (result <= 0) {
-    MOZ_CRASH("Could not get current directory");
-  }
-  if (result > MAX_PATH) {
-    MOZ_CRASH_UNSAFE_PRINTF(
-        "Could not get current directory: needed %ld bytes, got %ld\n", result,
-        MAX_PATH);
-  }
-
-  // Find destination directory, if any.
-  char destination[MAX_PATH];
-  result = GetEnvironmentVariable("CPP_UNIT_TESTS_DIR_JS_SRC", destination,
-                                  MAX_PATH);
-  if (result == 0) {
-    if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
-      return;  // No need to chdir
-    } else {
-      MOZ_CRASH("Could not get CPP_UNIT_TESTS_DIR_JS_SRC");
-    }
-  }
-  if (result > MAX_PATH) {
-    MOZ_CRASH_UNSAFE_PRINTF(
-        "Could not get CPP_UNIT_TESTS_DIR_JS_SRC: needed %ld bytes, got %ld\n",
-        result, MAX_PATH);
-  }
-
-  // Go to the directory.
-  if (SetCurrentDirectory(destination) == 0) {
-    MOZ_CRASH_UNSAFE_PRINTF("Could not chdir to %s", destination);
-  }
-}
-
-void exitJsDirectory() {
-  MOZ_ASSERT(strlen(gJsDirectory) > 0);
-  if (SetCurrentDirectory(gJsDirectory) == 0) {
-    MOZ_CRASH("Could not return to original directory");
-  }
-  gJsDirectory[0] = 0;
-}
-
-#endif  // defined(XP_UNIX) || defined(XP_WIN)
-
-// An dummy error reporter that does nothing, which is requred by
-// BinTokenReaderTester ctor.
-// These testcases don't test error case, so methods that is related to
-// error reporting crashes when called.
-class DummyErrorReporter : public js::frontend::ErrorReporter {
-  const JS::CompileOptions options_;
-
- public:
-  explicit DummyErrorReporter(JSContext* cx) : options_(cx) {}
-
-  virtual const JS::ReadOnlyCompileOptions& options() const override {
-    return options_;
-  }
-
-  virtual void lineAndColumnAt(size_t offset, uint32_t* line,
-                               uint32_t* column) const override {
-    *line = 0;
-    *column = 0;
-  }
-  virtual void currentLineAndColumn(uint32_t* line,
-                                    uint32_t* column) const override {
-    *line = 0;
-    *column = 0;
-  }
-  virtual bool isOnThisLine(size_t offset, uint32_t lineNum,
-                            bool* onThisLine) const override {
-    *onThisLine = true;
-    return true;
-  }
-  virtual uint32_t lineAt(size_t offset) const override { return 0; }
-  virtual uint32_t columnAt(size_t offset) const override { return 0; }
-
-  virtual bool hasTokenizationStarted() const override { return true; }
-  virtual void reportErrorNoOffsetVA(unsigned errorNumber,
-                                     va_list args) override {
-    MOZ_CRASH("shouldn't be used in test");
-  }
-  virtual const char* getFilename() const override { return "dummy filename"; }
-
-  virtual void errorAtVA(uint32_t offset, unsigned errorNumber,
-                         va_list* args) override {
-    MOZ_CRASH("shouldn't be used in test");
-  }
-  virtual bool reportExtraWarningErrorNumberVA(
-      js::UniquePtr<JSErrorNotes> notes, uint32_t offset, unsigned errorNumber,
-      va_list* args) override {
-    MOZ_CRASH("shouldn't be used in test");
-    return false;
-  }
-};
-
-void readFull(const char* path, js::Vector<uint8_t>& buf) {
-  enterJsDirectory();
-  buf.shrinkTo(0);
-  FILE* in = fopen(path, "rb");
-  if (!in) {
-    MOZ_CRASH_UNSAFE_PRINTF("Could not open %s: %s", path, strerror(errno));
-  }
-
-  struct stat info;
-  if (stat(path, &info) < 0) {
-    MOZ_CRASH_UNSAFE_PRINTF("Could not get stat on %s", path);
-  }
-
-  if (!buf.growBy(info.st_size)) {
-    MOZ_CRASH("OOM");
-  }
-
-  int result = fread(buf.begin(), 1, info.st_size, in);
-  if (fclose(in) != 0) {
-    MOZ_CRASH("Could not close input file");
-  }
-  if (result != info.st_size) {
-    MOZ_CRASH_UNSAFE_PRINTF(
-        "Read error while reading %s: expected %llu bytes, got %llu", path,
-        (unsigned long long)info.st_size, (unsigned long long)result);
-  }
-  exitJsDirectory();
-}
-
-// Reading a simple string.
-BEGIN_TEST(testBinTokenReaderTesterSimpleString) {
-  js::Vector<uint8_t> contents(cx);
-  readFull("jsapi-tests/binast/tokenizer/tester/test-simple-string.binjs",
-           contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  Chars found(cx);
-  CHECK(tokenizer.readChars(found).isOk());
-
-  CHECK(Tokenizer::equals(
-      found, "simple string"));  // FIXME: Find a way to make CHECK_EQUAL use
-                                 // `Tokenizer::equals`.
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterSimpleString)
-
-// Reading a string with embedded 0.
-BEGIN_TEST(testBinTokenReaderTesterStringWithEscapes) {
-  js::Vector<uint8_t> contents(cx);
-  readFull("jsapi-tests/binast/tokenizer/tester/test-string-with-escapes.binjs",
-           contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  Chars found(cx);
-  CHECK(tokenizer.readChars(found).isOk());
-
-  CHECK(Tokenizer::equals(
-      found,
-      "string with escapes \0\1\0"));  // FIXME: Find a way to make CHECK_EQUAL
-                                       // use `Tokenizer::equals`.
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterStringWithEscapes)
-
-// Reading an empty untagged tuple
-BEGIN_TEST(testBinTokenReaderTesterEmptyUntaggedTuple) {
-  js::Vector<uint8_t> contents(cx);
-  readFull(
-      "jsapi-tests/binast/tokenizer/tester/test-empty-untagged-tuple.binjs",
-      contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  {
-    Tokenizer::AutoTuple guard(tokenizer);
-    CHECK(tokenizer.enterUntaggedTuple(guard).isOk());
-    CHECK(guard.done().isOk());
-  }
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterEmptyUntaggedTuple)
-
-// Reading a untagged tuple with two strings
-BEGIN_TEST(testBinTokenReaderTesterTwoStringsInTuple) {
-  js::Vector<uint8_t> contents(cx);
-  readFull(
-      "jsapi-tests/binast/tokenizer/tester/test-trivial-untagged-tuple.binjs",
-      contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  {
-    Tokenizer::AutoTuple guard(tokenizer);
-    CHECK(tokenizer.enterUntaggedTuple(guard).isOk());
-
-    Chars found_0(cx);
-    CHECK(tokenizer.readChars(found_0).isOk());
-    CHECK(Tokenizer::equals(found_0,
-                            "foo"));  // FIXME: Find a way to make CHECK_EQUAL
-                                      // use `Tokenizer::equals`.
-
-    Chars found_1(cx);
-    CHECK(tokenizer.readChars(found_1).isOk());
-    CHECK(Tokenizer::equals(found_1,
-                            "bar"));  // FIXME: Find a way to make CHECK_EQUAL
-                                      // use `Tokenizer::equals`.
-
-    CHECK(guard.done().isOk());
-  }
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterTwoStringsInTuple)
-
-// Reading a tagged tuple `Pattern { id: "foo", value: 3.1415}`
-BEGIN_TEST(testBinTokenReaderTesterSimpleTaggedTuple) {
-  js::Vector<uint8_t> contents(cx);
-  readFull("jsapi-tests/binast/tokenizer/tester/test-simple-tagged-tuple.binjs",
-           contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  {
-    js::frontend::BinKind tag;
-    Tokenizer::BinFields fields(cx);
-    Tokenizer::AutoTaggedTuple guard(tokenizer);
-    CHECK(tokenizer.enterTaggedTuple(tag, fields, guard).isOk());
-
-    CHECK(tag == js::frontend::BinKind::BindingIdentifier);
-
-    Chars found_id(cx);
-    const double EXPECTED_value = 3.1415;
-
-    // Order of fields is deterministic.
-    CHECK(fields[0] == js::frontend::BinField::Label);
-    CHECK(fields[1] == js::frontend::BinField::Value);
-    CHECK(tokenizer.readChars(found_id).isOk());
-    double found_value = tokenizer.readDouble().unwrap();
-
-    CHECK(EXPECTED_value ==
-          found_value);  // Apparently, CHECK_EQUAL doesn't work on `double`.
-    CHECK(Tokenizer::equals(found_id, "foo"));
-    CHECK(guard.done().isOk());
-  }
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterSimpleTaggedTuple)
-
-// Reading an empty list
-BEGIN_TEST(testBinTokenReaderTesterEmptyList) {
-  js::Vector<uint8_t> contents(cx);
-  readFull("jsapi-tests/binast/tokenizer/tester/test-empty-list.binjs",
-           contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  {
-    uint32_t length;
-    Tokenizer::AutoList guard(tokenizer);
-    CHECK(tokenizer.enterList(length, guard).isOk());
-
-    CHECK(length == 0);
-    CHECK(guard.done().isOk());
-  }
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterEmptyList)
-
-// Reading `["foo", "bar"]`
-BEGIN_TEST(testBinTokenReaderTesterSimpleList) {
-  js::Vector<uint8_t> contents(cx);
-  readFull("jsapi-tests/binast/tokenizer/tester/test-trivial-list.binjs",
-           contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  {
-    uint32_t length;
-    Tokenizer::AutoList guard(tokenizer);
-    CHECK(tokenizer.enterList(length, guard).isOk());
-
-    CHECK(length == 2);
-
-    Chars found_0(cx);
-    CHECK(tokenizer.readChars(found_0).isOk());
-    CHECK(Tokenizer::equals(found_0, "foo"));
-
-    Chars found_1(cx);
-    CHECK(tokenizer.readChars(found_1).isOk());
-    CHECK(Tokenizer::equals(found_1, "bar"));
-
-    CHECK(guard.done().isOk());
-  }
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterSimpleList)
-
-// Reading `[["foo", "bar"]]`
-BEGIN_TEST(testBinTokenReaderTesterNestedList) {
-  js::Vector<uint8_t> contents(cx);
-  readFull("jsapi-tests/binast/tokenizer/tester/test-nested-lists.binjs",
-           contents);
-  DummyErrorReporter reporter(cx);
-  Tokenizer tokenizer(cx, &reporter, contents);
-
-  {
-    uint32_t outerLength;
-    Tokenizer::AutoList outerGuard(tokenizer);
-    CHECK(tokenizer.enterList(outerLength, outerGuard).isOk());
-    CHECK_EQUAL(outerLength, (uint32_t)1);
-
-    {
-      uint32_t innerLength;
-      Tokenizer::AutoList innerGuard(tokenizer);
-      CHECK(tokenizer.enterList(innerLength, innerGuard).isOk());
-      CHECK_EQUAL(innerLength, (uint32_t)2);
-
-      Chars found_0(cx);
-      CHECK(tokenizer.readChars(found_0).isOk());
-      CHECK(Tokenizer::equals(found_0, "foo"));
-
-      Chars found_1(cx);
-      CHECK(tokenizer.readChars(found_1).isOk());
-      CHECK(Tokenizer::equals(found_1, "bar"));
-
-      CHECK(innerGuard.done().isOk());
-    }
-
-    CHECK(outerGuard.done().isOk());
-  }
-
-  return true;
-}
-END_TEST(testBinTokenReaderTesterNestedList)
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -4923,55 +4923,46 @@ static bool BinParse(JSContext* cx, unsi
   bool buf_isSharedMemory = false;
   uint8_t* buf_data = nullptr;
   GetArrayBufferLengthAndData(objBuf, &buf_length, &buf_isSharedMemory,
                               &buf_data);
   MOZ_ASSERT(buf_data);
 
   // Extract argument 2: Options.
 
-  bool useMultipart = true;
-
   if (args.length() >= 2) {
     if (!args[1].isObject()) {
       const char* typeName = InformalValueTypeName(args[1]);
       JS_ReportErrorASCII(cx, "expected object (options) to parse, got %s",
                           typeName);
       return false;
     }
     RootedObject objOptions(cx, &args[1].toObject());
 
     RootedValue optionFormat(cx);
     if (!JS_GetProperty(cx, objOptions, "format", &optionFormat)) {
       return false;
     }
 
-    if (optionFormat.isUndefined()) {
-      // By default, `useMultipart` is `true`.
-      useMultipart = true;
-    } else if (optionFormat.isString()) {
+    if (!optionFormat.isUndefined()) {
       RootedLinearString linearFormat(
           cx, optionFormat.toString()->ensureLinear(cx));
       if (!linearFormat) {
         return false;
       }
-      if (StringEqualsAscii(linearFormat, "multipart")) {
-        useMultipart = true;
-      } else if (StringEqualsAscii(linearFormat, "simple")) {
-        useMultipart = false;
-      } else {
+      // Currently not used, reserved for future.
+      if (!StringEqualsAscii(linearFormat, "multipart")) {
         UniqueChars printable = JS_EncodeStringToUTF8(cx, linearFormat);
         if (!printable) {
           return false;
         }
 
         JS_ReportErrorUTF8(
             cx,
-            "Unknown value for option `format`, expected 'multipart' or "
-            "'simple', got %s",
+            "Unknown value for option `format`, expected 'multipart', got %s",
             printable.get());
         return false;
       }
     } else {
       const char* typeName = InformalValueTypeName(optionFormat);
       JS_ReportErrorASCII(cx, "option `format` should be a string, got %s",
                           typeName);
       return false;
@@ -4988,19 +4979,17 @@ static bool BinParse(JSContext* cx, unsi
       cx, frontend::CreateScriptSourceObject(cx, options, Nothing()));
   if (!sourceObj) {
     return false;
   }
 
   Directives directives(false);
   GlobalSharedContext globalsc(cx, ScopeKind::Global, directives, false);
 
-  auto parseFunc = useMultipart
-                       ? ParseBinASTData<frontend::BinTokenReaderMultipart>
-                       : ParseBinASTData<frontend::BinTokenReaderTester>;
+  auto parseFunc = ParseBinASTData<frontend::BinTokenReaderMultipart>;
   if (!parseFunc(cx, buf_data, buf_length, &globalsc, usedNames, options,
                  sourceObj)) {
     return false;
   }
 
   args.rval().setUndefined();
   return true;
 }