зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1576254 - Add a wasmForTrustedPrinciples bool onto ContextOptions that (currently) behaves the exact same as the wasm bool r=luke
In a future commit we will tie this boolean to its own preference value, but here we initialize it with the same value as the wasm boolean. We also update wasm::HasSupport to check the to-be-added isSystemOrAddonPrincipal() method on JSPrincipals to determine which member (wasm or wasmForTrustedPrinciples) to consult. Differential Revision: https://phabricator.services.mozilla.com/D47472 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
206eea6eb4
Коммит
754ebbc4d7
|
@ -286,6 +286,8 @@ void LoadContextOptions(const char* aPrefName, void* /* aClosure */) {
|
|||
JS::ContextOptions contextOptions;
|
||||
contextOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs")))
|
||||
.setWasm(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm")))
|
||||
.setWasmForTrustedPrinciples(
|
||||
GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm")))
|
||||
.setWasmBaseline(
|
||||
GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_baselinejit")))
|
||||
.setWasmIon(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_ionjit")))
|
||||
|
|
|
@ -20,6 +20,7 @@ class JS_PUBLIC_API ContextOptions {
|
|||
ContextOptions()
|
||||
: asmJS_(true),
|
||||
wasm_(true),
|
||||
wasmForTrustedPrinciples_(true),
|
||||
wasmVerbose_(false),
|
||||
wasmBaseline_(true),
|
||||
wasmIon_(true),
|
||||
|
@ -64,6 +65,12 @@ class JS_PUBLIC_API ContextOptions {
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool wasmForTrustedPrinciples() const { return wasmForTrustedPrinciples_; }
|
||||
ContextOptions& setWasmForTrustedPrinciples(bool flag) {
|
||||
wasmForTrustedPrinciples_ = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wasmVerbose() const { return wasmVerbose_; }
|
||||
ContextOptions& setWasmVerbose(bool flag) {
|
||||
wasmVerbose_ = flag;
|
||||
|
@ -187,6 +194,7 @@ class JS_PUBLIC_API ContextOptions {
|
|||
private:
|
||||
bool asmJS_ : 1;
|
||||
bool wasm_ : 1;
|
||||
bool wasmForTrustedPrinciples_ : 1;
|
||||
bool wasmVerbose_ : 1;
|
||||
bool wasmBaseline_ : 1;
|
||||
bool wasmIon_ : 1;
|
||||
|
|
|
@ -10327,6 +10327,7 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
|
|||
JS::ContextOptionsRef(cx)
|
||||
.setAsmJS(enableAsmJS)
|
||||
.setWasm(enableWasm)
|
||||
.setWasmForTrustedPrinciples(enableWasm)
|
||||
.setWasmBaseline(enableWasmBaseline)
|
||||
.setWasmIon(enableWasmIon)
|
||||
#ifdef ENABLE_WASM_CRANELIFT
|
||||
|
|
|
@ -151,8 +151,15 @@ static bool HasAvailableCompilerTier(JSContext* cx) {
|
|||
}
|
||||
|
||||
bool wasm::HasSupport(JSContext* cx) {
|
||||
return cx->options().wasm() && HasCompilerSupport(cx) &&
|
||||
HasAvailableCompilerTier(cx);
|
||||
// If the general wasm pref is on, it's on for everything.
|
||||
bool prefEnabled = cx->options().wasm();
|
||||
// If the general pref is off, check trusted principals.
|
||||
if (MOZ_UNLIKELY(!prefEnabled)) {
|
||||
prefEnabled = cx->options().wasmForTrustedPrinciples() && cx->realm() &&
|
||||
cx->realm()->principals() &&
|
||||
cx->realm()->principals()->isSystemOrAddonPrincipal();
|
||||
}
|
||||
return prefEnabled && HasCompilerSupport(cx) && HasAvailableCompilerTier(cx);
|
||||
}
|
||||
|
||||
bool wasm::HasStreamingSupport(JSContext* cx) {
|
||||
|
|
|
@ -957,6 +957,7 @@ static void ReloadPrefsCallback(const char* pref, XPCJSContext* xpccx) {
|
|||
JS::ContextOptionsRef(cx)
|
||||
.setAsmJS(useAsmJS)
|
||||
.setWasm(useWasm)
|
||||
.setWasmForTrustedPrinciples(useWasm)
|
||||
.setWasmIon(useWasmIon)
|
||||
.setWasmBaseline(useWasmBaseline)
|
||||
#ifdef ENABLE_WASM_CRANELIFT
|
||||
|
|
Загрузка…
Ссылка в новой задаче