Bug 68851 - De-virtualize JSCell::getPrimitiveNumber
Summary: De-virtualize JSCell::getPrimitiveNumber
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks: 67690
  Show dependency treegraph
 
Reported: 2011-09-26 16:51 PDT by Mark Hahnenberg
Modified: 2011-09-27 12:53 PDT (History)
1 user (show)

See Also:


Attachments
Patch (10.77 KB, patch)
2011-09-26 17:27 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (10.77 KB, patch)
2011-09-26 17:33 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (10.78 KB, patch)
2011-09-26 18:04 PDT, Mark Hahnenberg
darin: review+
Details | Formatted Diff | Diff
Benchmark results (without inlining) (6.32 KB, text/plain)
2011-09-27 10:47 PDT, Mark Hahnenberg
no flags Details
Benchmark results (with inlining) (6.40 KB, text/plain)
2011-09-27 12:36 PDT, Mark Hahnenberg
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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>