From 97b74cf197796b5fde0cd6dd3987581debe66063 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 11 Mar 2021 15:48:52 -0800 Subject: [PATCH 1/3] work --- src/tools/execution-results.h | 12 +++++++----- test/passes/roundtrip_fuzz-exec_all-features.txt | 13 +++++++++++++ test/passes/roundtrip_fuzz-exec_all-features.wast | 7 +++++++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 test/passes/roundtrip_fuzz-exec_all-features.txt create mode 100644 test/passes/roundtrip_fuzz-exec_all-features.wast diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index d998262106d..73c454327b2 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -121,11 +121,7 @@ struct ExecutionResults { } bool areEqual(Literal a, Literal b) { - if (a.type != b.type) { - std::cout << "types not identical! " << a << " != " << b << '\n'; - return false; - } - if (a.type.isRef()) { + if (a.type.isRef() && b.type.isRef()) { // Don't compare references - only their types. There are several issues // here that we can't fully handle, see // https://github.com/WebAssembly/binaryen/issues/3378, but the core issue @@ -133,8 +129,14 @@ struct ExecutionResults { // a separate instance of each) - we can't really identify an identical // reference between such things. We can only compare things structurally, // for which we compare the types. + // Another issue is that the same module, when passed through --roundtrip, + // will end up with a type that does not compare equally. return true; } + if (a.type != b.type) { + std::cout << "types not identical! " << a << " != " << b << '\n'; + return false; + } if (a != b) { std::cout << "values not identical! " << a << " != " << b << '\n'; return false; diff --git a/test/passes/roundtrip_fuzz-exec_all-features.txt b/test/passes/roundtrip_fuzz-exec_all-features.txt new file mode 100644 index 00000000000..d025f8de566 --- /dev/null +++ b/test/passes/roundtrip_fuzz-exec_all-features.txt @@ -0,0 +1,13 @@ +[fuzz-exec] calling foo +[fuzz-exec] note result: foo => funcref(null) +(module + (type $A (func (result (ref null $A)))) + (type $none_=>_funcref (func (result funcref))) + (export "foo" (func $0)) + (func $0 (result funcref) + (ref.null $A) + ) +) +[fuzz-exec] calling foo +[fuzz-exec] note result: foo => funcref(null) +[fuzz-exec] comparing foo diff --git a/test/passes/roundtrip_fuzz-exec_all-features.wast b/test/passes/roundtrip_fuzz-exec_all-features.wast new file mode 100644 index 00000000000..fb6679e723d --- /dev/null +++ b/test/passes/roundtrip_fuzz-exec_all-features.wast @@ -0,0 +1,7 @@ +(module + (type $A (func (result (ref null $A)))) + (func "foo" (result funcref) + (ref.null $A) + ) +) + From af6b5ad658e72e31e081d7987a6ee567e8e793d8 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 12 Mar 2021 12:29:34 -0800 Subject: [PATCH 2/3] better --- src/tools/execution-results.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 73c454327b2..9b8becca103 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -121,7 +121,11 @@ struct ExecutionResults { } bool areEqual(Literal a, Literal b) { - if (a.type.isRef() && b.type.isRef()) { + if (!Type::isSubType(a.type, b.type) && !Type::isSubType(b.type, a.type)) { + std::cout << "types not compatible! " << a << " != " << b << '\n'; + return false; + } + if (a.type.isRef()) { // Don't compare references - only their types. There are several issues // here that we can't fully handle, see // https://github.com/WebAssembly/binaryen/issues/3378, but the core issue @@ -130,13 +134,9 @@ struct ExecutionResults { // reference between such things. We can only compare things structurally, // for which we compare the types. // Another issue is that the same module, when passed through --roundtrip, - // will end up with a type that does not compare equally. + // will end up with a type that does not compare equallygi. return true; } - if (a.type != b.type) { - std::cout << "types not identical! " << a << " != " << b << '\n'; - return false; - } if (a != b) { std::cout << "values not identical! " << a << " != " << b << '\n'; return false; From 6e3ac2bb9658f4f02556a1acff615076dea27538 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 12 Mar 2021 12:30:48 -0800 Subject: [PATCH 3/3] comment --- src/tools/execution-results.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 9b8becca103..954c76f85b0 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -134,7 +134,8 @@ struct ExecutionResults { // reference between such things. We can only compare things structurally, // for which we compare the types. // Another issue is that the same module, when passed through --roundtrip, - // will end up with a type that does not compare equallygi. + // will end up with a type that does not compare equally as we do not + // currently globally canonicalize recursive types. return true; } if (a != b) {