WebAssembly JS API: check and test in-call / out-call values
https://bugs.webkit.org/show_bug.cgi?id=164876
<rdar://problem/29844107>
Reviewed by Saam Barati.
JSTests:
* wasm.yaml:
* wasm/assert.js: add an assert for NaN comparison
* wasm/fuzz/export-function.js: Added. Generate random wasm export
signatures, and call them with random parameters.
(const.paramExporter):
(const.setBuffer):
(const.types.generate):
(generate):
* wasm/js-api/export-arity.js: Added.
(const.paramExporter): Test that mismatched arities when JS calls
wasm follow the defined semantics: i32 is 0, f32 / f64 are NaN.
https://github.com/WebAssembly/design/blob/master/JS.md#exported-function-exotic-objects
* wasm/js-api/export-void-is-undef.js: Added. Test that "void"
wasm functions return "undefined" in JS.
Source/JavaScriptCore:
* wasm/WasmBinding.cpp:
(JSC::Wasm::wasmToJs): fix the wasm -> JS call coercions for f32 /
f64 which the assotiated tests inadvertently tripped on: the
previous code wasn't correctly performing JSValue boxing for
"double" values. This change is slightly involved because it
requires two scratch registers to materialize the
`DoubleEncodeOffset` value. This change therefore reorganizes the
code to first generate traps, then handle all integers (freeing
all GPRs), and then all the floating-point values.
* wasm/js/WebAssemblyFunction.cpp:
(JSC::callWebAssemblyFunction): Implement the defined semantics
for mismatched arities when JS calls wasm:
https://github.com/WebAssembly/design/blob/master/JS.md#exported-function-exotic-objects
- i32 is 0, f32 / f64 are NaN.
- wasm functions which return "void" are "undefined" in JS.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@210244 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JSTests/wasm.yaml b/JSTests/wasm.yaml
index 77fd443..5737ba1 100644
--- a/JSTests/wasm.yaml
+++ b/JSTests/wasm.yaml
@@ -27,6 +27,8 @@
cmd: runWebAssembly
- path: wasm/function-tests
cmd: runWebAssembly
+- path: wasm/fuzz
+ cmd: runWebAssembly
- path: wasm/spec-tests/address.wast.js
cmd: runWebAssemblySpecTest :normal