Bug 178210

Summary: WebAssembly: Wasm functions should have either JSFunctionType or TypeOfShouldCallGetCallData
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, jfbastien, keith_miller, mark.lam, msaboff, sbarati, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch sbarati: review+

Comment 1 Yusuke Suzuki 2017-10-12 07:10:43 PDT
Created attachment 323524 [details]
Patch
Comment 2 JF Bastien 2017-10-12 08:32:41 PDT
Comment on attachment 323524 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323524&action=review

Nice!

> JSTests/wasm/js-api/web-assembly-function.js:22
> +    assert.truthy(typeof instance.exports.foo === "function", "is_function bytecode should handle wasm function.");

We have assert.isFunction

> JSTests/wasm/js-api/web-assembly-function.js:24
> +    assert.eq(value, "function", "the result of typeof should be 'function'");

Why twice?
Comment 3 Yusuke Suzuki 2017-10-12 19:09:38 PDT
Comment on attachment 323524 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323524&action=review

Thank you!

>> JSTests/wasm/js-api/web-assembly-function.js:22
>> +    assert.truthy(typeof instance.exports.foo === "function", "is_function bytecode should handle wasm function.");
> 
> We have assert.isFunction

I would like to keep this as is. This is because I would like to keep this `typeof xxx === 'function'` form.
Currently, our bytecode compiler performs pattern matching onto the AST nodes and emit `is_function` specially if it finds `typeof xxx === "function"`.

>> JSTests/wasm/js-api/web-assembly-function.js:24
>> +    assert.eq(value, "function", "the result of typeof should be 'function'");
> 
> Why twice?

This is because we would like to test `is_function` opcode and `typeof` opcode in bytecode compiler.
Our JSC bytecode compiler emits `is_function` if `typeof XXX === "function"` case. The first `truthy` one tests this.
And second this one tests `typeof` bytecode operation.
Comment 4 Yusuke Suzuki 2017-10-12 19:13:27 PDT
Committed r223274: <https://trac.webkit.org/changeset/223274>
Comment 5 Radar WebKit Bug Importer 2017-10-12 19:14:28 PDT
<rdar://problem/34969307>