diff options
-rw-r--r-- | src/tools/tool-options.h | 2 | ||||
-rw-r--r-- | src/wasm-binary.h | 1 | ||||
-rw-r--r-- | src/wasm-features.h | 11 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 4 | ||||
-rw-r--r-- | test/unit/test_features.py | 3 |
5 files changed, 19 insertions, 2 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 1f13063c5..016154252 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -68,6 +68,8 @@ struct ToolOptions : public Options { .addFeature(FeatureSet::TruncSat, "nontrapping float-to-int operations") .addFeature(FeatureSet::SIMD, "SIMD operations and types") .addFeature(FeatureSet::BulkMemory, "bulk memory operations") + .addFeature(FeatureSet::ExceptionHandling, + "exception handling operations") .add("--no-validation", "-n", "Disables validation, assumes inputs are correct", diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 6f159740c..9937bb897 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -399,6 +399,7 @@ extern const char* ExceptionHandlingFeature; extern const char* TruncSatFeature; extern const char* SignExtFeature; extern const char* SIMD128Feature; +extern const char* ExceptionHandlingFeature; enum Subsection { NameFunction = 1, diff --git a/src/wasm-features.h b/src/wasm-features.h index 6337f6af9..340ca86ae 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -31,7 +31,9 @@ struct FeatureSet { SIMD = 1 << 3, BulkMemory = 1 << 4, SignExt = 1 << 5, - All = Atomics | MutableGlobals | TruncSat | SIMD | BulkMemory | SignExt + ExceptionHandling = 1 << 6, + All = Atomics | MutableGlobals | TruncSat | SIMD | BulkMemory | SignExt | + ExceptionHandling }; static std::string toString(Feature f) { @@ -48,6 +50,8 @@ struct FeatureSet { return "bulk-memory"; case SignExt: return "sign-ext"; + case ExceptionHandling: + return "exception-handling"; default: WASM_UNREACHABLE(); } @@ -64,6 +68,7 @@ struct FeatureSet { bool hasSIMD() const { return features & SIMD; } bool hasBulkMemory() const { return features & BulkMemory; } bool hasSignExt() const { return features & SignExt; } + bool hasExceptionHandling() const { return features & ExceptionHandling; } bool hasAll() const { return features & All; } void makeMVP() { features = MVP; } @@ -76,6 +81,7 @@ struct FeatureSet { void setSIMD(bool v = true) { set(SIMD, v); } void setBulkMemory(bool v = true) { set(BulkMemory, v); } void setSignExt(bool v = true) { set(SignExt, v); } + void setExceptionHandling(bool v = true) { set(ExceptionHandling, v); } void setAll(bool v = true) { features = v ? All : MVP; } void enable(const FeatureSet& other) { features |= other.features; } @@ -90,6 +96,9 @@ struct FeatureSet { if (hasBulkMemory()) { f(BulkMemory); } + if (hasExceptionHandling()) { + f(ExceptionHandling); + } if (hasMutableGlobals()) { f(MutableGlobals); } diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 81020cf75..a29665a15 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -647,6 +647,8 @@ void WasmBinaryWriter::writeFeaturesSection() { return "bulk-memory"; case FeatureSet::SignExt: return "sign-ext"; + case FeatureSet::ExceptionHandling: + return "exception-handling"; default: WASM_UNREACHABLE(); } @@ -2079,7 +2081,7 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { } else if (name == BinaryConsts::UserSections::BulkMemoryFeature) { wasm.features.setBulkMemory(); } else if (name == BinaryConsts::UserSections::ExceptionHandlingFeature) { - WASM_UNREACHABLE(); // TODO: exception handling + wasm.features.setExceptionHandling(); } else if (name == BinaryConsts::UserSections::TruncSatFeature) { wasm.features.setTruncSat(); } else if (name == BinaryConsts::UserSections::SignExtFeature) { diff --git a/test/unit/test_features.py b/test/unit/test_features.py index 8764bef97..6156191a2 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -24,6 +24,9 @@ class FeatureValidationTest(BinaryenTestCase): def check_bulk_mem(self, module, error): self.check_feature(module, error, '--enable-bulk-memory') + def check_exception_handling(self, module, error): + self.check_feature(module, error, '--enable-exception-handling') + def test_v128_signature(self): module = ''' (module |