From 3c66ad3c7c602416d4cf674b3d7528d9acd6d51f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 25 Nov 2020 15:36:04 -0800 Subject: [TypedFunctionReferences] Enable call_ref in fuzzer, and fix minor misc fuzz bugs (#3401) * Count signatures in tuple locals. * Count nested signature types (confirming @aheejin was right, that was missing). * Inlining was using the wrong type. * OptimizeInstructions should return -1 for unhandled types, not error. * The fuzzer should check for ref types as well, not just typed function references, similar to what GC does. * The fuzzer now creates a function if it has no other option for creating a constant expression of a function type, then does a ref.func of that. * Handle unreachability in call_ref binary reading. * S-expression parsing fixes in more places, and add a tiny fuzzer for it. * Switch fuzzer test to just have the metrics, and not print all the fuzz output which changes a lot. Also fix noprint handling which only worked on binaries before. * Fix Properties::getLiteral() to use the specific function type properly, and make Literal's function constructor require that, to prevent future bugs. * Turn all input types into nullable types, for now. --- test/typed-function-references.wast.fromBinary | 60 ++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'test/typed-function-references.wast.fromBinary') diff --git a/test/typed-function-references.wast.fromBinary b/test/typed-function-references.wast.fromBinary index dcabbeaaf..5cb2ff7c6 100644 --- a/test/typed-function-references.wast.fromBinary +++ b/test/typed-function-references.wast.fromBinary @@ -1,9 +1,16 @@ (module (type $none_=>_none (func)) + (type $none_=>_anyref_f32_anyref_f32 (func (result anyref f32 anyref f32))) (type $i32_=>_i32 (func (param i32) (result i32))) + (type $none_=>_eqref (func (result eqref))) + (type $i32_i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32 i32))) (type $none_=>_i32 (func (result i32))) - (type $ref_null_i32>_=>_i32 (func (param (ref null (func (param i32) (result i32)))) (result i32))) - (type $ref_i32>_=>_i32 (func (param (ref (func (param i32) (result i32)))) (result i32))) + (type $none_=>_anyref (func (result anyref))) + (type $ref_null[i32_->_i32]_=>_i32 (func (param (ref null (func (param i32) (result i32)))) (result i32))) + (type $none_=>_i32_ref_null[_->_anyref_f32_anyref_f32]_f64 (func (result i32 (ref null (func (result anyref f32 anyref f32))) f64))) + (type $none_=>_ref_null[i32_i32_i32_i32_i32_->_] (func (result (ref null (func (param i32 i32 i32 i32 i32)))))) + (type $f64_=>_ref_null[_->_eqref] (func (param f64) (result (ref null (func (result eqref)))))) + (type $none_=>_ref_null[_->_ref_null[i32_i32_i32_i32_i32_->_]] (func (result (ref null (func (result (ref null (func (param i32 i32 i32 i32 i32))))))))) (func $call-ref (call_ref (ref.func $call-ref) @@ -20,7 +27,7 @@ (ref.func $call-ref-more) ) ) - (func $call_from-param (param $f (ref (func (param i32) (result i32)))) (result i32) + (func $call_from-param (param $f (ref null (func (param i32) (result i32)))) (result i32) (call_ref (i32.const 42) (local.get $f) @@ -42,5 +49,52 @@ (local.get $f) ) ) + (func $ref-in-sig (param $0 f64) (result (ref null (func (result eqref)))) + (ref.null (func (result eqref))) + ) + (func $type-only-in-tuple-local + (local $x i32) + (local $1 f64) + (local $2 (ref null (func (result anyref)))) + (nop) + ) + (func $type-only-in-tuple-block + (local $0 (i32 (ref null (func (result anyref f32 anyref f32))) f64)) + (local $1 (ref null (func (result anyref f32 anyref f32)))) + (local $2 i32) + (local.set $0 + (block $label$1 (result i32 (ref null (func (result anyref f32 anyref f32))) f64) + (unreachable) + ) + ) + (drop + (block (result i32) + (local.set $2 + (tuple.extract 0 + (local.get $0) + ) + ) + (drop + (block (result (ref null (func (result anyref f32 anyref f32)))) + (local.set $1 + (tuple.extract 1 + (local.get $0) + ) + ) + (drop + (tuple.extract 2 + (local.get $0) + ) + ) + (local.get $1) + ) + ) + (local.get $2) + ) + ) + ) + (func $nested-type-only-there (result (ref null (func (result (ref null (func (param i32 i32 i32 i32 i32))))))) + (unreachable) + ) ) -- cgit v1.2.3