Bug 68851

Summary: De-virtualize JSCell::getPrimitiveNumber
Product: WebKit Reporter: Mark Hahnenberg <mhahnenberg>
Component: JavaScriptCoreAssignee: Mark Hahnenberg <mhahnenberg>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 67690    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
darin: review+
Benchmark results (without inlining)
none
Benchmark results (with inlining) none

Description Mark Hahnenberg 2011-09-26 16:51:29 PDT
Part of the larger process of de-virtualizing JSCell.
Comment 1 Mark Hahnenberg 2011-09-26 17:27:46 PDT
Created attachment 108761 [details]
Patch
Comment 2 Mark Hahnenberg 2011-09-26 17:33:42 PDT
Created attachment 108766 [details]
Patch
Comment 3 Mark Hahnenberg 2011-09-26 18:04:20 PDT
Created attachment 108770 [details]
Patch
Comment 4 Darin Adler 2011-09-27 10:16:49 PDT
Comment on attachment 108770 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSCell.cpp:135
> -bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)
> +bool JSCell::getPrimitiveNumber(ExecState* exec, double& number, JSValue& value) const
>  {
> -    ASSERT_NOT_REACHED();
> -    return false;
> +    if (isString())
> +        return static_cast<const JSString*>(this)->getPrimitiveNumber(exec, number, value);
> +    return static_cast<const JSObject*>(this)->getPrimitiveNumber(exec, number, value);
>  }

This turns a single virtual function call into two levels of non-virtual function call. Did you do speed testing? Does this function need to be inlined in JSString.h?
Comment 5 Mark Hahnenberg 2011-09-27 10:47:44 PDT
Created attachment 108866 [details]
Benchmark results (without inlining)
Comment 6 Mark Hahnenberg 2011-09-27 12:36:09 PDT
Created attachment 108882 [details]
Benchmark results (with inlining)
Comment 7 Mark Hahnenberg 2011-09-27 12:38:47 PDT
Overall, negligible difference between inlining and not inlining, so I think we should stick with JSCell::getPrimitiveNumber remaining in JSCell.cpp.
Comment 8 Mark Hahnenberg 2011-09-27 12:53:13 PDT
Committed r96143: <http://trac.webkit.org/changeset/96143>