summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-11 03:04:17 +0200
committerGitHub <noreply@github.com>2020-09-10 18:04:17 -0700
commit192757772adce7568fc1f3f3e733a4263b6392c6 (patch)
tree922fec8709cf9008d239a1fcbce7280e6ab46deb /src/wasm-binary.h
parentcd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595 (diff)
downloadbinaryen-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-binary.h')
-rw-r--r--src/wasm-binary.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 865a882df..33f78ce7f 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -347,6 +347,8 @@ enum EncodedType {
funcref = -0x10, // 0x70
// opaque host reference type
externref = -0x11, // 0x6f
+ // any reference type
+ anyref = -0x12, // 0x6e
// exception reference type
exnref = -0x18, // 0x68
// func_type form
@@ -358,6 +360,7 @@ enum EncodedType {
enum EncodedHeapType {
func = -0x10, // 0x70
extern_ = -0x11, // 0x6f
+ any = -0x12, // 0x6e
exn = -0x18, // 0x68
};
@@ -380,6 +383,7 @@ extern const char* ExceptionHandlingFeature;
extern const char* TailCallFeature;
extern const char* ReferenceTypesFeature;
extern const char* MultivalueFeature;
+extern const char* AnyrefFeature;
enum Subsection {
NameFunction = 1,
@@ -975,6 +979,9 @@ inline S32LEB binaryType(Type type) {
case Type::exnref:
ret = BinaryConsts::EncodedType::exnref;
break;
+ case Type::anyref:
+ ret = BinaryConsts::EncodedType::anyref;
+ break;
case Type::unreachable:
WASM_UNREACHABLE("unexpected type");
}
@@ -994,6 +1001,8 @@ inline S32LEB binaryHeapType(HeapType type) {
ret = BinaryConsts::EncodedHeapType::exn;
break;
case HeapType::AnyKind:
+ ret = BinaryConsts::EncodedHeapType::any;
+ break;
case HeapType::EqKind:
case HeapType::I31Kind:
case HeapType::SignatureKind: