diff options
author | Jay Phelps <hello@jayphelps.com> | 2019-08-20 15:27:58 -0500 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2019-08-20 13:27:58 -0700 |
commit | dce1fe8c16559437cae05c0dd782237474ca6082 (patch) | |
tree | 811e57a34951ad316072d7da8838461c25fbf465 /src/wasm/wasm-binary.cpp | |
parent | 86b8cf6c299d0189d7819cf5eabb1ea03d34ff3a (diff) | |
download | binaryen-dce1fe8c16559437cae05c0dd782237474ca6082.tar.gz binaryen-dce1fe8c16559437cae05c0dd782237474ca6082.tar.bz2 binaryen-dce1fe8c16559437cae05c0dd782237474ca6082.zip |
Add initial support for anyref as an opaque type (#2294)
Another round of trying to push upstream things from my fork.
This PR only adds support for anyref itself as an opaque type. It does NOT implement the full [reference types proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md)--so no table.get/set/grow/etc or ref.null, ref.func, etc.
Figured it was easier to review and merge as we go, especially if I did something fundamentally wrong.
***
I did put it under the `--enable-reference-types` flag as I imagine that even though this PR doesn't complete the full feature set, it probably is the right home. Lmk if not.
I'll also be adding a few github comments to places I want to point out/question.
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 7047b674e..d75973ab0 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -681,6 +681,8 @@ void WasmBinaryWriter::writeFeaturesSection() { return BinaryConsts::UserSections::ExceptionHandlingFeature; case FeatureSet::TailCall: return BinaryConsts::UserSections::TailCallFeature; + case FeatureSet::ReferenceTypes: + return BinaryConsts::UserSections::ReferenceTypesFeature; default: WASM_UNREACHABLE(); } @@ -1085,6 +1087,8 @@ Type WasmBinaryBuilder::getType() { return f64; case BinaryConsts::EncodedType::v128: return v128; + case BinaryConsts::EncodedType::anyref: + return anyref; case BinaryConsts::EncodedType::exnref: return exnref; default: { throwError("invalid wasm type: " + std::to_string(type)); } @@ -2167,6 +2171,8 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { wasm.features.setSIMD(); } else if (name == BinaryConsts::UserSections::TailCallFeature) { wasm.features.setTailCall(); + } else if (name == BinaryConsts::UserSections::ReferenceTypesFeature) { + wasm.features.setReferenceTypes(); } } } |