summaryrefslogtreecommitdiff
path: root/deps/v8/src/wasm/wasm-features.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/wasm/wasm-features.h')
-rw-r--r--deps/v8/src/wasm/wasm-features.h57
1 files changed, 35 insertions, 22 deletions
diff --git a/deps/v8/src/wasm/wasm-features.h b/deps/v8/src/wasm/wasm-features.h
index 2c6ab0f85a..956982536d 100644
--- a/deps/v8/src/wasm/wasm-features.h
+++ b/deps/v8/src/wasm/wasm-features.h
@@ -17,37 +17,50 @@ namespace internal {
class Isolate;
namespace wasm {
-#define COMMA ,
-#define SPACE
-#define DECL_FIELD(feat, desc, val) bool feat = false;
-#define JUST_TRUE(feat, desc, val) true
-#define JUST_FALSE(feat, desc, val) false
-#define DECL_PARAM(feat, desc, val) bool p##feat
-#define DO_INIT(feat, desc, val) feat(p##feat)
+// This is an empty type to indicate the end of the {WasmFeatures} struct. We
+// use the {end_t} type there to avoid trailing commas that get generated by
+// the macro generators. We considered the following alternatives:
+// * Add "separators" to the {FOREACH_WASM_FEATURE_FLAGS} between entries. This
+// does not work when we want to have different kinds of flags, e.g. for
+// experimental, staging, and shipped features.
+// * Use initialization lists, e.g. construct {WasmFeatures} with
+// "WasmFeatures{true, true, ..., true,}". This solves the comma problem,
+// because trailing commas are allowed here. However, we cannot
+// default-initialize the fields of {WasmFeatures} anymore. This seems
+// error-prone, because default-constructed {WasmFeatures} structs are already
+// used in the code base.
+// * Avoid the use of {constexpr}. With that we would be more flexible with how
+// we generate {kAllWasmFeatures} and {kNoWasmFeatures}. These values may be
+// used in performance-critical code, however, e.g. in the decoder or in the
+// interpreter.
+struct end_t {};
// Enabled or detected features.
struct WasmFeatures {
- FOREACH_WASM_FEATURE(DECL_FIELD, SPACE)
+#define DECL_FIELD(feat, desc, val) bool feat = false;
+ FOREACH_WASM_FEATURE(DECL_FIELD)
+#undef DECL_FIELD
+ // Marker for the end of the list, see the comment at {end_t}.
+ end_t end_;
+#define DECL_PARAM(feat, desc, val) bool p##feat,
+#define DO_INIT(feat, desc, val) feat(p##feat),
+ explicit constexpr WasmFeatures(FOREACH_WASM_FEATURE(DECL_PARAM) end_t)
+ : FOREACH_WASM_FEATURE(DO_INIT) end_() {}
+#undef DECL_PARAM
+#undef DO_INIT
constexpr WasmFeatures() = default;
-
- explicit constexpr WasmFeatures(FOREACH_WASM_FEATURE(DECL_PARAM, COMMA))
- : FOREACH_WASM_FEATURE(DO_INIT, COMMA) {}
};
-static constexpr WasmFeatures kAllWasmFeatures{
- FOREACH_WASM_FEATURE(JUST_TRUE, COMMA)};
-
-static constexpr WasmFeatures kNoWasmFeatures{
- FOREACH_WASM_FEATURE(JUST_FALSE, COMMA)};
-
+#define JUST_TRUE(feat, desc, val) true,
+static constexpr WasmFeatures kAllWasmFeatures(
+ FOREACH_WASM_FEATURE(JUST_TRUE){});
#undef JUST_TRUE
+
+#define JUST_FALSE(feat, desc, val) false,
+static constexpr WasmFeatures kNoWasmFeatures(
+ FOREACH_WASM_FEATURE(JUST_FALSE){});
#undef JUST_FALSE
-#undef DECL_FIELD
-#undef DECL_PARAM
-#undef DO_INIT
-#undef COMMA
-#undef SPACE
static constexpr WasmFeatures kAsmjsWasmFeatures = kNoWasmFeatures;