summaryrefslogtreecommitdiff
path: root/src/wasm/literal.cpp
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-29 21:24:02 +0200
committerGitHub <noreply@github.com>2020-09-29 21:24:02 +0200
commita629dc27bcb8022fad559ecdb2d3138e39183c6b (patch)
tree29cc4eba73071759fce48295db2c97df758c17ab /src/wasm/literal.cpp
parentfa4c884f4ebfde185c9d8a3ee4e54f96c57cebed (diff)
downloadbinaryen-a629dc27bcb8022fad559ecdb2d3138e39183c6b.tar.gz
binaryen-a629dc27bcb8022fad559ecdb2d3138e39183c6b.tar.bz2
binaryen-a629dc27bcb8022fad559ecdb2d3138e39183c6b.zip
GC: Fuzzing support for i31 (#3169)
Integrates `i31ref` types and instructions into the fuzzer, by assuming that `(i31.new (i32.const N))` is constant and hence suitable to be used in global initializers.
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r--src/wasm/literal.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index a7c14fdb6..d309be308 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -139,7 +139,11 @@ Literals Literal::makeZero(Type type) {
Literal Literal::makeSingleZero(Type type) {
assert(type.isSingle());
if (type.isRef()) {
- return makeNull(type);
+ if (type == Type::i31ref) {
+ return makeI31(0);
+ } else {
+ return makeNull(type);
+ }
} else {
return makeFromInt32(0, type);
}
@@ -438,7 +442,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) {
o << "eqref(null)";
break;
case Type::i31ref:
- o << "i31ref(" << literal.geti31(false) << ")";
+ o << "i31ref(" << literal.geti31() << ")";
break;
case Type::unreachable:
WASM_UNREACHABLE("invalid type");