Bug 97122

Summary: JS binding through JSC API is much slower than binding through WebCore
Product: WebKit Reporter: Chang Shu <cshu>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: abarth, barraclough, ggaren, laszlo.gombos, mhahnenberg, sam
Priority: P2 Keywords: InRadar, Performance
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Code does the binding through both JSC API and WebCore that demonstrates the performance.
none
Profiling result none

Description Chang Shu 2012-09-19 11:08:16 PDT
Created attachment 164757 [details]
Code does the binding through both JSC API and WebCore that demonstrates the performance.

While using JSC API for JS binding, I found the performance is quite slow comparing to binding the same interface inside WebCore. I have attached a test file that adds a MyTest object that does doSqrt() inside WebCore and also hacks a doSqrt() in TestRunner in WebKitTestRunner.
Run "WebKitBuild/Release/WebKitTestRunner LayoutTests/MyTest.html" shows that the latter is 7-8 times slower.
Comment 1 Geoffrey Garen 2012-09-20 12:47:21 PDT
<rdar://problem/12339275>
Comment 2 Sam Weinig 2012-09-23 00:07:04 PDT
Do you have any samples that might indicate where the time might be going?
Comment 3 Chang Shu 2012-09-24 07:01:14 PDT
Created attachment 165371 [details]
Profiling result

I did some profiling but didn't seem to find the bottleneck.
Comment 4 Geoffrey Garen 2013-07-11 14:33:33 PDT
One thing I see here is that JSWrapper::unwrap unnecessarily checks for null and calls JSValueToObject. It should just ASSERT non-null and ASSERT JSValueIsObjectOfClass, since this is guaranteed by the code generator. Then, it should static_cast to JSObjectRef.

This is not very important, since it's only test code, but if you're going to this piece of the test infrastructure for performance investigations, you should optimize it, so we don't get bogus results.