design
design copied to clipboard
When do we throw when there's an interaction between JS and i64?
When from JS we call an exported wasm function that takes i64 as the return value or parameter, the spec says:
If sig contains an i64 (as argument or result), a TypeError is thrown each time the [[Call]] method is invoked.
Does the throwing happen before the first argument is evaluated, or does it happen when the first Int64 argument is evaluated? (note there's a difference between the twos, e.g. if the first argument is an Object implementing valueOf() that causes side-effects (there is an implicit ToInt32 call hiding in the call to the wasm function), the second argument being an int64)
For import of non-exotic function objects, the spec is more explicit:
If the signature contains an i64 (as argument or result), the host function immediately throws a TypeError when called.
Can we confirm that it's the same behavior or a different one, though?
(I think the former solution (throw before arguments are even evaluated) is better, because it also provides a clear stand on how should the function behaves if the return value has type int64, and it's simpler and easier to understand as a user.)
Dup #913 and #949?
Yes indeed. How about we make the spec text crystal-clear so there are no more duplicates of this issue?
FWIW we test this behavior here: https://trac.webkit.org/browser/webkit/trunk/JSTests/wasm/function-tests/i64-from-js-exceptions.js