diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-24 12:02:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 12:02:09 +0200 |
commit | e9e1b2ff00aeb05aaeb57af3811add267dc25323 (patch) | |
tree | 4e19032813858b2e650f0cda46fe9fa227aa0a7f /src/wasm/wasm-validator.cpp | |
parent | a42423fafa8cf731c69303ddc0acbe80c890e0ab (diff) | |
download | binaryen-e9e1b2ff00aeb05aaeb57af3811add267dc25323.tar.gz binaryen-e9e1b2ff00aeb05aaeb57af3811add267dc25323.tar.bz2 binaryen-e9e1b2ff00aeb05aaeb57af3811add267dc25323.zip |
GC: Add i31 instructions (#3154)
Adds the `i31.new` and `i31.get_s/u` instructions for creating and working with `i31ref` typed values. Does not include fuzzer integration just yet because the fuzzer expects that trivial values it creates are suitable in global initializers, which is not the case for trivial `i31ref` expressions.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index c1df740df..d55f60009 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -337,6 +337,8 @@ public: void visitBrOnExn(BrOnExn* curr); void visitTupleMake(TupleMake* curr); void visitTupleExtract(TupleExtract* curr); + void visitI31New(I31New* curr); + void visitI31Get(I31Get* curr); void visitFunction(Function* curr); // helpers @@ -2109,6 +2111,26 @@ void FunctionValidator::visitTupleExtract(TupleExtract* curr) { } } +void FunctionValidator::visitI31New(I31New* curr) { + shouldBeTrue( + getModule()->features.hasGC(), curr, "i31.new requires gc to be enabled"); + shouldBeSubTypeOrFirstIsUnreachable(curr->value->type, + Type::i32, + curr->value, + "i31.new's argument should be i32"); +} + +void FunctionValidator::visitI31Get(I31Get* curr) { + shouldBeTrue(getModule()->features.hasGC(), + curr, + "i31.get_s/u requires gc to be enabled"); + shouldBeSubTypeOrFirstIsUnreachable( + curr->i31->type, + Type::i31ref, + curr->i31, + "i31.get_s/u's argument should be i31ref"); +} + void FunctionValidator::visitFunction(Function* curr) { if (curr->sig.results.isTuple()) { shouldBeTrue(getModule()->features.hasMultivalue(), |