summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/tool-options.h1
-rw-r--r--src/wasm-binary.h1
-rw-r--r--src/wasm-features.h9
-rw-r--r--src/wasm/wasm-binary.cpp4
-rw-r--r--src/wasm/wasm-type.cpp5
-rw-r--r--src/wasm/wasm.cpp1
-rw-r--r--test/binaryen.js/kitchen-sink.js.txt2
-rw-r--r--test/example/c-api-kitchen-sink.txt2
-rw-r--r--test/lit/help/wasm-as.test4
-rw-r--r--test/lit/help/wasm-ctor-eval.test4
-rw-r--r--test/lit/help/wasm-dis.test4
-rw-r--r--test/lit/help/wasm-emscripten-finalize.test4
-rw-r--r--test/lit/help/wasm-metadce.test4
-rw-r--r--test/lit/help/wasm-opt.test4
-rw-r--r--test/lit/help/wasm-reduce.test4
-rw-r--r--test/lit/help/wasm-split.test4
-rw-r--r--test/lit/help/wasm2js.test4
-rw-r--r--test/lit/strings.wast2
-rw-r--r--test/passes/strip-target-features_roundtrip_print-features_all-features.txt1
-rw-r--r--test/unit/test_features.py1
20 files changed, 60 insertions, 5 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
diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt
index b45894c7a..36b5c6749 100644
--- a/test/binaryen.js/kitchen-sink.js.txt
+++ b/test/binaryen.js/kitchen-sink.js.txt
@@ -44,7 +44,7 @@ Features.Memory64: 2048
Features.TypedFunctionReferences: 4096
Features.RelaxedSIMD: 16384
Features.ExtendedConst: 32768
-Features.All: 57343
+Features.All: 122879
InvalidId: 0
BlockId: 1
IfId: 2
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 49a3d74b1..3393022ae 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -28,7 +28,7 @@ BinaryenFeatureMemory64: 2048
BinaryenFeatureTypedFunctionReferences: 4096
BinaryenFeatureRelaxedSIMD: 16384
BinaryenFeatureExtendedConst: 32768
-BinaryenFeatureAll: 57343
+BinaryenFeatureAll: 122879
(f32.neg
(f32.const -33.61199951171875)
)
diff --git a/test/lit/help/wasm-as.test b/test/lit/help/wasm-as.test
index 50ab57355..35c621056 100644
--- a/test/lit/help/wasm-as.test
+++ b/test/lit/help/wasm-as.test
@@ -104,6 +104,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-ctor-eval.test b/test/lit/help/wasm-ctor-eval.test
index 518d536e3..43e551451 100644
--- a/test/lit/help/wasm-ctor-eval.test
+++ b/test/lit/help/wasm-ctor-eval.test
@@ -108,6 +108,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-dis.test b/test/lit/help/wasm-dis.test
index c2b4af271..195554c65 100644
--- a/test/lit/help/wasm-dis.test
+++ b/test/lit/help/wasm-dis.test
@@ -97,6 +97,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-emscripten-finalize.test b/test/lit/help/wasm-emscripten-finalize.test
index 2f9ae3a31..5079f192f 100644
--- a/test/lit/help/wasm-emscripten-finalize.test
+++ b/test/lit/help/wasm-emscripten-finalize.test
@@ -147,6 +147,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test
index 99a830065..8c49e3536 100644
--- a/test/lit/help/wasm-metadce.test
+++ b/test/lit/help/wasm-metadce.test
@@ -145,6 +145,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 66ac66f91..e0444ae01 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -610,6 +610,10 @@
;; CHECK-NEXT: --disable-extended-const Disable extended const
;; CHECK-NEXT: expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes
;; CHECK-NEXT: inputs are correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-reduce.test b/test/lit/help/wasm-reduce.test
index 2360ed508..11cf0e45f 100644
--- a/test/lit/help/wasm-reduce.test
+++ b/test/lit/help/wasm-reduce.test
@@ -133,6 +133,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm-split.test b/test/lit/help/wasm-split.test
index f79d1c0c7..05a7df910 100644
--- a/test/lit/help/wasm-split.test
+++ b/test/lit/help/wasm-split.test
@@ -191,6 +191,10 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-extended-const Disable extended const expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes inputs are
;; CHECK-NEXT: correct
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index 917b8750a..5d2d29e87 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -569,6 +569,10 @@
;; CHECK-NEXT: --disable-extended-const Disable extended const
;; CHECK-NEXT: expressions
;; CHECK-NEXT:
+;; CHECK-NEXT: --enable-strings Enable strings
+;; CHECK-NEXT:
+;; CHECK-NEXT: --disable-strings Disable strings
+;; CHECK-NEXT:
;; CHECK-NEXT: --no-validation,-n Disables validation, assumes
;; CHECK-NEXT: inputs are correct
;; CHECK-NEXT:
diff --git a/test/lit/strings.wast b/test/lit/strings.wast
index 4e3269690..c4b6f39af 100644
--- a/test/lit/strings.wast
+++ b/test/lit/strings.wast
@@ -2,7 +2,7 @@
;; Check that string types are emitted properly in the binary format.
-;; RUN: foreach %s %t wasm-opt -all --roundtrip -S -o - | filecheck %s
+;; RUN: foreach %s %t wasm-opt --enable-strings --enable-reference-types --roundtrip -S -o - | filecheck %s
(module
;; CHECK: (func $foo (param $a stringref) (param $b stringview_wtf8) (param $c stringview_wtf16) (param $d stringview_iter) (param $e stringref) (param $f stringview_wtf8) (param $g stringview_wtf16) (param $h stringview_iter) (param $i (ref string)) (param $j (ref stringview_wtf8)) (param $k (ref stringview_wtf16)) (param $l (ref stringview_iter))
diff --git a/test/passes/strip-target-features_roundtrip_print-features_all-features.txt b/test/passes/strip-target-features_roundtrip_print-features_all-features.txt
index e93805cf5..fa7221683 100644
--- a/test/passes/strip-target-features_roundtrip_print-features_all-features.txt
+++ b/test/passes/strip-target-features_roundtrip_print-features_all-features.txt
@@ -13,6 +13,7 @@
--enable-typed-function-references
--enable-relaxed-simd
--enable-extended-const
+--enable-strings
(module
(type $none_=>_v128_anyref (func (result v128 anyref)))
(func $foo (result v128 anyref)
diff --git a/test/unit/test_features.py b/test/unit/test_features.py
index 53c2263f3..5c22886fb 100644
--- a/test/unit/test_features.py
+++ b/test/unit/test_features.py
@@ -398,4 +398,5 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase):
'--enable-typed-function-references',
'--enable-relaxed-simd',
'--enable-extended-const',
+ '--enable-strings',
], p2.stdout.splitlines())