diff options
author | Alon Zakai <azakai@google.com> | 2021-06-15 11:14:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 11:14:42 -0700 |
commit | 9d279c08b9f37b6cf2c5a5fac564eee9ea4fb927 (patch) | |
tree | 04ee164199e76d1a09ae4d12c9da820244a297a7 /src/wasm-features.h | |
parent | e0a8f40f65b178556f6fcbed778923a36dca64e3 (diff) | |
download | binaryen-9d279c08b9f37b6cf2c5a5fac564eee9ea4fb927.tar.gz binaryen-9d279c08b9f37b6cf2c5a5fac564eee9ea4fb927.tar.bz2 binaryen-9d279c08b9f37b6cf2c5a5fac564eee9ea4fb927.zip |
[Wasm GC] Add experimental support for non-nullable locals (#3932)
This adds a new feature flag, GCNNLocals that enables support for
non-nullable locals. No validation is applied to check that they are
actually assigned before their use yet - this just allows experimentation
to begin.
This feature is not enabled by default even with -all. If we enabled it,
then it would take effect in most of our tests and likely confuse current
users as well. Instead, the flag must be opted in explicitly using
--enable-gc-nn-locals. That is, this is an experimental feature flag,
and as such must be explicitly enabled. (Once the spec stabilizes,
we will remove the feature anyhow when we implement the
final status of non-nullability. )
Diffstat (limited to 'src/wasm-features.h')
-rw-r--r-- | src/wasm-features.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/wasm-features.h b/src/wasm-features.h index 237dc7757..e28dcf4d1 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -39,7 +39,9 @@ struct FeatureSet { GC = 1 << 10, Memory64 = 1 << 11, TypedFunctionReferences = 1 << 12, - All = (1 << 13) - 1 + // TODO: Remove this feature when the wasm spec stabilizes. + GCNNLocals = 1 << 13, + All = (1 << 14) - 1 }; static std::string toString(Feature f) { @@ -70,6 +72,8 @@ struct FeatureSet { return "memory64"; case TypedFunctionReferences: return "typed-function-references"; + case GCNNLocals: + return "gc-nn-locals"; default: WASM_UNREACHABLE("unexpected feature"); } @@ -113,9 +117,9 @@ struct FeatureSet { bool hasTypedFunctionReferences() const { return (features & TypedFunctionReferences) != 0; } + bool hasGCNNLocals() const { return (features & GCNNLocals) != 0; } bool hasAll() const { return (features & All) != 0; } - void makeMVP() { features = MVP; } void set(FeatureSet f, bool v = true) { features = v ? (features | f) : (features & ~f); } @@ -134,7 +138,22 @@ struct FeatureSet { void setTypedFunctionReferences(bool v = true) { set(TypedFunctionReferences, v); } - void setAll(bool v = true) { features = v ? All : MVP; } + void setGCNNLocals(bool v = true) { set(GCNNLocals, v); } + void setMVP() { features = MVP; } + void setAll() { + // Do not set GCNNLocals, which forces the user to opt in to that feature + // explicitly. That is, wasm-opt -all will enable GC but *not* enable + // non-nullable locals. To get them, do wasm-opt -all --enable-gc-nn-locals + // FIXME: When the wasm spec stabilizes, this feature will go away, as the + // non-nullable locals experiment will either become the standard, + // or it will go away. + // Leave the old GCNNLocals value unmodified. This makes things like + // --enable-gc-nn-locals -all work (that is, if we enable the feature, + // then -all does not disable it; it simply does not enable it by itself). + auto oldGCNNLocals = hasGCNNLocals(); + features = All; + setGCNNLocals(oldGCNNLocals); + } void enable(const FeatureSet& other) { features |= other.features; } void disable(const FeatureSet& other) { |