Bug 1522350 - Move JS::ContextOptions{,Ref} to a new js/public/ContextOptions.h header to further slim jsapi.h. r=arai

--HG--
rename : js/src/jsapi.h => js/public/ContextOptions.h
This commit is contained in:
Jeff Walden 2019-01-23 16:56:56 -08:00
Родитель b8e8e3c96d
Коммит 59aaefa333
21 изменённых файлов: 273 добавлений и 231 удалений

Просмотреть файл

@ -19,6 +19,7 @@
#include "nsGlobalWindow.h"
#include "WorkerScope.h"
#include "jsapi.h"
#include "js/ContextOptions.h"
#include "nsJSPrincipals.h"
namespace mozilla {

Просмотреть файл

@ -31,6 +31,7 @@
#include "nsJSEnvironment.h"
#include "xpcpublic.h"
#include "jsapi.h"
#include "js/ContextOptions.h"
#include "js/TracingAPI.h"
namespace mozilla {

Просмотреть файл

@ -7,7 +7,11 @@
#ifndef mozilla_dom_workerinternals_JSSettings_h
#define mozilla_dom_workerinternals_JSSettings_h
#include <stdint.h>
#include "jsapi.h"
#include "js/ContextOptions.h"
#include "js/GCAPI.h"
#include "mozilla/Maybe.h"
#include "nsString.h"
#include "nsTArray.h"

Просмотреть файл

@ -29,6 +29,7 @@
#include "mozilla/ipc/BackgroundChild.h"
#include "GeckoProfiler.h"
#include "jsfriendapi.h"
#include "js/ContextOptions.h"
#include "js/LocaleSensitive.h"
#include "mozilla/AbstractThread.h"
#include "mozilla/AntiTrackingCommon.h"

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsIObserver.h"
#include "js/ContextOptions.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/workerinternals/JSSettings.h"
#include "mozilla/Mutex.h"

Просмотреть файл

@ -9,6 +9,7 @@
#include <utility>
#include "js/CompilationAndEvaluation.h"
#include "js/ContextOptions.h"
#include "js/LocaleSensitive.h"
#include "js/MemoryMetrics.h"
#include "js/SourceText.h"

Просмотреть файл

@ -15,6 +15,7 @@
#include "nsIEventTarget.h"
#include "nsTObserverArray.h"
#include "js/ContextOptions.h"
#include "mozilla/dom/Worker.h"
#include "mozilla/dom/WorkerHolder.h"
#include "mozilla/dom/WorkerLoadInfo.h"

251
js/public/ContextOptions.h Normal file
Просмотреть файл

@ -0,0 +1,251 @@
/* -*- 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/. */
/* JavaScript API. */
#ifndef js_ContextOptions_h
#define js_ContextOptions_h
#include "jstypes.h" // JS_PUBLIC_API
struct JSContext;
namespace JS {
class JS_PUBLIC_API ContextOptions {
public:
ContextOptions()
: baseline_(true),
ion_(true),
asmJS_(true),
wasm_(true),
wasmVerbose_(false),
wasmBaseline_(true),
wasmIon_(true),
#ifdef ENABLE_WASM_CRANELIFT
wasmCranelift_(false),
#endif
#ifdef ENABLE_WASM_REFTYPES
wasmGc_(false),
#endif
testWasmAwaitTier2_(false),
throwOnAsmJSValidationFailure_(false),
nativeRegExp_(true),
asyncStack_(true),
throwOnDebuggeeWouldRun_(true),
dumpStackOnDebuggeeWouldRun_(false),
werror_(false),
strictMode_(false),
extraWarnings_(false)
#ifdef FUZZING
,
fuzzing_(false)
#endif
{
}
bool baseline() const { return baseline_; }
ContextOptions& setBaseline(bool flag) {
baseline_ = flag;
return *this;
}
ContextOptions& toggleBaseline() {
baseline_ = !baseline_;
return *this;
}
bool ion() const { return ion_; }
ContextOptions& setIon(bool flag) {
ion_ = flag;
return *this;
}
ContextOptions& toggleIon() {
ion_ = !ion_;
return *this;
}
bool asmJS() const { return asmJS_; }
ContextOptions& setAsmJS(bool flag) {
asmJS_ = flag;
return *this;
}
ContextOptions& toggleAsmJS() {
asmJS_ = !asmJS_;
return *this;
}
bool wasm() const { return wasm_; }
ContextOptions& setWasm(bool flag) {
wasm_ = flag;
return *this;
}
ContextOptions& toggleWasm() {
wasm_ = !wasm_;
return *this;
}
bool wasmVerbose() const { return wasmVerbose_; }
ContextOptions& setWasmVerbose(bool flag) {
wasmVerbose_ = flag;
return *this;
}
bool wasmBaseline() const { return wasmBaseline_; }
ContextOptions& setWasmBaseline(bool flag) {
wasmBaseline_ = flag;
return *this;
}
bool wasmIon() const { return wasmIon_; }
ContextOptions& setWasmIon(bool flag) {
wasmIon_ = flag;
return *this;
}
#ifdef ENABLE_WASM_CRANELIFT
bool wasmCranelift() const { return wasmCranelift_; }
ContextOptions& setWasmCranelift(bool flag) {
wasmCranelift_ = flag;
return *this;
}
#endif
bool testWasmAwaitTier2() const { return testWasmAwaitTier2_; }
ContextOptions& setTestWasmAwaitTier2(bool flag) {
testWasmAwaitTier2_ = flag;
return *this;
}
#ifdef ENABLE_WASM_REFTYPES
bool wasmGc() const { return wasmGc_; }
ContextOptions& setWasmGc(bool flag) {
wasmGc_ = flag;
return *this;
}
#endif
bool throwOnAsmJSValidationFailure() const {
return throwOnAsmJSValidationFailure_;
}
ContextOptions& setThrowOnAsmJSValidationFailure(bool flag) {
throwOnAsmJSValidationFailure_ = flag;
return *this;
}
ContextOptions& toggleThrowOnAsmJSValidationFailure() {
throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_;
return *this;
}
bool nativeRegExp() const { return nativeRegExp_; }
ContextOptions& setNativeRegExp(bool flag) {
nativeRegExp_ = flag;
return *this;
}
bool asyncStack() const { return asyncStack_; }
ContextOptions& setAsyncStack(bool flag) {
asyncStack_ = flag;
return *this;
}
bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; }
ContextOptions& setThrowOnDebuggeeWouldRun(bool flag) {
throwOnDebuggeeWouldRun_ = flag;
return *this;
}
bool dumpStackOnDebuggeeWouldRun() const {
return dumpStackOnDebuggeeWouldRun_;
}
ContextOptions& setDumpStackOnDebuggeeWouldRun(bool flag) {
dumpStackOnDebuggeeWouldRun_ = flag;
return *this;
}
bool werror() const { return werror_; }
ContextOptions& setWerror(bool flag) {
werror_ = flag;
return *this;
}
ContextOptions& toggleWerror() {
werror_ = !werror_;
return *this;
}
bool strictMode() const { return strictMode_; }
ContextOptions& setStrictMode(bool flag) {
strictMode_ = flag;
return *this;
}
ContextOptions& toggleStrictMode() {
strictMode_ = !strictMode_;
return *this;
}
bool extraWarnings() const { return extraWarnings_; }
ContextOptions& setExtraWarnings(bool flag) {
extraWarnings_ = flag;
return *this;
}
ContextOptions& toggleExtraWarnings() {
extraWarnings_ = !extraWarnings_;
return *this;
}
#ifdef FUZZING
bool fuzzing() const { return fuzzing_; }
ContextOptions& setFuzzing(bool flag) {
fuzzing_ = flag;
return *this;
}
#endif
void disableOptionsForSafeMode() {
setBaseline(false);
setIon(false);
setAsmJS(false);
setWasm(false);
setWasmBaseline(false);
setWasmIon(false);
#ifdef ENABLE_WASM_REFTYPES
setWasmGc(false);
#endif
setNativeRegExp(false);
}
private:
bool baseline_ : 1;
bool ion_ : 1;
bool asmJS_ : 1;
bool wasm_ : 1;
bool wasmVerbose_ : 1;
bool wasmBaseline_ : 1;
bool wasmIon_ : 1;
#ifdef ENABLE_WASM_CRANELIFT
bool wasmCranelift_ : 1;
#endif
#ifdef ENABLE_WASM_REFTYPES
bool wasmGc_ : 1;
#endif
bool testWasmAwaitTier2_ : 1;
bool throwOnAsmJSValidationFailure_ : 1;
bool nativeRegExp_ : 1;
bool asyncStack_ : 1;
bool throwOnDebuggeeWouldRun_ : 1;
bool dumpStackOnDebuggeeWouldRun_ : 1;
bool werror_ : 1;
bool strictMode_ : 1;
bool extraWarnings_ : 1;
#ifdef FUZZING
bool fuzzing_ : 1;
#endif
};
JS_PUBLIC_API ContextOptions& ContextOptionsRef(JSContext* cx);
} // namespace JS
#endif // js_ContextOptions_h

Просмотреть файл

@ -15,6 +15,7 @@ typedef uint32_t HashNumber;
#include "jsfriendapi.h"
#include "js/CompilationAndEvaluation.h"
#include "js/CompileOptions.h"
#include "js/ContextOptions.h"
#include "js/Conversions.h"
#include "js/Date.h"
#include "js/Initialization.h"

Просмотреть файл

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "js/CompilationAndEvaluation.h"
#include "js/ContextOptions.h"
#include "jsapi-tests/tests.h"
static TestJSPrincipals system_principals(1);

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/Atomics.h"
#include "js/ContextOptions.h"
#include "js/PropertySpec.h"
#include "jsapi-tests/tests.h"
#include "vm/JSContext.h"

Просмотреть файл

@ -55,6 +55,7 @@
#include "js/CharacterEncoding.h"
#include "js/CompilationAndEvaluation.h"
#include "js/CompileOptions.h"
#include "js/ContextOptions.h" // JS::ContextOptions{,Ref}
#include "js/Conversions.h"
#include "js/Date.h"
#include "js/Initialization.h"

Просмотреть файл

@ -385,237 +385,6 @@ void AssertHeapIsIdle();
namespace JS {
class JS_PUBLIC_API ContextOptions {
public:
ContextOptions()
: baseline_(true),
ion_(true),
asmJS_(true),
wasm_(true),
wasmVerbose_(false),
wasmBaseline_(true),
wasmIon_(true),
#ifdef ENABLE_WASM_CRANELIFT
wasmCranelift_(false),
#endif
#ifdef ENABLE_WASM_REFTYPES
wasmGc_(false),
#endif
testWasmAwaitTier2_(false),
throwOnAsmJSValidationFailure_(false),
nativeRegExp_(true),
asyncStack_(true),
throwOnDebuggeeWouldRun_(true),
dumpStackOnDebuggeeWouldRun_(false),
werror_(false),
strictMode_(false),
extraWarnings_(false)
#ifdef FUZZING
,
fuzzing_(false)
#endif
{
}
bool baseline() const { return baseline_; }
ContextOptions& setBaseline(bool flag) {
baseline_ = flag;
return *this;
}
ContextOptions& toggleBaseline() {
baseline_ = !baseline_;
return *this;
}
bool ion() const { return ion_; }
ContextOptions& setIon(bool flag) {
ion_ = flag;
return *this;
}
ContextOptions& toggleIon() {
ion_ = !ion_;
return *this;
}
bool asmJS() const { return asmJS_; }
ContextOptions& setAsmJS(bool flag) {
asmJS_ = flag;
return *this;
}
ContextOptions& toggleAsmJS() {
asmJS_ = !asmJS_;
return *this;
}
bool wasm() const { return wasm_; }
ContextOptions& setWasm(bool flag) {
wasm_ = flag;
return *this;
}
ContextOptions& toggleWasm() {
wasm_ = !wasm_;
return *this;
}
bool wasmVerbose() const { return wasmVerbose_; }
ContextOptions& setWasmVerbose(bool flag) {
wasmVerbose_ = flag;
return *this;
}
bool wasmBaseline() const { return wasmBaseline_; }
ContextOptions& setWasmBaseline(bool flag) {
wasmBaseline_ = flag;
return *this;
}
bool wasmIon() const { return wasmIon_; }
ContextOptions& setWasmIon(bool flag) {
wasmIon_ = flag;
return *this;
}
#ifdef ENABLE_WASM_CRANELIFT
bool wasmCranelift() const { return wasmCranelift_; }
ContextOptions& setWasmCranelift(bool flag) {
wasmCranelift_ = flag;
return *this;
}
#endif
bool testWasmAwaitTier2() const { return testWasmAwaitTier2_; }
ContextOptions& setTestWasmAwaitTier2(bool flag) {
testWasmAwaitTier2_ = flag;
return *this;
}
#ifdef ENABLE_WASM_REFTYPES
bool wasmGc() const { return wasmGc_; }
ContextOptions& setWasmGc(bool flag) {
wasmGc_ = flag;
return *this;
}
#endif
bool throwOnAsmJSValidationFailure() const {
return throwOnAsmJSValidationFailure_;
}
ContextOptions& setThrowOnAsmJSValidationFailure(bool flag) {
throwOnAsmJSValidationFailure_ = flag;
return *this;
}
ContextOptions& toggleThrowOnAsmJSValidationFailure() {
throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_;
return *this;
}
bool nativeRegExp() const { return nativeRegExp_; }
ContextOptions& setNativeRegExp(bool flag) {
nativeRegExp_ = flag;
return *this;
}
bool asyncStack() const { return asyncStack_; }
ContextOptions& setAsyncStack(bool flag) {
asyncStack_ = flag;
return *this;
}
bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; }
ContextOptions& setThrowOnDebuggeeWouldRun(bool flag) {
throwOnDebuggeeWouldRun_ = flag;
return *this;
}
bool dumpStackOnDebuggeeWouldRun() const {
return dumpStackOnDebuggeeWouldRun_;
}
ContextOptions& setDumpStackOnDebuggeeWouldRun(bool flag) {
dumpStackOnDebuggeeWouldRun_ = flag;
return *this;
}
bool werror() const { return werror_; }
ContextOptions& setWerror(bool flag) {
werror_ = flag;
return *this;
}
ContextOptions& toggleWerror() {
werror_ = !werror_;
return *this;
}
bool strictMode() const { return strictMode_; }
ContextOptions& setStrictMode(bool flag) {
strictMode_ = flag;
return *this;
}
ContextOptions& toggleStrictMode() {
strictMode_ = !strictMode_;
return *this;
}
bool extraWarnings() const { return extraWarnings_; }
ContextOptions& setExtraWarnings(bool flag) {
extraWarnings_ = flag;
return *this;
}
ContextOptions& toggleExtraWarnings() {
extraWarnings_ = !extraWarnings_;
return *this;
}
#ifdef FUZZING
bool fuzzing() const { return fuzzing_; }
ContextOptions& setFuzzing(bool flag) {
fuzzing_ = flag;
return *this;
}
#endif
void disableOptionsForSafeMode() {
setBaseline(false);
setIon(false);
setAsmJS(false);
setWasm(false);
setWasmBaseline(false);
setWasmIon(false);
#ifdef ENABLE_WASM_REFTYPES
setWasmGc(false);
#endif
setNativeRegExp(false);
}
private:
bool baseline_ : 1;
bool ion_ : 1;
bool asmJS_ : 1;
bool wasm_ : 1;
bool wasmVerbose_ : 1;
bool wasmBaseline_ : 1;
bool wasmIon_ : 1;
#ifdef ENABLE_WASM_CRANELIFT
bool wasmCranelift_ : 1;
#endif
#ifdef ENABLE_WASM_REFTYPES
bool wasmGc_ : 1;
#endif
bool testWasmAwaitTier2_ : 1;
bool throwOnAsmJSValidationFailure_ : 1;
bool nativeRegExp_ : 1;
bool asyncStack_ : 1;
bool throwOnDebuggeeWouldRun_ : 1;
bool dumpStackOnDebuggeeWouldRun_ : 1;
bool werror_ : 1;
bool strictMode_ : 1;
bool extraWarnings_ : 1;
#ifdef FUZZING
bool fuzzing_ : 1;
#endif
};
JS_PUBLIC_API ContextOptions& ContextOptionsRef(JSContext* cx);
/**
* Initialize the runtime's self-hosted code. Embeddings should call this
* exactly once per runtime/context, before the first JS_NewGlobalObject

Просмотреть файл

@ -120,6 +120,7 @@ EXPORTS.js += [
'../public/Class.h',
'../public/CompilationAndEvaluation.h',
'../public/CompileOptions.h',
'../public/ContextOptions.h',
'../public/Conversions.h',
'../public/Date.h',
'../public/Debug.h',

Просмотреть файл

@ -88,6 +88,7 @@
#include "js/CharacterEncoding.h"
#include "js/CompilationAndEvaluation.h"
#include "js/CompileOptions.h"
#include "js/ContextOptions.h" // JS::ContextOptions{,Ref}
#include "js/Debug.h"
#include "js/Equality.h" // JS::SameValue
#include "js/GCVector.h"

Просмотреть файл

@ -14,6 +14,7 @@
#include "frontend/BytecodeCompilation.h"
#include "gc/GCInternals.h"
#include "jit/IonBuilder.h"
#include "js/ContextOptions.h" // JS::ContextOptions
#include "js/SourceText.h"
#include "js/UniquePtr.h"
#include "js/Utility.h"

Просмотреть файл

@ -38,6 +38,7 @@
#include "jit/Ion.h"
#include "jit/PcScriptCache.h"
#include "js/CharacterEncoding.h"
#include "js/ContextOptions.h" // JS::ContextOptions
#include "js/Printf.h"
#ifdef JS_SIMULATOR_ARM64
# include "jit/arm64/vixl/Simulator-vixl.h"

Просмотреть файл

@ -13,6 +13,7 @@
#include "ds/TraceableFifo.h"
#include "js/CharacterEncoding.h"
#include "js/ContextOptions.h" // JS::ContextOptions
#include "js/GCVector.h"
#include "js/Promise.h"
#include "js/Result.h"

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsCycleCollector.h"
#include "jsfriendapi.h"
#include "js/CharacterEncoding.h"
#include "js/ContextOptions.h"
#include "js/SavedFrameAPI.h"
#include "js/StructuredClone.h"
#include "mozilla/Attributes.h"

Просмотреть файл

@ -38,6 +38,7 @@
#include "nsCycleCollectionNoteRootCallback.h"
#include "nsCycleCollector.h"
#include "jsapi.h"
#include "js/ContextOptions.h"
#include "js/MemoryMetrics.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Element.h"

Просмотреть файл

@ -9,6 +9,7 @@
#include "jsfriendapi.h"
#include "js/CharacterEncoding.h"
#include "js/CompilationAndEvaluation.h"
#include "js/ContextOptions.h"
#include "js/Printf.h"
#include "js/PropertySpec.h"
#include "mozilla/ChaosMode.h"