Bug 196387 - Teach Call ICs how to call Wasm
Summary: Teach Call ICs how to call Wasm
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on: 196624
Blocks: 196385
  Show dependency treegraph
 
Reported: 2019-03-28 19:30 PDT by Saam Barati
Modified: 2019-04-04 14:39 PDT (History)
15 users (show)

See Also:


Attachments
WIP (26.62 KB, patch)
2019-04-01 16:27 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (35.65 KB, patch)
2019-04-01 19:24 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (35.67 KB, patch)
2019-04-01 19:29 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (35.75 KB, patch)
2019-04-02 13:42 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (36.59 KB, patch)
2019-04-02 14:49 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (35.57 KB, patch)
2019-04-02 20:15 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch (79.40 KB, patch)
2019-04-03 16:30 PDT, Saam Barati
fpizlo: review+
Details | Formatted Diff | Diff
patch for landing (80.24 KB, patch)
2019-04-03 17:07 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch for landing (80.90 KB, patch)
2019-04-04 11:14 PDT, Saam Barati
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2019-03-28 19:30:06 PDT
...
Comment 1 Saam Barati 2019-04-01 16:27:15 PDT
Created attachment 366440 [details]
WIP

almost 2x faster on richards-wasm

I still need to make the code correct in the common case, e.g, teach the unwinder how to unwind past these frames and read callee saves, and restore wasm context
Comment 2 Saam Barati 2019-04-01 19:24:55 PDT
Created attachment 366455 [details]
WIP
Comment 3 Saam Barati 2019-04-01 19:29:40 PDT
Created attachment 366457 [details]
WIP
Comment 4 Saam Barati 2019-04-02 13:42:55 PDT
Created attachment 366532 [details]
WIP

Wasm tests appear to pass
Comment 5 Saam Barati 2019-04-02 13:43:22 PDT
I now need to make polymorphic calls work.
Comment 6 Saam Barati 2019-04-02 14:49:30 PDT
Created attachment 366541 [details]
WIP

now with polymorphic ICs
Comment 7 Saam Barati 2019-04-02 20:15:42 PDT
Created attachment 366571 [details]
WIP

Almost done. Just need to clean up a few things.
Comment 8 Saam Barati 2019-04-03 16:30:30 PDT
Created attachment 366667 [details]
patch
Comment 9 EWS Watchlist 2019-04-03 16:32:22 PDT
Attachment 366667 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/wasm/js/WebAssemblyFunctionHeapCellType.cpp:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 34 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Filip Pizlo 2019-04-03 16:47:37 PDT
Comment on attachment 366667 [details]
patch

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

> Source/JavaScriptCore/jit/Repatch.cpp:1151
> -            codePtr = variant.executable()->generatedJITCodeForCall()->addressForCall(ArityCheckNotRequired);
> +
> +#if ENABLE(WEBASSEMBLY)
> +            if (callLinkInfo.specializationKind() == CodeForCall) {
> +                if (JSFunction* function = variant.function()) {
> +                    if (auto* wasmFunction = jsDynamicCast<WebAssemblyFunction*>(vm, function))
> +                        codePtr = wasmFunction->jsCallEntrypoint();
> +                }
> +            }
> +#endif
> +
> +            if (!codePtr)
> +                codePtr = variant.executable()->generatedJITCodeForCall()->addressForCall(ArityCheckNotRequired);

Seems like we write this code or some variant of it in multiple places.

Helper?
Comment 11 Saam Barati 2019-04-03 16:50:46 PDT
Comment on attachment 366667 [details]
patch

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

>> Source/JavaScriptCore/jit/Repatch.cpp:1151
>> +                codePtr = variant.executable()->generatedJITCodeForCall()->addressForCall(ArityCheckNotRequired);
> 
> Seems like we write this code or some variant of it in multiple places.
> 
> Helper?

Thanks for the review. Will fix.
Comment 12 Saam Barati 2019-04-03 17:07:48 PDT
Created attachment 366674 [details]
patch for landing
Comment 13 Saam Barati 2019-04-04 11:14:02 PDT
Created attachment 366730 [details]
patch for landing

With windows build fix.
Comment 14 Saam Barati 2019-04-04 11:18:46 PDT
This is also a 12% speedup on https://pspdfkit.com/webassembly-benchmark/
Comment 15 WebKit Commit Bot 2019-04-04 11:54:22 PDT
Comment on attachment 366730 [details]
patch for landing

Clearing flags on attachment: 366730

Committed r243886: <https://trac.webkit.org/changeset/243886>
Comment 16 WebKit Commit Bot 2019-04-04 11:54:23 PDT
All reviewed patches have been landed.  Closing bug.
Comment 17 Radar WebKit Bug Importer 2019-04-04 12:02:20 PDT
<rdar://problem/49616723>
Comment 18 Yusuke Suzuki 2019-04-04 13:42:19 PDT
Committed r243898: <https://trac.webkit.org/changeset/243898>
Comment 19 WebKit Commit Bot 2019-04-04 13:50:35 PDT
Re-opened since this is blocked by bug 196624
Comment 20 Saam Barati 2019-04-04 14:25:11 PDT
Will land cloop build fix momentarily
Comment 21 Saam Barati 2019-04-04 14:39:34 PDT
CLoop build fix:
http://trac.webkit.org/changeset/243907/webkit