| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef js_WasmFeatures_h |
| 8 |
#define js_WasmFeatures_h |
| 9 |
|
| 10 |
// [SMDOC] WebAssembly feature gating |
| 11 |
// |
| 12 |
// Declarative listing of WebAssembly optional features. This macro is used to |
| 13 |
// generate most of the feature gating code in a centralized manner. See |
| 14 |
// 'Adding a feature' below for the exact steps needed to add a new feature. |
| 15 |
// |
| 16 |
// # Adding a feature |
| 17 |
// |
| 18 |
// 1. Add a configure switch for the feature in js/moz.configure |
| 19 |
// 2. Add a WASM_FEATURE_ENABLED #define below |
| 20 |
// 3. Add the feature to JS_FOR_WASM_FEATURES |
| 21 |
// a. capitalized name: Used for naming of feature functions, including |
| 22 |
// wasmFeatureEnabled shell function. |
| 23 |
// b. lower case name: Used for naming of feature flag variables, including |
| 24 |
// in wasm::FeatureArgs. |
| 25 |
// c. compile predicate: Set to WASM_FEATURE_ENABLED |
| 26 |
// d. compiler predicate: Expression of compilers that this feature depends |
| 27 |
// on. |
| 28 |
// e. flag predicate: Expression used to predicate enablement of feature |
| 29 |
// flag. Useful for disabling a feature when dependent feature is not |
| 30 |
// enabled or if we are fuzzing. |
| 31 |
// f. preference name: The stem of the browser preference. Will be expanded |
| 32 |
// to `javascript.options.wasm-FEATURE`. |
| 33 |
// 4. Add the preference to module/libpref/init/StaticPrefList.yaml |
| 34 |
// a. Set `set_spidermonkey_pref: startup` |
| 35 |
// b. Set value to 'true' for default features, @IS_NIGHTLY_BUILD@ for |
| 36 |
// tentative features, and 'false' for experimental features. |
| 37 |
// 5. [fuzzing] Add the feature to gluesmith/src/lib.rs, if wasm-smith has |
| 38 |
// support for it. |
| 39 |
|
| 40 |
#ifdef ENABLE_WASM_RELAXED_SIMD |
| 41 |
# define WASM_RELAXED_SIMD_ENABLED 1 |
| 42 |
#else |
| 43 |
# define WASM_RELAXED_SIMD_ENABLED 0 |
| 44 |
#endif |
| 45 |
#ifdef ENABLE_WASM_MEMORY64 |
| 46 |
# define WASM_MEMORY64_ENABLED 1 |
| 47 |
#else |
| 48 |
# define WASM_MEMORY64_ENABLED 0 |
| 49 |
#endif |
| 50 |
#ifdef ENABLE_WASM_MEMORY_CONTROL |
| 51 |
# define WASM_MEMORY_CONTROL_ENABLED 1 |
| 52 |
#else |
| 53 |
# define WASM_MEMORY_CONTROL_ENABLED 0 |
| 54 |
#endif |
| 55 |
#ifdef ENABLE_WASM_JSPI |
| 56 |
# define WASM_JSPI_ENABLED 1 |
| 57 |
#else |
| 58 |
# define WASM_JSPI_ENABLED 0 |
| 59 |
#endif |
| 60 |
#ifdef ENABLE_WASM_MOZ_INTGEMM |
| 61 |
# define WASM_MOZ_INTGEMM_ENABLED 1 |
| 62 |
#else |
| 63 |
# define WASM_MOZ_INTGEMM_ENABLED 0 |
| 64 |
#endif |
| 65 |
#ifdef ENABLE_WASM_MULTI_MEMORY |
| 66 |
# define WASM_MULTI_MEMORY_ENABLED 1 |
| 67 |
#else |
| 68 |
# define WASM_MULTI_MEMORY_ENABLED 0 |
| 69 |
#endif |
| 70 |
#ifdef ENABLE_WASM_BRANCH_HINTING |
| 71 |
# define WASM_BRANCH_HINTING_ENABLED 1 |
| 72 |
#else |
| 73 |
# define WASM_BRANCH_HINTING_ENABLED 0 |
| 74 |
#endif |
| 75 |
#ifdef ENABLE_WASM_JS_STRING_BUILTINS |
| 76 |
# define WASM_JS_STRING_BUILTINS_ENABLED 1 |
| 77 |
#else |
| 78 |
# define WASM_JS_STRING_BUILTINS_ENABLED 0 |
| 79 |
#endif |
| 80 |
|
| 81 |
// clang-format off |
| 82 |
#define JS_FOR_WASM_FEATURES(FEATURE) \ |
| 83 |
FEATURE( \ |
| 84 |
/* capitalized name */ ExnRef, \ |
| 85 |
/* lower case name */ exnref, \ |
| 86 |
/* compile predicate */ true, \ |
| 87 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 88 |
/* flag predicate */ true, \ |
| 89 |
/* flag force enable */ false, \ |
| 90 |
/* flag fuzz enable */ true, \ |
| 91 |
/* preference name */ exnref) \ |
| 92 |
FEATURE( \ |
| 93 |
/* capitalized name */ JSStringBuiltins, \ |
| 94 |
/* lower case name */ jsStringBuiltins, \ |
| 95 |
/* compile predicate */ WASM_JS_STRING_BUILTINS_ENABLED, \ |
| 96 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 97 |
/* flag predicate */ true, \ |
| 98 |
/* flag force enable */ false, \ |
| 99 |
/* flag fuzz enable */ true, \ |
| 100 |
/* preference name */ js_string_builtins) \ |
| 101 |
FEATURE( \ |
| 102 |
/* capitalized name */ RelaxedSimd, \ |
| 103 |
/* lower case name */ v128Relaxed, \ |
| 104 |
/* compile predicate */ WASM_RELAXED_SIMD_ENABLED, \ |
| 105 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 106 |
/* flag predicate */ js::jit::JitSupportsWasmSimd(), \ |
| 107 |
/* flag force enable */ false, \ |
| 108 |
/* flag fuzz enable */ true, \ |
| 109 |
/* preference name */ relaxed_simd) \ |
| 110 |
FEATURE( \ |
| 111 |
/* capitalized name */ Memory64, \ |
| 112 |
/* lower case name */ memory64, \ |
| 113 |
/* compile predicate */ WASM_MEMORY64_ENABLED, \ |
| 114 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 115 |
/* flag predicate */ true, \ |
| 116 |
/* flag force enable */ false, \ |
| 117 |
/* flag fuzz enable */ true, \ |
| 118 |
/* preference name */ memory64) \ |
| 119 |
FEATURE( \ |
| 120 |
/* capitalized name */ MemoryControl, \ |
| 121 |
/* lower case name */ memoryControl, \ |
| 122 |
/* compile predicate */ WASM_MEMORY_CONTROL_ENABLED, \ |
| 123 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 124 |
/* flag predicate */ true, \ |
| 125 |
/* flag force enable */ false, \ |
| 126 |
/* flag fuzz enable */ false, \ |
| 127 |
/* preference name */ memory_control) \ |
| 128 |
FEATURE( \ |
| 129 |
/* capitalized name */ MultiMemory, \ |
| 130 |
/* lower case name */ multiMemory, \ |
| 131 |
/* compile predicate */ WASM_MULTI_MEMORY_ENABLED, \ |
| 132 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 133 |
/* flag predicate */ true, \ |
| 134 |
/* flag force enable */ false, \ |
| 135 |
/* flag fuzz enable */ true, \ |
| 136 |
/* preference name */ multi_memory) \ |
| 137 |
FEATURE( \ |
| 138 |
/* capitalized name */ JSPromiseIntegration, \ |
| 139 |
/* lower case name */ jsPromiseIntegration, \ |
| 140 |
/* compile predicate */ WASM_JSPI_ENABLED, \ |
| 141 |
/* compiler predicate */ IonPlatformSupport(), \ |
| 142 |
/* flag predicate */ true, \ |
| 143 |
/* flag force enable */ false, \ |
| 144 |
/* flag fuzz enable */ true, \ |
| 145 |
/* preference name */ js_promise_integration) \ |
| 146 |
FEATURE( \ |
| 147 |
/* capitalized name */ MozIntGemm, \ |
| 148 |
/* lower case name */ mozIntGemm, \ |
| 149 |
/* compile predicate */ WASM_MOZ_INTGEMM_ENABLED, \ |
| 150 |
/* compiler predicate */ AnyCompilerAvailable(cx), \ |
| 151 |
/* flag predicate */ IsPrivilegedContext(cx), \ |
| 152 |
/* flag force enable */ false, \ |
| 153 |
/* flag fuzz enable */ false, \ |
| 154 |
/* preference name */ moz_intgemm) \ |
| 155 |
FEATURE( \ |
| 156 |
/* capitalized name */ TestSerialization, \ |
| 157 |
/* lower case name */ testSerialization, \ |
| 158 |
/* compile predicate */ 1, \ |
| 159 |
/* compiler predicate */ IonAvailable(cx), \ |
| 160 |
/* flag predicate */ true, \ |
| 161 |
/* flag force enable */ false, \ |
| 162 |
/* flag fuzz enable */ false, \ |
| 163 |
/* preference name */ test_serialization) \ |
| 164 |
FEATURE( \ |
| 165 |
/* capitalized name */ BranchHinting, \ |
| 166 |
/* lower case name */ branchHinting, \ |
| 167 |
/* compile predicate */ WASM_BRANCH_HINTING_ENABLED, \ |
| 168 |
/* compiler predicate */ IonAvailable(cx), \ |
| 169 |
/* flag predicate */ true, \ |
| 170 |
/* flag force enable */ false, \ |
| 171 |
/* flag fuzz enable */ true, \ |
| 172 |
/* preference name */ branch_hinting) |
| 173 |
|
| 174 |
// clang-format on |
| 175 |
|
| 176 |
#endif // js_WasmFeatures_h |