Merge mozilla-central to autoland. a=merge CLOSED TREE
[gecko.git] / js / public / WasmFeatures.h
blob7e30a748d2a5cd22181d8b6e567f76bf496ca1bd
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/. */
7 #ifndef js_WasmFeatures_h
8 #define js_WasmFeatures_h
10 // [SMDOC] WebAssembly feature gating
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.
16 // # Adding a feature
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.
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_GC
46 # define WASM_GC_ENABLED 1
47 #else
48 # define WASM_GC_ENABLED 0
49 #endif
50 #ifdef ENABLE_WASM_MEMORY64
51 # define WASM_MEMORY64_ENABLED 1
52 #else
53 # define WASM_MEMORY64_ENABLED 0
54 #endif
55 #ifdef ENABLE_WASM_MEMORY_CONTROL
56 # define WASM_MEMORY_CONTROL_ENABLED 1
57 #else
58 # define WASM_MEMORY_CONTROL_ENABLED 0
59 #endif
60 #ifdef ENABLE_WASM_TAIL_CALLS
61 # define WASM_TAIL_CALLS_ENABLED 1
62 #else
63 # define WASM_TAIL_CALLS_ENABLED 0
64 #endif
65 #ifdef ENABLE_WASM_MOZ_INTGEMM
66 # define WASM_MOZ_INTGEMM_ENABLED 1
67 #else
68 # define WASM_MOZ_INTGEMM_ENABLED 0
69 #endif
70 #ifdef ENABLE_WASM_MULTI_MEMORY
71 # define WASM_MULTI_MEMORY_ENABLED 1
72 #else
73 # define WASM_MULTI_MEMORY_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
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 */ Gc, \
94 /* lower case name */ gc, \
95 /* compile predicate */ WASM_GC_ENABLED, \
96 /* compiler predicate */ AnyCompilerAvailable(cx), \
97 /* flag predicate */ true, \
98 /* flag force enable */ false, \
99 /* flag fuzz enable */ false, \
100 /* preference name */ gc) \
101 FEATURE( \
102 /* capitalized name */ JSStringBuiltins, \
103 /* lower case name */ jsStringBuiltins, \
104 /* compile predicate */ WASM_JS_STRING_BUILTINS_ENABLED, \
105 /* compiler predicate */ AnyCompilerAvailable(cx), \
106 /* flag predicate */ true, \
107 /* flag force enable */ false, \
108 /* flag fuzz enable */ true, \
109 /* preference name */ js_string_builtins) \
110 FEATURE( \
111 /* capitalized name */ RelaxedSimd, \
112 /* lower case name */ v128Relaxed, \
113 /* compile predicate */ WASM_RELAXED_SIMD_ENABLED, \
114 /* compiler predicate */ AnyCompilerAvailable(cx), \
115 /* flag predicate */ js::jit::JitSupportsWasmSimd(), \
116 /* flag force enable */ false, \
117 /* flag fuzz enable */ true, \
118 /* preference name */ relaxed_simd) \
119 FEATURE( \
120 /* capitalized name */ Memory64, \
121 /* lower case name */ memory64, \
122 /* compile predicate */ WASM_MEMORY64_ENABLED, \
123 /* compiler predicate */ AnyCompilerAvailable(cx), \
124 /* flag predicate */ true, \
125 /* flag force enable */ false, \
126 /* flag fuzz enable */ true, \
127 /* preference name */ memory64) \
128 FEATURE( \
129 /* capitalized name */ MemoryControl, \
130 /* lower case name */ memoryControl, \
131 /* compile predicate */ WASM_MEMORY_CONTROL_ENABLED, \
132 /* compiler predicate */ AnyCompilerAvailable(cx), \
133 /* flag predicate */ true, \
134 /* flag force enable */ false, \
135 /* flag fuzz enable */ false, \
136 /* preference name */ memory_control) \
137 FEATURE( \
138 /* capitalized name */ MultiMemory, \
139 /* lower case name */ multiMemory, \
140 /* compile predicate */ WASM_MULTI_MEMORY_ENABLED, \
141 /* compiler predicate */ AnyCompilerAvailable(cx), \
142 /* flag predicate */ true, \
143 /* flag force enable */ false, \
144 /* flag fuzz enable */ true, \
145 /* preference name */ multi_memory) \
146 FEATURE( \
147 /* capitalized name */ TailCalls, \
148 /* lower case name */ tailCalls, \
149 /* compile predicate */ WASM_TAIL_CALLS_ENABLED, \
150 /* compiler predicate */ AnyCompilerAvailable(cx), \
151 /* flag predicate */ true, \
152 /* flag force enable */ false, \
153 /* flag fuzz enable */ true, \
154 /* preference name */ tail_calls) \
155 FEATURE( \
156 /* capitalized name */ MozIntGemm, \
157 /* lower case name */ mozIntGemm, \
158 /* compile predicate */ WASM_MOZ_INTGEMM_ENABLED, \
159 /* compiler predicate */ AnyCompilerAvailable(cx), \
160 /* flag predicate */ IsSimdPrivilegedContext(cx), \
161 /* flag force enable */ false, \
162 /* flag fuzz enable */ false, \
163 /* preference name */ moz_intgemm) \
164 FEATURE( \
165 /* capitalized name */ TestSerialization, \
166 /* lower case name */ testSerialization, \
167 /* compile predicate */ 1, \
168 /* compiler predicate */ IonAvailable(cx), \
169 /* flag predicate */ true, \
170 /* flag force enable */ false, \
171 /* flag fuzz enable */ false, \
172 /* preference name */ test_serialization)
174 // clang-format on
176 #endif // js_WasmFeatures_h