Bug 118513

Summary: Cache property access for JSC API static functions
Product: WebKit Reporter: Yi Shen <max.hong.shen>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cshu
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: OS X 10.8   
Attachments:
Description Flags
Test case
none
proposal patch ggaren: review-

Description Yi Shen 2013-07-09 10:17:21 PDT
By caching property access, the JSC API static function call could be 1/4 times faster than before.
Comment 1 Yi Shen 2013-07-09 10:27:48 PDT
Created attachment 206339 [details]
Test case
Comment 2 Yi Shen 2013-07-09 10:28:56 PDT
                 No cache        Cache
result(ms)
1.                  8000          6003
2.                  7600          5947
3.                  7987          5912
4.                  8002          5886
5.                  8155          5934
6.                  7539          5953
7.                  8562          5958
8.                  7455          5952
9.                  7936          5913
10.                7461          5910
------------------------------
avg                7869          5937
Comment 3 Yi Shen 2013-07-09 10:30:16 PDT
Created attachment 206340 [details]
proposal patch
Comment 4 Geoffrey Garen 2013-07-10 10:26:01 PDT
Comment on attachment 206340 [details]
proposal patch

I don't think this is correct.

Client functions are allowed to make arbitrary decisions, and we can't assume they'll make the same decision each time.
Comment 5 Yi Shen 2013-07-11 11:19:20 PDT
Thanks for review! Could you please explain a bit more about the 'arbitrary decisions' that you have mentioned? 

As I noticed that the JSCallbackObject<Parent>::staticFunctionGetter() always checks for cached or override property when it gets called.  So, I added a similar check before calling staticFunctionGetter() and pass the cached property to the property slot only if it exists. By doing this, we can cache the property access through tryCacheGetByID() (JITStubs.cpp). 

(In reply to comment #4)
> (From update of attachment 206340 [details])
> I don't think this is correct.
> 
> Client functions are allowed to make arbitrary decisions, and we can't assume they'll make the same decision each time.