From c3e31c99461f7f109637528d805dbaa349cf4a22 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 10 Aug 2022 16:43:43 -0700 Subject: [PATCH] [fuzz] Document Wasm-JS conversions (#4683) During differential execution against V8, Wasm values need to be converted back and forth from JS values. This change documents the location in the specification where this is defined. --- crates/fuzzing/src/oracles/v8.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/fuzzing/src/oracles/v8.rs b/crates/fuzzing/src/oracles/v8.rs index bf8b683ab7..984b706937 100644 --- a/crates/fuzzing/src/oracles/v8.rs +++ b/crates/fuzzing/src/oracles/v8.rs @@ -83,6 +83,8 @@ pub fn differential_v8_execution(wasm: &[u8], config: &crate::generators::Config ValType::ExternRef => Val::ExternRef(None), _ => unimplemented!(), }); + // See https://webassembly.github.io/spec/js-api/index.html#tojsvalue + // for how the Wasm-to-JS conversions are done. v8_params.push(match param { ValType::I32 | ValType::F32 | ValType::F64 => v8::Number::new(&mut scope, 0.0).into(), ValType::I64 => v8::BigInt::new_from_i64(&mut scope, 0).into(), @@ -215,6 +217,9 @@ fn eval<'s>( /// Asserts that the wasmtime value `a` matches the v8 value `b`. /// /// For NaN values simply just asserts that they're both NaN. +/// +/// See https://webassembly.github.io/spec/js-api/index.html#towebassemblyvalue +/// for how the JS-to-Wasm conversions are done. fn assert_val_match(a: &Val, b: &v8::Local<'_, v8::Value>, scope: &mut v8::HandleScope<'_>) { match *a { Val::I32(wasmtime) => {