diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/tool-options.h | 1 | ||||
-rw-r--r-- | src/wasm-binary.h | 1 | ||||
-rw-r--r-- | src/wasm-features.h | 9 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 5 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 1 |
6 files changed, 19 insertions, 2 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index c15291c8d..320cd6ba1 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -94,6 +94,7 @@ struct ToolOptions : public Options { .addFeature(FeatureSet::GCNNLocals, "GC non-null locals") .addFeature(FeatureSet::RelaxedSIMD, "relaxed SIMD") .addFeature(FeatureSet::ExtendedConst, "extended const expressions") + .addFeature(FeatureSet::Strings, "strings") .add("--no-validation", "-n", "Disables validation, assumes inputs are correct", diff --git a/src/wasm-binary.h b/src/wasm-binary.h index a5c6d0a46..c7ac7e7b7 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -437,6 +437,7 @@ extern const char* Memory64Feature; extern const char* TypedFunctionReferencesFeature; extern const char* RelaxedSIMDFeature; extern const char* ExtendedConstFeature; +extern const char* StringsFeature; enum Subsection { NameModule = 0, diff --git a/src/wasm-features.h b/src/wasm-features.h index 64d831ecc..10e4ac4c7 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -43,11 +43,12 @@ struct FeatureSet { GCNNLocals = 1 << 13, RelaxedSIMD = 1 << 14, ExtendedConst = 1 << 15, + Strings = 1 << 16, // GCNNLocals are opt-in: merely asking for "All" does not apply them. To // get all possible values use AllPossible. See setAll() below for more // details. - All = ((1 << 16) - 1) & ~GCNNLocals, - AllPossible = (1 << 16) - 1, + All = ((1 << 17) - 1) & ~GCNNLocals, + AllPossible = (1 << 17) - 1, }; static std::string toString(Feature f) { @@ -84,6 +85,8 @@ struct FeatureSet { return "relaxed-simd"; case ExtendedConst: return "extended-const"; + case Strings: + return "strings"; default: WASM_UNREACHABLE("unexpected feature"); } @@ -130,6 +133,7 @@ struct FeatureSet { bool hasGCNNLocals() const { return (features & GCNNLocals) != 0; } bool hasRelaxedSIMD() const { return (features & RelaxedSIMD) != 0; } bool hasExtendedConst() const { return (features & ExtendedConst) != 0; } + bool hasStrings() const { return (features & Strings) != 0; } bool hasAll() const { return (features & AllPossible) != 0; } void set(FeatureSet f, bool v = true) { @@ -153,6 +157,7 @@ struct FeatureSet { void setGCNNLocals(bool v = true) { set(GCNNLocals, v); } void setRelaxedSIMD(bool v = true) { set(RelaxedSIMD, v); } void setExtendedConst(bool v = true) { set(ExtendedConst, v); } + void setStrings(bool v = true) { set(Strings, v); } void setMVP() { features = MVP; } void setAll() { // Do not set GCNNLocals, which forces the user to opt in to that feature diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index f087e3e4b..263f905fb 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1101,6 +1101,8 @@ void WasmBinaryWriter::writeFeaturesSection() { return BinaryConsts::UserSections::RelaxedSIMDFeature; case FeatureSet::ExtendedConst: return BinaryConsts::UserSections::ExtendedConstFeature; + case FeatureSet::Strings: + return BinaryConsts::UserSections::StringsFeature; default: WASM_UNREACHABLE("unexpected feature flag"); } @@ -3416,6 +3418,8 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { feature = FeatureSet::RelaxedSIMD; } else if (name == BinaryConsts::UserSections::ExtendedConstFeature) { feature = FeatureSet::ExtendedConst; + } else if (name == BinaryConsts::UserSections::StringsFeature) { + feature = FeatureSet::Strings; } else { // Silently ignore unknown features (this may be and old binaryen running // on a new wasm). diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 85f3f0cfc..b13b1ecd7 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1165,6 +1165,11 @@ FeatureSet Type::getFeatures() const { case HeapType::BasicHeapType::i31: case HeapType::BasicHeapType::data: return FeatureSet::ReferenceTypes | FeatureSet::GC; + case HeapType::string: + case HeapType::stringview_wtf8: + case HeapType::stringview_wtf16: + case HeapType::stringview_iter: + return FeatureSet::ReferenceTypes | FeatureSet::Strings; default: {} } } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 428e5093c..86072a880 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -50,6 +50,7 @@ const char* Memory64Feature = "memory64"; const char* TypedFunctionReferencesFeature = "typed-function-references"; const char* RelaxedSIMDFeature = "relaxed-simd"; const char* ExtendedConstFeature = "extended-const"; +const char* StringsFeature = "strings"; } // namespace UserSections } // namespace BinaryConsts |