From a629dc27bcb8022fad559ecdb2d3138e39183c6b Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Tue, 29 Sep 2020 21:24:02 +0200 Subject: 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. --- src/wasm/literal.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/wasm/literal.cpp') 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"); -- cgit v1.2.3