Bug 1486577 - Make all users of the various *CompileOptions classes #include "js/CompileOptions.h" so that nothing but that file has to know about these classes having a JS_PUBLIC_API on them, that would have to be present in forward-declarations. r=jandem
authorJeff Walden <jwalden@mit.edu>
Fri, 24 Aug 2018 21:25:15 -0500
changeset 433718 1fb7ddfad86d5e085c4f2af23a2519d37e45a3e4
parent 433717 2dc7007e3924444f55345606b6785f2d2ba89ce1
child 433719 48921866b394212e0dddd0ba72c183081bc6805f
push id34521
push userebalazs@mozilla.com
push dateWed, 29 Aug 2018 09:43:53 +0000
treeherdermozilla-central@b75561ff5ffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1486577
milestone63.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 1486577 - Make all users of the various *CompileOptions classes #include "js/CompileOptions.h" so that nothing but that file has to know about these classes having a JS_PUBLIC_API on them, that would have to be present in forward-declarations. r=jandem
js/public/CompileOptions.h
js/src/NamespaceImports.h
js/src/builtin/Eval.cpp
js/src/builtin/ReflectParse.cpp
js/src/builtin/RegExp.cpp
js/src/builtin/TestingFunctions.cpp
js/src/frontend/BinSource.h
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/BytecodeCompiler.h
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
js/src/frontend/TokenStream.cpp
js/src/frontend/TokenStream.h
js/src/fuzz-tests/testBinASTReader.cpp
js/src/gdb/tests/test-unwind.cpp
js/src/jsapi-tests/testCloneScript.cpp
js/src/jsapi.cpp
js/src/jspubtd.h
js/src/shell/js.cpp
js/src/vm/Debugger.cpp
js/src/vm/HelperThreads.cpp
js/src/vm/HelperThreads.h
js/src/vm/JSFunction.cpp
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
js/src/vm/RegExpObject.cpp
js/src/vm/SelfHosting.cpp
js/src/vm/Xdr.h
js/src/wasm/AsmJS.cpp
--- a/js/public/CompileOptions.h
+++ b/js/public/CompileOptions.h
@@ -147,16 +147,18 @@ class JS_PUBLIC_API(TransitiveCompileOpt
     virtual JSObject* element() const = 0;
     virtual JSString* elementAttributeName() const = 0;
     virtual JSScript* introductionScript() const = 0;
 
   private:
     void operator=(const TransitiveCompileOptions&) = delete;
 };
 
+class JS_PUBLIC_API(CompileOptions);
+
 /**
  * The class representing a full set of compile options.
  *
  * Use this in code that only needs to access compilation options created
  * elsewhere, like the compiler.  Don't instantiate this class (the constructor
  * is protected anyway); instead, create instances only of the derived classes:
  * CompileOptions and OwningCompileOptions.
  */
--- a/js/src/NamespaceImports.h
+++ b/js/src/NamespaceImports.h
@@ -95,22 +95,18 @@ using JS::IdVector;
 using JS::ScriptVector;
 
 using JS::GCVector;
 using JS::GCHashMap;
 using JS::GCHashSet;
 
 using JS::CallArgs;
 using JS::CallNonGenericMethod;
-using JS::CompileOptions;
 using JS::IsAcceptableThis;
 using JS::NativeImpl;
-using JS::OwningCompileOptions;
-using JS::ReadOnlyCompileOptions;
-using JS::TransitiveCompileOptions;
 
 using JS::Rooted;
 using JS::RootedFunction;
 using JS::RootedId;
 using JS::RootedObject;
 using JS::RootedScript;
 using JS::RootedString;
 using JS::RootedSymbol;
--- a/js/src/builtin/Eval.cpp
+++ b/js/src/builtin/Eval.cpp
@@ -23,16 +23,17 @@
 using namespace js;
 
 using mozilla::AddToHash;
 using mozilla::HashString;
 using mozilla::RangedPtr;
 
 using JS::AutoCheckCannotGC;
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
 using JS::SourceBufferHolder;
 
 // We should be able to assert this for *any* fp->environmentChain().
 static void
 AssertInnerizedEnvironmentChain(JSContext* cx, JSObject& env)
 {
 #ifdef DEBUG
     RootedObject obj(cx);
--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -27,16 +27,17 @@
 #include "frontend/ParseNode-inl.h"
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 using namespace js::frontend;
 
 using JS::AutoStableStringChars;
 using JS::AutoValueArray;
+using JS::CompileOptions;
 using mozilla::DebugOnly;
 
 enum ASTType {
     AST_ERROR = -1,
 #define ASTDEF(ast, str, method) ast,
 #include "jsast.tbl"
 #undef ASTDEF
     AST_LIMIT
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -22,16 +22,18 @@
 #include "vm/NativeObject-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 
 using mozilla::CheckedInt;
 using mozilla::IsAsciiDigit;
 
+using JS::CompileOptions;
+
 /*
  * ES 2017 draft rev 6a13789aa9e7c6de4e96b7d3e24d9e6eba6584ad 21.2.5.2.2
  * steps 3, 16-25.
  */
 bool
 js::CreateRegExpMatchResult(JSContext* cx, HandleString input, const MatchPairs& matches,
                             MutableHandleValue rval)
 {
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -37,16 +37,17 @@
 #include "irregexp/RegExpEngine.h"
 #include "irregexp/RegExpParser.h"
 #endif
 #include "gc/Heap.h"
 #include "jit/BaselineJIT.h"
 #include "jit/InlinableNatives.h"
 #include "jit/JitRealm.h"
 #include "js/AutoByteString.h"
+#include "js/CompileOptions.h"
 #include "js/Debug.h"
 #include "js/HashTable.h"
 #include "js/LocaleSensitive.h"
 #include "js/SourceBufferHolder.h"
 #include "js/StableStringChars.h"
 #include "js/StructuredClone.h"
 #include "js/UbiNode.h"
 #include "js/UbiNodeBreadthFirst.h"
@@ -85,16 +86,17 @@
 #include "vm/StringType-inl.h"
 
 using namespace js;
 
 using mozilla::ArrayLength;
 using mozilla::Maybe;
 
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
 using JS::SourceBufferHolder;
 
 // If fuzzingSafe is set, remove functionality that could cause problems with
 // fuzzers. Set this via the environment variable MOZ_FUZZING_SAFE.
 mozilla::Atomic<bool> fuzzingSafe(false);
 
 // If disableOOMFunctions is set, disable functionality that causes artificial
 // OOM conditions.
--- a/js/src/frontend/BinSource.h
+++ b/js/src/frontend/BinSource.h
@@ -20,16 +20,17 @@
 #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"
 #include "js/Result.h"
 
 namespace js {
 namespace frontend {
 
 class BinASTParserBase: private JS::AutoGCRooter
@@ -182,19 +183,19 @@ class BinASTParser : public BinASTParser
     MOZ_MUST_USE JS::Result<Ok> checkFunctionClosedVars();
 
     // --- Utilities.
 
     MOZ_MUST_USE JS::Result<ParseNode*> appendDirectivesToBody(ParseNode* body,
         ParseNode* directives);
 
   private: // Implement ErrorReporter
-    const ReadOnlyCompileOptions& options_;
+    const JS::ReadOnlyCompileOptions& options_;
 
-    const ReadOnlyCompileOptions& options() const override {
+    const JS::ReadOnlyCompileOptions& options() const override {
         return this->options_;
     }
 
   public:
     virtual ObjectBox* newObjectBox(JSObject* obj) override {
         MOZ_ASSERT(obj);
 
         /*
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -30,16 +30,18 @@
 #include "vm/JSScript-inl.h"
 
 using namespace js;
 using namespace js::frontend;
 
 using mozilla::Maybe;
 using mozilla::Nothing;
 
+using JS::CompileOptions;
+using JS::ReadOnlyCompileOptions;
 using JS::SourceBufferHolder;
 
 // The BytecodeCompiler class contains resources common to compiling scripts and
 // function bodies.
 class MOZ_STACK_CLASS BytecodeCompiler
 {
   public:
     // Construct an object passing mandatory arguments.
@@ -707,17 +709,17 @@ frontend::CompileModule(JSContext* cx, c
     if (!script)
         return nullptr;
 
     assertException.reset();
     return script;
 }
 
 JSScript*
-frontend::CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options,
+frontend::CompileModule(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                         SourceBufferHolder& srcBuf)
 {
     AutoAssertReportedException assertException(cx);
 
     if (!GlobalObject::ensureModulePrototypesCreated(cx, cx->global()))
         return nullptr;
 
     LifoAlloc& alloc = cx->tempLifoAlloc();
@@ -785,17 +787,17 @@ frontend::CompileLazyFunction(JSContext*
     // compiled, because compilation requires full information about the
     // function's immediately enclosing scope.
     MOZ_ASSERT(lazy->enclosingScriptHasEverBeenCompiled());
 
     AutoAssertReportedException assertException(cx);
     Rooted<JSFunction*> fun(cx, lazy->functionNonDelazifying());
     AutoAssertFunctionDelazificationCompletion delazificationCompletion(cx, fun);
 
-    CompileOptions options(cx);
+    JS::CompileOptions options(cx);
     options.setMutedErrors(lazy->mutedErrors())
            .setFileAndLine(lazy->filename(), lazy->lineno())
            .setColumn(lazy->column())
            .setScriptSourceOffset(lazy->sourceStart())
            .setNoScriptRval(false)
            .setSelfHostingMode(false);
 
     // Update statistics to find out if we are delazifying just after having
@@ -852,17 +854,17 @@ frontend::CompileLazyFunction(JSContext*
 
     delazificationCompletion.complete();
     assertException.reset();
     return true;
 }
 
 bool
 frontend::CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
-                                    const ReadOnlyCompileOptions& options,
+                                    const JS::ReadOnlyCompileOptions& options,
                                     JS::SourceBufferHolder& srcBuf,
                                     const Maybe<uint32_t>& parameterListEnd,
                                     HandleScope enclosingScope /* = nullptr */)
 {
     AutoAssertReportedException assertException(cx);
 
     RootedScope scope(cx, enclosingScope);
     if (!scope)
@@ -877,17 +879,17 @@ frontend::CompileStandaloneFunction(JSCo
     }
 
     assertException.reset();
     return true;
 }
 
 bool
 frontend::CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
-                                     const ReadOnlyCompileOptions& options,
+                                     const JS::ReadOnlyCompileOptions& options,
                                      JS::SourceBufferHolder& srcBuf,
                                      const Maybe<uint32_t>& parameterListEnd)
 {
     AutoAssertReportedException assertException(cx);
 
     RootedScope emptyGlobalScope(cx, &cx->global()->emptyGlobalScope());
 
     BytecodeCompiler compiler(cx, cx->tempLifoAlloc(), options, srcBuf, emptyGlobalScope);
--- a/js/src/frontend/BytecodeCompiler.h
+++ b/js/src/frontend/BytecodeCompiler.h
@@ -6,16 +6,17 @@
 
 #ifndef frontend_BytecodeCompiler_h
 #define frontend_BytecodeCompiler_h
 
 #include "mozilla/Maybe.h"
 
 #include "NamespaceImports.h"
 
+#include "js/CompileOptions.h"
 #include "vm/Scope.h"
 #include "vm/StringType.h"
 #include "vm/TraceLogging.h"
 
 class JSLinearString;
 
 namespace js {
 
@@ -26,43 +27,43 @@ class ScriptSourceObject;
 namespace frontend {
 
 class ErrorReporter;
 class FunctionBox;
 class ParseNode;
 
 JSScript*
 CompileGlobalScript(JSContext* cx, LifoAlloc& alloc, ScopeKind scopeKind,
-                    const ReadOnlyCompileOptions& options,
+                    const JS::ReadOnlyCompileOptions& options,
                     JS::SourceBufferHolder& srcBuf,
                     ScriptSourceObject** sourceObjectOut = nullptr);
 
 #if defined(JS_BUILD_BINAST)
 
 JSScript*
 CompileGlobalBinASTScript(JSContext *cx, LifoAlloc& alloc,
-                          const ReadOnlyCompileOptions& options,
+                          const JS::ReadOnlyCompileOptions& options,
                           const uint8_t* src, size_t len,
                           ScriptSourceObject** sourceObjectOut = nullptr);
 
 #endif // JS_BUILD_BINAST
 
 JSScript*
 CompileEvalScript(JSContext* cx, LifoAlloc& alloc,
                   HandleObject scopeChain, HandleScope enclosingScope,
-                  const ReadOnlyCompileOptions& options,
+                  const JS::ReadOnlyCompileOptions& options,
                   JS::SourceBufferHolder& srcBuf,
                   ScriptSourceObject** sourceObjectOut = nullptr);
 
 JSScript*
-CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options,
+CompileModule(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
               JS::SourceBufferHolder& srcBuf);
 
 JSScript*
-CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options,
+CompileModule(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
               JS::SourceBufferHolder& srcBuf, LifoAlloc& alloc,
               ScriptSourceObject** sourceObjectOut = nullptr);
 
 MOZ_MUST_USE bool
 CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* chars, size_t length);
 
 //
 // Compile a single function. The source in srcBuf must match the ECMA-262
@@ -73,41 +74,41 @@ CompileLazyFunction(JSContext* cx, Handl
 // else, it's a SyntaxError. This is used to implement the Function constructor;
 // it's how we detect that these weird cases are SyntaxErrors:
 //
 //     Function("/*", "*/x) {")
 //     Function("x){ if (3", "return x;}")
 //
 MOZ_MUST_USE bool
 CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
-                          const ReadOnlyCompileOptions& options,
+                          const JS::ReadOnlyCompileOptions& options,
                           JS::SourceBufferHolder& srcBuf,
                           const mozilla::Maybe<uint32_t>& parameterListEnd,
                           HandleScope enclosingScope = nullptr);
 
 MOZ_MUST_USE bool
 CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
-                           const ReadOnlyCompileOptions& options,
+                           const JS::ReadOnlyCompileOptions& options,
                            JS::SourceBufferHolder& srcBuf,
                            const mozilla::Maybe<uint32_t>& parameterListEnd);
 
 MOZ_MUST_USE bool
 CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fun,
-                               const ReadOnlyCompileOptions& options,
+                               const JS::ReadOnlyCompileOptions& options,
                                JS::SourceBufferHolder& srcBuf,
                                const mozilla::Maybe<uint32_t>& parameterListEnd);
 
 MOZ_MUST_USE bool
 CompileStandaloneAsyncGenerator(JSContext* cx, MutableHandleFunction fun,
-                                const ReadOnlyCompileOptions& options,
+                                const JS::ReadOnlyCompileOptions& options,
                                 JS::SourceBufferHolder& srcBuf,
                                 const mozilla::Maybe<uint32_t>& parameterListEnd);
 
 ScriptSourceObject*
-CreateScriptSourceObject(JSContext* cx, const ReadOnlyCompileOptions& options,
+CreateScriptSourceObject(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                          const mozilla::Maybe<uint32_t>& parameterListEnd = mozilla::Nothing());
 
 /*
  * True if str consists of an IdentifierStart character, followed by one or
  * more IdentifierPart characters, i.e. it matches the IdentifierName production
  * in the language spec.
  *
  * This returns true even if str is a keyword like "if".
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -32,16 +32,17 @@
 #include "frontend/ForOfEmitter.h"
 #include "frontend/ForOfLoopControl.h"
 #include "frontend/IfEmitter.h"
 #include "frontend/Parser.h"
 #include "frontend/SwitchEmitter.h"
 #include "frontend/TDZCheckCache.h"
 #include "frontend/TryEmitter.h"
 #include "frontend/WhileEmitter.h"
+#include "js/CompileOptions.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/Debugger.h"
 #include "vm/GeneratorObject.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSScript.h"
 #include "vm/Stack.h"
@@ -5108,18 +5109,18 @@ BytecodeEmitter::emitFunction(ParseNode*
                 fun->lazyScript()->setTreatAsRunOnce();
         } else {
             MOZ_ASSERT_IF(outersc->strict(), funbox->strictScript);
 
             // Inherit most things (principals, version, etc) from the
             // parent.  Use default values for the rest.
             Rooted<JSScript*> parent(cx, script);
             MOZ_ASSERT(parent->mutedErrors() == parser->options().mutedErrors());
-            const TransitiveCompileOptions& transitiveOptions = parser->options();
-            CompileOptions options(cx, transitiveOptions);
+            const JS::TransitiveCompileOptions& transitiveOptions = parser->options();
+            JS::CompileOptions options(cx, transitiveOptions);
 
             Rooted<JSObject*> sourceObject(cx, script->sourceObject());
             Rooted<JSScript*> script(cx, JSScript::Create(cx, options, sourceObject,
                                                           funbox->bufStart, funbox->bufEnd,
                                                           funbox->toStringStart,
                                                           funbox->toStringEnd));
             if (!script)
                 return false;
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -60,16 +60,17 @@ using mozilla::Maybe;
 using mozilla::Nothing;
 using mozilla::PodCopy;
 using mozilla::PodZero;
 using mozilla::Some;
 using mozilla::Unused;
 using mozilla::Utf8Unit;
 
 using JS::AutoGCRooter;
+using JS::ReadOnlyCompileOptions;
 
 namespace js {
 namespace frontend {
 
 using DeclaredNamePtr = ParseContext::Scope::DeclaredNamePtr;
 using AddDeclaredNamePtr = ParseContext::Scope::AddDeclaredNamePtr;
 using BindingIter = ParseContext::Scope::BindingIter;
 using UsedNamePtr = UsedNameTracker::UsedNameMap::Ptr;
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -176,16 +176,17 @@
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/NameAnalysisTypes.h"
 #include "frontend/NameCollections.h"
 #include "frontend/ParseContext.h"
 #include "frontend/SharedContext.h"
 #include "frontend/SyntaxParseHandler.h"
 #include "frontend/TokenStream.h"
+#include "js/CompileOptions.h"
 #include "vm/Iteration.h"
 
 namespace js {
 
 class ModuleObject;
 
 namespace frontend {
 
@@ -315,17 +316,17 @@ class MOZ_STACK_CLASS ParserBase
 
     ParseGoal parseGoal() const {
         return ParseGoal(parseGoal_);
     }
 
     template<class, typename> friend class AutoAwaitIsKeyword;
     template<class, typename> friend class AutoInParametersOfAsyncFunction;
 
-    ParserBase(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
+    ParserBase(JSContext* cx, LifoAlloc& alloc, const JS::ReadOnlyCompileOptions& options,
                bool foldConstants, UsedNameTracker& usedNames,
                ScriptSourceObject* sourceObject, ParseGoal parseGoal);
     ~ParserBase();
 
     bool checkOptions();
 
     void trace(JSTracer* trc);
 
@@ -338,17 +339,17 @@ class MOZ_STACK_CLASS ParserBase
     }
 
     virtual bool strictMode() override { return pc->sc()->strict(); }
     bool setLocalStrictMode(bool strict) {
         MOZ_ASSERT(anyChars.debugHasNoLookahead());
         return pc->sc()->setLocalStrictMode(strict);
     }
 
-    const ReadOnlyCompileOptions& options() const {
+    const JS::ReadOnlyCompileOptions& options() const {
         return anyChars.options();
     }
 
     bool isUnexpectedEOF() const { return isUnexpectedEOF_; }
 
     MOZ_MUST_USE bool warningNoOffset(unsigned errorNumber, ...);
     void errorNoOffset(unsigned errorNumber, ...);
 
@@ -480,24 +481,24 @@ class MOZ_STACK_CLASS PerHandlerParser
     // template class doesn't know |CharT|, so we store a |void*| here and make
     // |GeneralParser<ParseHandler, CharT>::getSyntaxParser| impose the real type.
     void* internalSyntaxParser_;
 
   private:
     // NOTE: The argument ordering here is deliberately different from the
     //       public constructor so that typos calling the public constructor
     //       are less likely to select this overload.
-    PerHandlerParser(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
+    PerHandlerParser(JSContext* cx, LifoAlloc& alloc, const JS::ReadOnlyCompileOptions& options,
                      bool foldConstants, UsedNameTracker& usedNames, LazyScript* lazyOuterFunction,
                      ScriptSourceObject* sourceObject, ParseGoal parseGoal,
                      void* internalSyntaxParser);
 
   protected:
     template<typename CharT>
-    PerHandlerParser(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
+    PerHandlerParser(JSContext* cx, LifoAlloc& alloc, const JS::ReadOnlyCompileOptions& options,
                      bool foldConstants, UsedNameTracker& usedNames,
                      GeneralParser<SyntaxParseHandler, CharT>* syntaxParser,
                      LazyScript* lazyOuterFunction, ScriptSourceObject* sourceObject,
                      ParseGoal parseGoal)
       : PerHandlerParser(cx, alloc, options, foldConstants, usedNames, lazyOuterFunction,
                          sourceObject, parseGoal,
                          // JSOPTION_EXTRA_WARNINGS adds extra warnings not
                          // generated when functions are parsed lazily.
@@ -894,17 +895,17 @@ class MOZ_STACK_CLASS GeneralParser
     SyntaxParser* getSyntaxParser() const {
         return reinterpret_cast<SyntaxParser*>(Base::internalSyntaxParser_);
     }
 
   public:
     TokenStream tokenStream;
 
   public:
-    GeneralParser(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
+    GeneralParser(JSContext* cx, LifoAlloc& alloc, const JS::ReadOnlyCompileOptions& options,
                   const CharT* chars, size_t length, bool foldConstants,
                   UsedNameTracker& usedNames, SyntaxParser* syntaxParser,
                   LazyScript* lazyOuterFunction,
                   ScriptSourceObject* sourceObject,
                   ParseGoal parseGoal);
 
     inline void setAwaitHandling(AwaitHandling awaitHandling);
     inline void setInParametersOfAsyncFunction(bool inParameters);
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -50,16 +50,18 @@ using mozilla::IsAsciiAlpha;
 using mozilla::IsAsciiDigit;
 using mozilla::IsTrailingUnit;
 using mozilla::MakeScopeExit;
 using mozilla::MakeSpan;
 using mozilla::Maybe;
 using mozilla::PointerRangeSize;
 using mozilla::Utf8Unit;
 
+using JS::ReadOnlyCompileOptions;
+
 struct ReservedWordInfo
 {
     const char* chars;         // C string with reserved word text
     js::frontend::TokenKind tokentype;
 };
 
 static const ReservedWordInfo reservedWords[] = {
 #define RESERVED_WORD_INFO(word, name, type) \
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -199,16 +199,17 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 
 #include "jspubtd.h"
 
 #include "frontend/ErrorReporter.h"
 #include "frontend/TokenKind.h"
+#include "js/CompileOptions.h"
 #include "js/UniquePtr.h"
 #include "js/Vector.h"
 #include "util/Text.h"
 #include "util/Unicode.h"
 #include "vm/ErrorReporting.h"
 #include "vm/JSContext.h"
 #include "vm/RegExpShared.h"
 #include "vm/StringType.h"
@@ -588,17 +589,17 @@ class MOZ_STACK_CLASS TokenStreamPositio
     unsigned lookahead;
     Token lookaheadTokens[TokenStreamShared::maxLookahead];
 } JS_HAZ_ROOTED;
 
 class TokenStreamAnyChars
   : public TokenStreamShared
 {
   public:
-    TokenStreamAnyChars(JSContext* cx, const ReadOnlyCompileOptions& options,
+    TokenStreamAnyChars(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                         StrictModeGetter* smg);
 
     template<typename CharT, class AnyCharsAccess> friend class GeneralTokenStreamChars;
     template<typename CharT, class AnyCharsAccess> friend class TokenStreamChars;
     template<typename CharT, class AnyCharsAccess> friend class TokenStreamSpecific;
 
     template<typename CharT> friend class TokenStreamPosition;
 
@@ -889,17 +890,17 @@ class TokenStreamAnyChars
     }
 
     const char* getFilename() const {
         return filename_;
     }
 
   protected:
     // Options used for parsing/tokenizing.
-    const ReadOnlyCompileOptions& options_;
+    const JS::ReadOnlyCompileOptions& options_;
 
     Token               tokens[ntokens];    // circular token buffer
   private:
     unsigned            cursor_;            // index of last parsed token
   protected:
     unsigned            lookahead;          // count of lookahead tokens
     unsigned            lineno;             // current line number
     TokenStreamFlags    flags;              // flags -- see above
@@ -2317,17 +2318,17 @@ class MOZ_STACK_CLASS TokenStreamSpecifi
     // Deliberately don't |using| |sourceUnits| because of bug 1472569.  :-(
     using CharsBase::toCharT;
     using GeneralCharsBase::ungetCodeUnit;
     using GeneralCharsBase::updateLineInfoForEOL;
 
     template<typename CharU> friend class TokenStreamPosition;
 
   public:
-    TokenStreamSpecific(JSContext* cx, const ReadOnlyCompileOptions& options,
+    TokenStreamSpecific(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                         const CharT* base, size_t length);
 
     /**
      * Get the next code point, converting LineTerminatorSequences to '\n' and
      * updating internal line-counter state if needed.  Return true on success
      * and store the code point in |*cp|.  Return false and leave |*cp|
      * undefined on failure.
      */
@@ -2690,17 +2691,17 @@ class TokenStreamAnyCharsAccess
 
 class MOZ_STACK_CLASS TokenStream final
   : public TokenStreamAnyChars,
     public TokenStreamSpecific<char16_t, TokenStreamAnyCharsAccess>
 {
     using CharT = char16_t;
 
   public:
-    TokenStream(JSContext* cx, const ReadOnlyCompileOptions& options,
+    TokenStream(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                 const CharT* base, size_t length, StrictModeGetter* smg)
     : TokenStreamAnyChars(cx, options, smg),
       TokenStreamSpecific<CharT, TokenStreamAnyCharsAccess>(cx, options, base, length)
     {}
 };
 
 template<class TokenStreamSpecific>
 /* static */ inline TokenStreamAnyChars&
--- a/js/src/fuzz-tests/testBinASTReader.cpp
+++ b/js/src/fuzz-tests/testBinASTReader.cpp
@@ -10,23 +10,26 @@
 
 #include "jsapi.h"
 
 #include "frontend/BinSource.h"
 #include "frontend/FullParseHandler.h"
 #include "frontend/ParseContext.h"
 #include "frontend/Parser.h"
 #include "fuzz-tests/tests.h"
+#include "js/CompileOptions.h"
 #include "vm/Interpreter.h"
 
 #include "vm/JSContext-inl.h"
 
 using UsedNameTracker = js::frontend::UsedNameTracker;
 using namespace js;
 
+using JS::CompileOptions;
+
 // These are defined and pre-initialized by the harness (in tests.cpp).
 extern JS::PersistentRootedObject gGlobal;
 extern JSContext* gCx;
 
 static int
 testBinASTReaderInit(int *argc, char ***argv) {
   return 0;
 }
--- a/js/src/gdb/tests/test-unwind.cpp
+++ b/js/src/gdb/tests/test-unwind.cpp
@@ -1,18 +1,24 @@
 #include "gdb-tests.h"
-#include "jsapi.h"
-#include "jit/JitOptions.h"
+#include "jsapi.h" // sundry symbols not moved to more-specific headers yet
 
-#include <string.h>
+#include "jit/JitOptions.h" // js::jit::JitOptions
+#include "js/CallArgs.h" // JS::CallArgs, JS::CallArgsFromVp
+#include "js/CompileOptions.h" // JS::CompileOptions
+#include "js/RootingAPI.h" // JS::Rooted
+#include "js/Value.h" // JS::Value
+
+#include <stdint.h> // uint32_t
+#include <string.h> // strlen
 
 static bool
 Something(JSContext* cx, unsigned argc, JS::Value* vp)
 {
-    JS::CallArgs args = CallArgsFromVp(argc, vp);
+    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     args.rval().setInt32(23);
     breakpoint();
     return true;
 }
 
 static const JSFunctionSpecWithHelp unwind_functions[] = {
     JS_FN_HELP("something", Something, 0, 0,
 "something()",
@@ -38,15 +44,15 @@ FRAGMENT(unwind, simple) {
         "}\n"
         "\n"
         "function unwindFunctionOuter() {\n"
         "    return unwindFunctionInner();\n"
         "}\n"
         "\n"
         "unwindFunctionOuter();\n";
 
-    CompileOptions opts(cx);
+    JS::CompileOptions opts(cx);
     opts.setFileAndLine(__FILE__, line0 + 1);
-    RootedValue rval(cx);
-    Evaluate(cx, opts, bytes, strlen(bytes), &rval);
+    JS::Rooted<JS::Value> rval(cx);
+    JS::Evaluate(cx, opts, bytes, strlen(bytes), &rval);
 
     js::jit::JitOptions.baselineWarmUpThreshold = saveThreshold;
 }
--- a/js/src/jsapi-tests/testCloneScript.cpp
+++ b/js/src/jsapi-tests/testCloneScript.cpp
@@ -2,17 +2,25 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  *
  * Test script cloning.
  */
 /* 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> // strlen
+
+#include "jsapi.h" // sundry symbols not moved to more-specific headers yet
 #include "jsfriendapi.h"
+#include "jspubtd.h" // JS::AutoObjectVector
+
+#include "js/CompileOptions.h" // JS::CompileOptions
+#include "js/RootingAPI.h" // JS::Rooted
+#include "js/TypeDecls.h" // JSFunction, JSObject
 #include "jsapi-tests/tests.h"
 
 BEGIN_TEST(test_cloneScript)
 {
     JS::RootedObject A(cx, createGlobal());
     JS::RootedObject B(cx, createGlobal());
 
     CHECK(A);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -52,16 +52,17 @@
 #include "gc/Marking.h"
 #include "gc/Policy.h"
 #include "gc/PublicIterators.h"
 #include "gc/WeakMap.h"
 #include "jit/JitCommon.h"
 #include "jit/JitSpewer.h"
 #include "js/AutoByteString.h"
 #include "js/CharacterEncoding.h"
+#include "js/CompileOptions.h"
 #include "js/Conversions.h"
 #include "js/Date.h"
 #include "js/Initialization.h"
 #include "js/JSON.h"
 #include "js/LocaleSensitive.h"
 #include "js/Proxy.h"
 #include "js/SliceBudget.h"
 #include "js/SourceBufferHolder.h"
@@ -109,16 +110,18 @@
 using namespace js;
 using namespace js::gc;
 
 using mozilla::Maybe;
 using mozilla::PodCopy;
 using mozilla::Some;
 
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
+using JS::ReadOnlyCompileOptions;
 using JS::SourceBufferHolder;
 
 #ifdef HAVE_VA_LIST_AS_ARRAY
 #define JS_ADDRESSOF_VA_LIST(ap) ((va_list*)(ap))
 #else
 #define JS_ADDRESSOF_VA_LIST(ap) (&(ap))
 #endif
 
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -26,20 +26,16 @@ namespace JS {
 
 template <typename T> class AutoVector;
 using AutoIdVector = AutoVector<jsid>;
 using AutoValueVector = AutoVector<Value>;
 using AutoObjectVector = AutoVector<JSObject*>;
 
 class CallArgs;
 
-class JS_PUBLIC_API(CompileOptions);
-class JS_PUBLIC_API(ReadOnlyCompileOptions);
-class JS_PUBLIC_API(OwningCompileOptions);
-class JS_PUBLIC_API(TransitiveCompileOptions);
 class JS_PUBLIC_API(RealmOptions);
 
 } // namespace JS
 
 /* Result of typeof operator enumeration. */
 enum JSType {
     JSTYPE_UNDEFINED,           /* undefined */
     JSTYPE_OBJECT,              /* object */
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -74,16 +74,17 @@
 #include "gc/Zone.h"
 #include "jit/arm/Simulator-arm.h"
 #include "jit/InlinableNatives.h"
 #include "jit/Ion.h"
 #include "jit/JitcodeMap.h"
 #include "jit/JitRealm.h"
 #include "jit/shared/CodeGenerator-shared.h"
 #include "js/AutoByteString.h"
+#include "js/CompileOptions.h"
 #include "js/Debug.h"
 #include "js/GCVector.h"
 #include "js/Initialization.h"
 #include "js/JSON.h"
 #include "js/Printf.h"
 #include "js/SourceBufferHolder.h"
 #include "js/StableStringChars.h"
 #include "js/StructuredClone.h"
@@ -127,16 +128,17 @@
 #include "vm/Realm-inl.h"
 #include "vm/Stack-inl.h"
 
 using namespace js;
 using namespace js::cli;
 using namespace js::shell;
 
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
 
 using js::shell::RCFile;
 
 using mozilla::ArrayEqual;
 using mozilla::ArrayLength;
 using mozilla::Atomic;
 using mozilla::MakeScopeExit;
 using mozilla::Maybe;
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -54,16 +54,17 @@
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Stack-inl.h"
 
 using namespace js;
 
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
 using JS::dbg::AutoEntryMonitor;
 using JS::dbg::Builder;
 using js::frontend::IsIdentifier;
 using JS::SourceBufferHolder;
 using mozilla::DebugOnly;
 using mozilla::MakeScopeExit;
 using mozilla::Maybe;
 using mozilla::Some;
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -35,16 +35,19 @@
 
 using namespace js;
 
 using mozilla::Maybe;
 using mozilla::Unused;
 using mozilla::TimeDuration;
 using mozilla::TimeStamp;
 
+using JS::CompileOptions;
+using JS::ReadOnlyCompileOptions;
+
 namespace js {
 
 GlobalHelperThreadState* gHelperThreadState = nullptr;
 
 } // namespace js
 
 // These macros are identical in function to the same-named ones in
 // GeckoProfiler.h, but they are defined separately because SpiderMonkey can't
--- a/js/src/vm/HelperThreads.h
+++ b/js/src/vm/HelperThreads.h
@@ -19,16 +19,17 @@
 #include "mozilla/TimeStamp.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Variant.h"
 
 #include "jsapi.h"
 
 #include "ds/Fifo.h"
 #include "jit/Ion.h"
+#include "js/CompileOptions.h"
 #include "js/SourceBufferHolder.h"
 #include "js/TypeDecls.h"
 #include "threading/ConditionVariable.h"
 #include "vm/JSContext.h"
 #include "vm/MutexIDs.h"
 
 namespace JS {
 class OffThreadToken {};
@@ -599,41 +600,41 @@ HasOffThreadIonCompile(JS::Realm* realm)
 void
 CancelOffThreadParses(JSRuntime* runtime);
 
 /*
  * Start a parse/emit cycle for a stream of source. The characters must stay
  * alive until the compilation finishes.
  */
 bool
-StartOffThreadParseScript(JSContext* cx, const ReadOnlyCompileOptions& options,
+StartOffThreadParseScript(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                           JS::SourceBufferHolder& srcBuf,
                           JS::OffThreadCompileCallback callback, void* callbackData);
 
 bool
-StartOffThreadParseModule(JSContext* cx, const ReadOnlyCompileOptions& options,
+StartOffThreadParseModule(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                           JS::SourceBufferHolder& srcBuf,
                           JS::OffThreadCompileCallback callback, void* callbackData);
 
 bool
-StartOffThreadDecodeScript(JSContext* cx, const ReadOnlyCompileOptions& options,
+StartOffThreadDecodeScript(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                            const JS::TranscodeRange& range,
                            JS::OffThreadCompileCallback callback, void* callbackData);
 
 #if defined(JS_BUILD_BINAST)
 
 bool
-StartOffThreadDecodeBinAST(JSContext* cx, const ReadOnlyCompileOptions& options,
+StartOffThreadDecodeBinAST(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                            const uint8_t* buf, size_t length,
                            JS::OffThreadCompileCallback callback, void* callbackData);
 
 #endif /* JS_BUILD_BINAST */
 
 bool
-StartOffThreadDecodeMultiScripts(JSContext* cx, const ReadOnlyCompileOptions& options,
+StartOffThreadDecodeMultiScripts(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                                  JS::TranscodeSources& sources,
                                  JS::OffThreadCompileCallback callback, void* callbackData);
 
 /*
  * Called at the end of GC to enqueue any Parse tasks that were waiting on an
  * atoms-zone GC to finish.
  */
 void
@@ -682,17 +683,17 @@ class MOZ_RAII AutoUnlockHelperThreadSta
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
 };
 
 struct ParseTask : public mozilla::LinkedListElement<ParseTask>, public JS::OffThreadToken
 {
     ParseTaskKind kind;
-    OwningCompileOptions options;
+    JS::OwningCompileOptions options;
 
     LifoAlloc alloc;
 
     // The global object to use while parsing.
     JSObject* parseGlobal;
 
     // Callback invoked off thread when the parse finishes.
     JS::OffThreadCompileCallback callback;
@@ -711,17 +712,17 @@ struct ParseTask : public mozilla::Linke
     Vector<UniquePtr<CompileError>, 0, SystemAllocPolicy> errors;
     bool overRecursed;
     bool outOfMemory;
 
     ParseTask(ParseTaskKind kind, JSContext* cx,
               JS::OffThreadCompileCallback callback, void* callbackData);
     virtual ~ParseTask();
 
-    bool init(JSContext* cx, const ReadOnlyCompileOptions& options, JSObject* global);
+    bool init(JSContext* cx, const JS::ReadOnlyCompileOptions& options, JSObject* global);
 
     void activate(JSRuntime* rt);
     virtual void parse(JSContext* cx) = 0;
     bool finish(JSContext* cx);
 
     bool runtimeMatches(JSRuntime* rt) {
         return parseGlobal->runtimeFromAnyThread() == rt;
     }
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -28,17 +28,19 @@
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/TokenStream.h"
 #include "gc/Marking.h"
 #include "gc/Policy.h"
 #include "jit/InlinableNatives.h"
 #include "jit/Ion.h"
 #include "js/AutoByteString.h"
 #include "js/CallNonGenericMethod.h"
+#include "js/CompileOptions.h"
 #include "js/Proxy.h"
+
 #include "js/SourceBufferHolder.h"
 #include "js/StableStringChars.h"
 #include "js/Wrapper.h"
 #include "util/StringBuffer.h"
 #include "vm/AsyncFunction.h"
 #include "vm/AsyncIteration.h"
 #include "vm/Debugger.h"
 #include "vm/GlobalObject.h"
@@ -63,16 +65,17 @@ using namespace js::gc;
 using namespace js::frontend;
 
 using mozilla::ArrayLength;
 using mozilla::CheckedInt;
 using mozilla::Maybe;
 using mozilla::Some;
 
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
 using JS::SourceBufferHolder;
 
 static bool
 fun_enumerate(JSContext* cx, HandleObject obj)
 {
     MOZ_ASSERT(obj->is<JSFunction>());
 
     RootedId id(cx);
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -31,16 +31,17 @@
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/BytecodeEmitter.h"
 #include "frontend/SharedContext.h"
 #include "gc/FreeOp.h"
 #include "jit/BaselineJIT.h"
 #include "jit/Ion.h"
 #include "jit/IonCode.h"
 #include "jit/JitRealm.h"
+#include "js/CompileOptions.h"
 #include "js/MemoryMetrics.h"
 #include "js/Printf.h"
 #include "js/SourceBufferHolder.h"
 #include "js/UniquePtr.h"
 #include "js/Utility.h"
 #include "js/Wrapper.h"
 #include "util/StringBuffer.h"
 #include "util/Text.h"
@@ -70,16 +71,18 @@
 
 using namespace js;
 using namespace js::gc;
 using namespace js::frontend;
 
 using mozilla::Maybe;
 using mozilla::PodCopy;
 
+using JS::CompileOptions;
+using JS::ReadOnlyCompileOptions;
 using JS::SourceBufferHolder;
 
 template<XDRMode mode>
 XDRResult
 js::XDRScriptConst(XDRState<mode>* xdr, MutableHandleValue vp)
 {
     JSContext* cx = xdr->cx();
 
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -16,16 +16,17 @@
 #include "mozilla/Variant.h"
 
 #include "jstypes.h"
 
 #include "frontend/NameAnalysisTypes.h"
 #include "gc/Barrier.h"
 #include "gc/Rooting.h"
 #include "jit/IonCode.h"
+#include "js/CompileOptions.h"
 #include "js/UbiNode.h"
 #include "js/UniquePtr.h"
 #include "vm/BytecodeUtil.h"
 #include "vm/JSAtom.h"
 #include "vm/NativeObject.h"
 #include "vm/Scope.h"
 #include "vm/Shape.h"
 #include "vm/SharedImmutableStringsCache.h"
@@ -539,17 +540,17 @@ class ScriptSource
 
     void incref() { refs++; }
     void decref() {
         MOZ_ASSERT(refs != 0);
         if (--refs == 0)
             js_delete(this);
     }
     MOZ_MUST_USE bool initFromOptions(JSContext* cx,
-                                      const ReadOnlyCompileOptions& options,
+                                      const JS::ReadOnlyCompileOptions& options,
                                       const mozilla::Maybe<uint32_t>& parameterListEnd = mozilla::Nothing());
     MOZ_MUST_USE bool setSourceCopy(JSContext* cx, JS::SourceBufferHolder& srcBuf);
     void setSourceRetrievable() { sourceRetrievable_ = true; }
     bool sourceRetrievable() const { return sourceRetrievable_; }
     bool hasSourceData() const { return !data.is<Missing>(); }
     bool hasUncompressedSource() const { return data.is<Uncompressed>(); }
     bool hasCompressedSource() const { return data.is<Compressed>(); }
 
@@ -726,17 +727,17 @@ class ScriptSourceObject : public Native
 
     static void trace(JSTracer* trc, JSObject* obj);
     static void finalize(FreeOp* fop, JSObject* obj);
     static ScriptSourceObject* create(JSContext* cx, ScriptSource* source);
 
     // Initialize those properties of this ScriptSourceObject whose values
     // are provided by |options|, re-wrapping as necessary.
     static bool initFromOptions(JSContext* cx, HandleScriptSourceObject source,
-                                const ReadOnlyCompileOptions& options);
+                                const JS::ReadOnlyCompileOptions& options);
 
     static bool initElementProperties(JSContext* cx, HandleScriptSourceObject source,
                                       HandleObject element, HandleString elementAttrName);
 
     ScriptSource* source() const {
         return static_cast<ScriptSource*>(getReservedSlot(SOURCE_SLOT).toPrivate());
     }
     JSObject* element() const {
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -39,16 +39,17 @@
 
 using namespace js;
 
 using mozilla::ArrayLength;
 using mozilla::DebugOnly;
 using mozilla::PodCopy;
 using JS::AutoStableStringChars;
 using js::frontend::TokenStream;
+using JS::CompileOptions;
 
 using JS::AutoCheckCannotGC;
 
 JS_STATIC_ASSERT(IgnoreCaseFlag == JSREG_FOLD);
 JS_STATIC_ASSERT(GlobalFlag == JSREG_GLOB);
 JS_STATIC_ASSERT(MultilineFlag == JSREG_MULTILINE);
 JS_STATIC_ASSERT(StickyFlag == JSREG_STICKY);
 JS_STATIC_ASSERT(UnicodeFlag == JSREG_UNICODE);
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -68,16 +68,17 @@
 #include "vm/NumberObject-inl.h"
 #include "vm/StringObject-inl.h"
 
 using namespace js;
 using namespace js::selfhosted;
 
 using JS::AutoCheckCannotGC;
 using JS::AutoStableStringChars;
+using JS::CompileOptions;
 using mozilla::IsInRange;
 using mozilla::Maybe;
 
 static void
 selfHosting_WarningReporter(JSContext* cx, JSErrorReport* report)
 {
     MOZ_ASSERT(report);
     MOZ_ASSERT(JSREPORT_IS_WARNING(report->flags));
--- a/js/src/vm/Xdr.h
+++ b/js/src/vm/Xdr.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/EndianUtils.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "NamespaceImports.h"
 
+#include "js/CompileOptions.h"
 #include "js/Transcoding.h"
 #include "js/TypeDecls.h"
 #include "vm/JSAtom.h"
 
 namespace js {
 
 class LifoAlloc;
 
@@ -249,17 +250,17 @@ class XDRState : public XDRCoderBase
     virtual ~XDRState() {};
 
     JSContext* cx() const {
         return buf.cx();
     }
     virtual LifoAlloc& lifoAlloc() const;
 
     virtual bool hasOptions() const { return false; }
-    virtual const ReadOnlyCompileOptions& options() {
+    virtual const JS::ReadOnlyCompileOptions& options() {
         MOZ_CRASH("does not have options");
     }
     virtual bool hasScriptSourceObjectOut() const { return false; }
     virtual ScriptSourceObject** scriptSourceObjectOut() {
         MOZ_CRASH("does not have scriptSourceObjectOut.");
     }
 
     XDRResult fail(JS::TranscodeResult code) {
@@ -472,31 +473,31 @@ class XDRState : public XDRCoderBase
     XDRResult codeScript(MutableHandleScript scriptp);
 };
 
 using XDREncoder = XDRState<XDR_ENCODE>;
 using XDRDecoder = XDRState<XDR_DECODE>;
 
 class XDROffThreadDecoder : public XDRDecoder
 {
-    const ReadOnlyCompileOptions* options_;
+    const JS::ReadOnlyCompileOptions* options_;
     ScriptSourceObject** sourceObjectOut_;
     LifoAlloc& alloc_;
 
   public:
     // Note, when providing an JSContext, where isJSContext is false,
     // then the initialization of the ScriptSourceObject would remain
     // incomplete. Thus, the sourceObjectOut must be used to finish the
     // initialization with ScriptSourceObject::initFromOptions after the
     // decoding.
     //
     // When providing a sourceObjectOut pointer, you have to ensure that it is
     // marked by the GC to avoid dangling pointers.
     XDROffThreadDecoder(JSContext* cx, LifoAlloc& alloc,
-                        const ReadOnlyCompileOptions* options,
+                        const JS::ReadOnlyCompileOptions* options,
                         ScriptSourceObject** sourceObjectOut,
                         const JS::TranscodeRange& range)
       : XDRDecoder(cx, range),
         options_(options),
         sourceObjectOut_(sourceObjectOut),
         alloc_(alloc)
     {
         MOZ_ASSERT(options);
@@ -504,17 +505,17 @@ class XDROffThreadDecoder : public XDRDe
         MOZ_ASSERT(*sourceObjectOut == nullptr);
     }
 
     LifoAlloc& lifoAlloc() const override {
         return alloc_;
     }
 
     bool hasOptions() const override { return true; }
-    const ReadOnlyCompileOptions& options() override {
+    const JS::ReadOnlyCompileOptions& options() override {
         return *options_;
     }
     bool hasScriptSourceObjectOut() const override { return true; }
     ScriptSourceObject** scriptSourceObjectOut() override {
         return sourceObjectOut_;
     }
 };
 
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -6150,17 +6150,17 @@ HandleInstantiationFailure(JSContext* cx
         return false;
 
     RootedFunction fun(cx, NewScriptedFunction(cx, 0, JSFunction::INTERPRETED_NORMAL,
                                                name, /* proto = */ nullptr, gc::AllocKind::FUNCTION,
                                                TenuredObject));
     if (!fun)
         return false;
 
-    CompileOptions options(cx);
+    JS::CompileOptions options(cx);
     options.setMutedErrors(source->mutedErrors())
            .setFile(source->filename())
            .setNoScriptRval(false);
     options.asmJSOption = AsmJSOption::Disabled;
 
     // The exported function inherits an implicit strict context if the module
     // also inherited it somehow.
     if (metadata.strict)