[webkit-changes] [WebKit/WebKit] 1ef261: [JSC] Bound function should be unwrapped when call...
Yusuke Suzuki
noreply at github.com
Fri Feb 17 21:44:47 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1ef2618fca1d075259cb8c84e88299c1f34b2f41
https://github.com/WebKit/WebKit/commit/1ef2618fca1d075259cb8c84e88299c1f34b2f41
Author: Yusuke Suzuki <ysuzuki at apple.com>
Date: 2023-02-17 (Fri, 17 Feb 2023)
Changed paths:
A JSTests/microbenchmarks/call-from-cpp-bound-with-args.js
A JSTests/microbenchmarks/call-from-cpp-bound.js
M Source/JavaScriptCore/API/JSCallbackConstructor.cpp
M Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
M Source/JavaScriptCore/interpreter/Interpreter.cpp
M Source/JavaScriptCore/interpreter/Interpreter.h
M Source/JavaScriptCore/runtime/CallData.h
M Source/JavaScriptCore/runtime/InternalFunction.cpp
M Source/JavaScriptCore/runtime/JSBoundFunction.cpp
M Source/JavaScriptCore/runtime/JSFunction.cpp
M Source/JavaScriptCore/runtime/ProxyObject.cpp
M Source/JavaScriptCore/tools/JSDollarVM.cpp
M Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
M Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
M Source/WebCore/bridge/objc/objc_runtime.mm
M Source/WebCore/bridge/runtime_object.cpp
Log Message:
-----------
[JSC] Bound function should be unwrapped when calling it from C++
https://bugs.webkit.org/show_bug.cgi?id=252445
rdar://105571741
Reviewed by Tadeu Zagallo.
We already unwrapped nested JSBoundFunctions in 260303 at main. As a result, one-level unwrapping is enough to extract the target function in most cases.
This patch adds one-level unwrapping in executeCall so that we can skip JSBoundFunction indirection.
Before: CXX -> vmEntryToNative -> CXX JSBoundFunction implementation -> vmEntryToJS -> targetFunction
After: CXX -> vmEntryToJS -> targetFunction
We extract "isBoundFunction" information when calling getCallData / getConstructData. We use this to unwrap in executeCall.
We observed large improvement in microbenchmarks. And we observed 0.3% progression in Speedometer2.1
ToT Patched
call-from-cpp-bound 160.4848+-0.0830 ^ 89.3845+-0.1212 ^ definitely 1.7954x faster
call-from-cpp-bound-with-args 169.0045+-0.1030 ^ 107.8479+-0.0877 ^ definitely 1.5671x faster
* JSTests/microbenchmarks/call-from-cpp-bound-with-args.js: Added.
(test):
* JSTests/microbenchmarks/call-from-cpp-bound.js: Added.
(test):
* Source/JavaScriptCore/API/JSCallbackConstructor.cpp:
(JSC::JSCallbackConstructor::getConstructData):
* Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:
(JSC::JSCallbackObject<Parent>::getConstructData):
(JSC::JSCallbackObject<Parent>::getCallData):
* Source/JavaScriptCore/interpreter/Interpreter.cpp:
(JSC::Interpreter::executeBoundCall):
(JSC::Interpreter::executeCallImpl):
(JSC::Interpreter::executeCall):
* Source/JavaScriptCore/interpreter/Interpreter.h:
* Source/JavaScriptCore/runtime/CallData.h:
* Source/JavaScriptCore/runtime/InternalFunction.cpp:
(JSC::InternalFunction::getCallData):
(JSC::InternalFunction::getConstructData):
* Source/JavaScriptCore/runtime/JSBoundFunction.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSFunction.cpp:
(JSC::JSFunction::getCallData):
(JSC::JSFunction::getConstructData):
* Source/JavaScriptCore/runtime/ProxyObject.cpp:
(JSC::ProxyObject::getCallData):
(JSC::ProxyObject::getConstructData):
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSDollarVM::finishCreation):
* Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::JSHTMLAllCollection::getCallData):
* Source/WebCore/bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginElementCustomGetCallData):
* Source/WebCore/bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcFallbackObjectImp::getCallData):
* Source/WebCore/bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::getCallData):
(JSC::Bindings::RuntimeObject::getConstructData):
Canonical link: https://commits.webkit.org/260494@main
More information about the webkit-changes
mailing list