From 015452a9dc39a5065ac87cbdf27b7df8bb6622be Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 17 Nov 2022 15:01:22 -0800 Subject: [PATCH 1/2] Do not compare reference values across executions Since we optimize assuming a closed world, optimizations can change the types and structure of GC data even in externally-visible ways. Because differences are expected, the fuzzer already did not compare reference-typed values from before and after optimizations when running with nominal typing. Update it to not compare these values under any type system. --- src/tools/execution-results.h | 28 ++++++++++------------------ test/lit/exec/no-compare-refs.wast | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 test/lit/exec/no-compare-refs.wast diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 723ddffda46..925c9b6d816 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -143,25 +143,17 @@ struct ExecutionResults { } bool areEqual(Literal a, Literal b) { - // We allow nulls to have different types (as they compare equal regardless) - // but anything else must have an identical type. - // We cannot do this in nominal typing, however, as different modules will - // have different types in general. We could perhaps compare the entire - // graph structurally TODO - if (getTypeSystem() != TypeSystem::Nominal) { - if (a.type != b.type && !(a.isNull() && b.isNull())) { - std::cout << "types not identical! " << 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 - // is that we are comparing results between two separate wasm modules (and - // 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. + // Don't compare references. There are several issues here that we can't + // fully handle, see https://github.com/WebAssembly/binaryen/issues/3378, + // but the core issue is that since we optimize assuming a closed world, + // the types and structure of GC data can arbitrarily change after + // optimizations, even in ways that are externally visible from outside + // the module. + // + // TODO: Once we support optimizing under some form of open-world + // assumption, we should be able to check that the types and/or structure + // of GC data passed out of the module does not change. return true; } if (a != b) { diff --git a/test/lit/exec/no-compare-refs.wast b/test/lit/exec/no-compare-refs.wast new file mode 100644 index 00000000000..bb9766a3122 --- /dev/null +++ b/test/lit/exec/no-compare-refs.wast @@ -0,0 +1,22 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited. + +;; RUN: wasm-opt %s --hybrid -all --signature-pruning --fuzz-exec -q -o /dev/null 2>&1 | filecheck %s + +(module + (type $f (func (param i32))) + + (func $no-use-param (type $f) (param i32) + (unreachable) + ) + + ;; The type of the reference this function returns will change as a result of + ;; signature pruning. The fuzzer should not complain about this. + ;; CHECK: [fuzz-exec] calling return-ref + ;; CHECK-NEXT: [fuzz-exec] note result: return-ref => funcref + (func "return-ref" (result funcref) + (ref.func $no-use-param) + ) +) +;; CHECK: [fuzz-exec] calling return-ref +;; CHECK-NEXT: [fuzz-exec] note result: return-ref => funcref +;; CHECK-NEXT: [fuzz-exec] comparing return-ref From 07eccc54e7055961db8dd3ee870c27c1c0e78d7b Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 17 Nov 2022 15:46:43 -0800 Subject: [PATCH 2/2] Unpin V8 Our WasmGC output is no longer compatible with the previously pinned version and the issue that caused us to pin it in the first place has been resolved. --- scripts/test/shared.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/test/shared.py b/scripts/test/shared.py index eac4bd99d33..1d48ddd68a5 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -202,9 +202,7 @@ def is_exe(fpath): NODEJS = os.getenv('NODE', which('node') or which('nodejs')) MOZJS = which('mozjs') or which('spidermonkey') -# TODO: Remove the specific v8 version once we implement structref and can run -# on recent v8. -V8 = which('v8-10.8.104') or which('v8') or which('d8') +V8 = which('v8') or which('d8') BINARYEN_INSTALL_DIR = os.path.dirname(options.binaryen_bin) WASM_OPT = [os.path.join(options.binaryen_bin, 'wasm-opt')]