design icon indicating copy to clipboard operation
design copied to clipboard

When do we throw when there's an interaction between JS and i64?

Open bnjbvr opened this issue 8 years ago • 3 comments
trafficstars

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.)

bnjbvr avatar Nov 09 '17 18:11 bnjbvr

Dup #913 and #949?

jfbastien avatar Nov 09 '17 18:11 jfbastien

Yes indeed. How about we make the spec text crystal-clear so there are no more duplicates of this issue?

bnjbvr avatar Nov 09 '17 18:11 bnjbvr

FWIW we test this behavior here: https://trac.webkit.org/browser/webkit/trunk/JSTests/wasm/function-tests/i64-from-js-exceptions.js

jfbastien avatar Nov 09 '17 19:11 jfbastien