RESOLVED FIXED 205327
[JSC] Improve our bound function implementation
https://bugs.webkit.org/show_bug.cgi?id=205327
Summary [JSC] Improve our bound function implementation
Yusuke Suzuki
Reported 2019-12-17 00:45:21 PST
I think there are bunch of things to do. 1. We should not look up JIT thunks every time we create JSBoundFunction. 2. We should have fast path for bound args. (I think it is easy). And more.
Attachments
Patch (167.62 KB, patch)
2019-12-19 21:48 PST, Yusuke Suzuki
no flags
Patch (168.12 KB, patch)
2019-12-19 22:31 PST, Yusuke Suzuki
no flags
Patch (176.95 KB, patch)
2019-12-20 12:00 PST, Yusuke Suzuki
no flags
Patch (176.95 KB, patch)
2019-12-20 12:22 PST, Yusuke Suzuki
keith_miller: review+
Yusuke Suzuki
Comment 1 2019-12-19 21:48:23 PST
Yusuke Suzuki
Comment 2 2019-12-19 22:31:16 PST
Yusuke Suzuki
Comment 3 2019-12-20 12:00:04 PST
Yusuke Suzuki
Comment 4 2019-12-20 12:22:52 PST
Keith Miller
Comment 5 2019-12-21 11:49:27 PST
Comment on attachment 386238 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=386238&action=review r=me. > Source/JavaScriptCore/ChangeLog:10 > + 1. Rename CallFrameSlot::argumentCount to CallFrameSlot::argumentCountIncludingThis. Nooo, the merge conflicts! :P > Source/JavaScriptCore/ChangeLog:15 > + 3. Cache NativeExecutable for JSBoundFunction in VM. Using hash-map in JITThunk for NativeExecutable is assuming that host-function creation is not done by > + user program: each function is pre-defined one by the environment, and there is no case creating host-functions repeatedly from user-program. This is not > + true for JSBoundFunction. We should cache NativeExecutable in VM to look up fast. If I'm understanding what you are trying to say correctly I think I would phrase this as: Cache NativeExecutable for JSBoundFunction in the VM. We use a hash-map in JITThunk for NativeExecutables because we assume that host-function creation cannot not done by the user program: each executable is pre-defined to exactly one object by the environment, and there is no way to create host-functions repeatedly from the user-program. The only exception to this is JSBoundFunction so caching it on the VM avoids the hash-map lookup. true for JSBoundFunction. > Source/JavaScriptCore/ChangeLog:17 > + bound arguments. And it is used as event listener. This is really bad: when dispatching an event, we first call this function from C++, entering JS world, nit: And it is used => Additionally, it is used. And isn't normally used to start a sentence. > Source/JavaScriptCore/ChangeLog:19 > + calling bound JS Executable from thunk. Previously, bound arguments are stored in JSArray. But it is difficult to access them from thunk since we need to consider nit: calling the* bound JSExecutable from the* thunk.
Yusuke Suzuki
Comment 6 2019-12-21 19:11:12 PST
Comment on attachment 386238 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=386238&action=review Thanks! >> Source/JavaScriptCore/ChangeLog:10 >> + 1. Rename CallFrameSlot::argumentCount to CallFrameSlot::argumentCountIncludingThis. > > Nooo, the merge conflicts! :P Lol, oops, sorry :P >> Source/JavaScriptCore/ChangeLog:15 >> + true for JSBoundFunction. We should cache NativeExecutable in VM to look up fast. > > If I'm understanding what you are trying to say correctly I think I would phrase this as: > > Cache NativeExecutable for JSBoundFunction in the VM. We use a hash-map in JITThunk for NativeExecutables because we assume that host-function creation cannot not done by > the user program: each executable is pre-defined to exactly one object by the environment, and there is no way to create host-functions repeatedly from the user-program. The only exception to this is > JSBoundFunction so caching it on the VM avoids the hash-map lookup. > true for JSBoundFunction. Right. Fixed. >> Source/JavaScriptCore/ChangeLog:17 >> + bound arguments. And it is used as event listener. This is really bad: when dispatching an event, we first call this function from C++, entering JS world, > > nit: And it is used => Additionally, it is used. And isn't normally used to start a sentence. Fixed. >> Source/JavaScriptCore/ChangeLog:19 >> + calling bound JS Executable from thunk. Previously, bound arguments are stored in JSArray. But it is difficult to access them from thunk since we need to consider > > nit: calling the* bound JSExecutable from the* thunk. Fixed.
Yusuke Suzuki
Comment 7 2019-12-21 19:12:08 PST
Radar WebKit Bug Importer
Comment 8 2019-12-21 19:13:18 PST
Yusuke Suzuki
Comment 9 2019-12-22 01:57:09 PST
Yusuke Suzuki
Comment 10 2019-12-22 04:10:08 PST
Note You need to log in before you can comment on or make changes to this bug.