зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1590907 - Remove preprocessor dependence from size of ContextOptions. r=sfink
Previously, if SpiderMonkey embedders linked to a copy of libmozjs built with --enable-cranelift, --enable-wasm-gc, or --enable-fuzzing, then the size of the ContextOptions data structure declared in the header file would be different than the size of ContextOptions in the library, likely leading to crashes. This makes all members of ContextOptions independent of preprocessor macros. Any options not compiled into SpiderMonkey will still be no-ops. Differential Revision: https://phabricator.services.mozilla.com/D52460 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
efe8a8c1bf
Коммит
60223e4965
|
@ -24,12 +24,8 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
wasmVerbose_(false),
|
wasmVerbose_(false),
|
||||||
wasmBaseline_(true),
|
wasmBaseline_(true),
|
||||||
wasmIon_(true),
|
wasmIon_(true),
|
||||||
#ifdef ENABLE_WASM_CRANELIFT
|
|
||||||
wasmCranelift_(false),
|
wasmCranelift_(false),
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_WASM_GC
|
|
||||||
wasmGc_(false),
|
wasmGc_(false),
|
||||||
#endif
|
|
||||||
testWasmAwaitTier2_(false),
|
testWasmAwaitTier2_(false),
|
||||||
throwOnAsmJSValidationFailure_(false),
|
throwOnAsmJSValidationFailure_(false),
|
||||||
asyncStack_(true),
|
asyncStack_(true),
|
||||||
|
@ -37,13 +33,8 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
dumpStackOnDebuggeeWouldRun_(false),
|
dumpStackOnDebuggeeWouldRun_(false),
|
||||||
werror_(false),
|
werror_(false),
|
||||||
strictMode_(false),
|
strictMode_(false),
|
||||||
extraWarnings_(false)
|
extraWarnings_(false),
|
||||||
#ifdef FUZZING
|
fuzzing_(false) {}
|
||||||
,
|
|
||||||
fuzzing_(false)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool asmJS() const { return asmJS_; }
|
bool asmJS() const { return asmJS_; }
|
||||||
ContextOptions& setAsmJS(bool flag) {
|
ContextOptions& setAsmJS(bool flag) {
|
||||||
|
@ -89,13 +80,9 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WASM_CRANELIFT
|
|
||||||
bool wasmCranelift() const { return wasmCranelift_; }
|
bool wasmCranelift() const { return wasmCranelift_; }
|
||||||
ContextOptions& setWasmCranelift(bool flag) {
|
// Defined out-of-line because it depends on a compile-time option
|
||||||
wasmCranelift_ = flag;
|
ContextOptions& setWasmCranelift(bool flag);
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool testWasmAwaitTier2() const { return testWasmAwaitTier2_; }
|
bool testWasmAwaitTier2() const { return testWasmAwaitTier2_; }
|
||||||
ContextOptions& setTestWasmAwaitTier2(bool flag) {
|
ContextOptions& setTestWasmAwaitTier2(bool flag) {
|
||||||
|
@ -103,13 +90,9 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WASM_GC
|
|
||||||
bool wasmGc() const { return wasmGc_; }
|
bool wasmGc() const { return wasmGc_; }
|
||||||
ContextOptions& setWasmGc(bool flag) {
|
// Defined out-of-line because it depends on a compile-time option
|
||||||
wasmGc_ = flag;
|
ContextOptions& setWasmGc(bool flag);
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool throwOnAsmJSValidationFailure() const {
|
bool throwOnAsmJSValidationFailure() const {
|
||||||
return throwOnAsmJSValidationFailure_;
|
return throwOnAsmJSValidationFailure_;
|
||||||
|
@ -173,22 +156,16 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FUZZING
|
|
||||||
bool fuzzing() const { return fuzzing_; }
|
bool fuzzing() const { return fuzzing_; }
|
||||||
ContextOptions& setFuzzing(bool flag) {
|
// Defined out-of-line because it depends on a compile-time option
|
||||||
fuzzing_ = flag;
|
ContextOptions& setFuzzing(bool flag);
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void disableOptionsForSafeMode() {
|
void disableOptionsForSafeMode() {
|
||||||
setAsmJS(false);
|
setAsmJS(false);
|
||||||
setWasm(false);
|
setWasm(false);
|
||||||
setWasmBaseline(false);
|
setWasmBaseline(false);
|
||||||
setWasmIon(false);
|
setWasmIon(false);
|
||||||
#ifdef ENABLE_WASM_GC
|
|
||||||
setWasmGc(false);
|
setWasmGc(false);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -198,12 +175,8 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
bool wasmVerbose_ : 1;
|
bool wasmVerbose_ : 1;
|
||||||
bool wasmBaseline_ : 1;
|
bool wasmBaseline_ : 1;
|
||||||
bool wasmIon_ : 1;
|
bool wasmIon_ : 1;
|
||||||
#ifdef ENABLE_WASM_CRANELIFT
|
|
||||||
bool wasmCranelift_ : 1;
|
bool wasmCranelift_ : 1;
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_WASM_GC
|
|
||||||
bool wasmGc_ : 1;
|
bool wasmGc_ : 1;
|
||||||
#endif
|
|
||||||
bool testWasmAwaitTier2_ : 1;
|
bool testWasmAwaitTier2_ : 1;
|
||||||
bool throwOnAsmJSValidationFailure_ : 1;
|
bool throwOnAsmJSValidationFailure_ : 1;
|
||||||
bool asyncStack_ : 1;
|
bool asyncStack_ : 1;
|
||||||
|
@ -212,9 +185,7 @@ class JS_PUBLIC_API ContextOptions {
|
||||||
bool werror_ : 1;
|
bool werror_ : 1;
|
||||||
bool strictMode_ : 1;
|
bool strictMode_ : 1;
|
||||||
bool extraWarnings_ : 1;
|
bool extraWarnings_ : 1;
|
||||||
#ifdef FUZZING
|
|
||||||
bool fuzzing_ : 1;
|
bool fuzzing_ : 1;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
JS_PUBLIC_API ContextOptions& ContextOptionsRef(JSContext* cx);
|
JS_PUBLIC_API ContextOptions& ContextOptionsRef(JSContext* cx);
|
||||||
|
|
|
@ -401,6 +401,27 @@ JS_PUBLIC_API JS::ContextOptions& JS::ContextOptionsRef(JSContext* cx) {
|
||||||
return cx->options();
|
return cx->options();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS::ContextOptions& JS::ContextOptions::setWasmCranelift(bool flag) {
|
||||||
|
#ifdef ENABLE_WASM_CRANELIFT
|
||||||
|
wasmCranelift_ = flag;
|
||||||
|
#endif
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS::ContextOptions& JS::ContextOptions::setWasmGc(bool flag) {
|
||||||
|
#ifdef ENABLE_WASM_GC
|
||||||
|
wasmGc_ = flag;
|
||||||
|
#endif
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS::ContextOptions& JS::ContextOptions::setFuzzing(bool flag) {
|
||||||
|
#ifdef FUZZING
|
||||||
|
fuzzing_ = flag;
|
||||||
|
#endif
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS::InitSelfHostedCode(JSContext* cx) {
|
JS_PUBLIC_API bool JS::InitSelfHostedCode(JSContext* cx) {
|
||||||
MOZ_RELEASE_ASSERT(!cx->runtime()->hasInitializedSelfHosting(),
|
MOZ_RELEASE_ASSERT(!cx->runtime()->hasInitializedSelfHosting(),
|
||||||
"JS::InitSelfHostedCode() called more than once");
|
"JS::InitSelfHostedCode() called more than once");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче