Bug 1774178 - Add test. r=nika,iain

Differential Revision: https://phabricator.services.mozilla.com/D152395
This commit is contained in:
Jan de Mooij 2022-08-02 13:23:58 +00:00
Родитель 420304b600
Коммит ff8dff26c3
3 изменённых файлов: 47 добавлений и 1 удалений

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

@ -4199,6 +4199,21 @@ JS_PUBLIC_API bool JS_GetGlobalJitCompilerOption(JSContext* cx,
case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
*valueOut = rt->canUseOffthreadIonCompilation();
break;
case JSJITCOMPILER_SPECTRE_INDEX_MASKING:
*valueOut = jit::JitOptions.spectreIndexMasking ? 1 : 0;
break;
case JSJITCOMPILER_SPECTRE_OBJECT_MITIGATIONS:
*valueOut = jit::JitOptions.spectreObjectMitigations ? 1 : 0;
break;
case JSJITCOMPILER_SPECTRE_STRING_MITIGATIONS:
*valueOut = jit::JitOptions.spectreStringMitigations ? 1 : 0;
break;
case JSJITCOMPILER_SPECTRE_VALUE_MASKING:
*valueOut = jit::JitOptions.spectreValueMasking ? 1 : 0;
break;
case JSJITCOMPILER_SPECTRE_JIT_TO_CXX_CALLS:
*valueOut = jit::JitOptions.spectreJitToCxxCalls ? 1 : 0;
break;
case JSJITCOMPILER_WATCHTOWER_MEGAMORPHIC:
*valueOut = jit::JitOptions.enableWatchtowerMegamorphic ? 1 : 0;
break;

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

@ -44,6 +44,7 @@ support-files =
shadow_realm_module.js
prefs =
javascript.options.weakrefs=true
javascript.options.spectre.disable_for_isolated_content=true
javascript.options.experimental.ergonomic_brand_checks=true
javascript.options.experimental.top_level_await=true
javascript.options.experimental.enable_change_array_by_copy=false
@ -134,4 +135,5 @@ skip-if = (debug == false)
skip-if = !nightly_build
[test_shadowRealm.html]
[test_shadowRealm_worker.html]
[test_spectre_mitigations.html]
skip-if = os == "android" # Fission situation on Android is more complicated.

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

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tests for Spectre mitigations</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>
add_task(async function() {
const { Cu } = SpecialPowers;
const options = Cu.getJSTestingFunctions().getJitCompilerOptions();
const testMitigation = function(name) {
let val = options[name];
ok(val === 0 || val === 1, "must be valid JitOption");
is(Boolean(val), !SpecialPowers.useRemoteSubframes, "must be enabled if Fission is disabled");
};
testMitigation("spectre.index-masking");
testMitigation("spectre.object-mitigations");
testMitigation("spectre.string-mitigations");
testMitigation("spectre.value-masking");
testMitigation("spectre.jit-to-cxx-calls");
});
</script>
</body>
</html>