diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-11 03:04:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 18:04:17 -0700 |
commit | 192757772adce7568fc1f3f3e733a4263b6392c6 (patch) | |
tree | 922fec8709cf9008d239a1fcbce7280e6ab46deb /src/wasm/wasm-validator.cpp | |
parent | cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595 (diff) | |
download | binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.gz binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.tar.bz2 binaryen-192757772adce7568fc1f3f3e733a4263b6392c6.zip |
Add anyref feature and type (#3109)
Adds `anyref` type, which is enabled by a new feature `--enable-anyref`. This type is primarily used for testing that passes correctly handle subtype relationships so that the codebase will continue to be prepared for future subtyping. Since `--enable-anyref` is meaningless without also using `--enable-reference-types`, this PR also makes it a validation error to pass only the former (and similarly makes it a validation error to enable exception handling without enabling reference types).
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index c6d679a24..80c54abed 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1363,6 +1363,7 @@ void FunctionValidator::validateMemBytes(uint8_t bytes, case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: WASM_UNREACHABLE("unexpected type"); } @@ -2176,6 +2177,7 @@ void FunctionValidator::validateAlignment( case Type::funcref: case Type::externref: case Type::exnref: + case Type::anyref: case Type::none: WASM_UNREACHABLE("invalid type"); } @@ -2475,6 +2477,20 @@ static void validateModule(Module& module, ValidationInfo& info) { } } +static void validateFeatures(Module& module, ValidationInfo& info) { + if (module.features.hasAnyref()) { + info.shouldBeTrue(module.features.hasReferenceTypes(), + module.features, + "--enable-anyref requires --enable-reference-types"); + } + if (module.features.hasExceptionHandling()) { // implies exnref + info.shouldBeTrue( + module.features.hasReferenceTypes(), + module.features, + "--enable-exception-handling requires --enable-reference-types"); + } +} + // TODO: If we want the validator to be part of libwasm rather than libpasses, // then Using PassRunner::getPassDebug causes a circular dependence. We should // fix that, perhaps by moving some of the pass infrastructure into libsupport. @@ -2495,6 +2511,7 @@ bool WasmValidator::validate(Module& module, Flags flags) { validateTable(module, info); validateEvents(module, info); validateModule(module, info); + validateFeatures(module, info); } // validate additional internal IR details when in pass-debug mode if (PassRunner::getPassDebug()) { |