Bug 20333 - improve JavaScript speed when handling single-character strings
: improve JavaScript speed when handling single-character strings
Status: RESOLVED FIXED
: WebKit
JavaScriptCore
: 528+ (Nightly build)
: Macintosh Mac OS X 10.5
: P2 Enhancement
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2008-08-08 13:07 PST by
Modified: 2008-08-30 23:58 PST (History)


Attachments
some early work in progress (62.22 KB, patch)
2008-08-08 13:08 PST, Darin Adler
no flags Review Patch | Details | Formatted Diff | Diff
eliminate JSValue::type() (162.85 KB, patch)
2008-08-12 21:26 PST, Darin Adler
no flags Review Patch | Details | Formatted Diff | Diff
remove the need for InternalFunction to return a UString& to its name (9.16 KB, patch)
2008-08-21 15:14 PST, Darin Adler
no flags Review Patch | Details | Formatted Diff | Diff
work in progress (35.72 KB, patch)
2008-08-29 17:26 PST, Darin Adler
no flags Review Patch | Details | Formatted Diff | Diff
patch (73.35 KB, patch)
2008-08-30 16:04 PST, Darin Adler
mjs: review+
Review Patch | Details | Formatted Diff | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2008-08-08 13:07:32 PST
We think this will work!
------- Comment #1 From 2008-08-08 13:08:00 PST -------
Created an attachment (id=22708) [details]
some early work in progress
------- Comment #2 From 2008-08-12 21:26:34 PST -------
Created an attachment (id=22766) [details]
eliminate JSValue::type()
------- Comment #3 From 2008-08-15 00:10:20 PST -------
(From update of attachment 22766 [details])
r=me

Please try not to conflict with bug 20389.

It looks like you re-autogenerated a bunch of SVG tests, too. Was that intentional?

+        if (v1 == JSImmediate::from(0))
+            return !JSImmediate::isImmediate(v2)
+                && static_cast<JSCell*>(v2)->isNumber()
+                && static_cast<JSNumberCell*>(v2)->value() == 0;
+        return v2 == JSImmediate::from(0)
+            && !JSImmediate::isImmediate(v1)
+            && static_cast<JSCell*>(v1)->isNumber()
+            && static_cast<JSNumberCell*>(v1)->value() == 0;

This surprised me a little bit. Is there a case where 0 gets stored on the heap instead of as an immediate? How do we know this doesn't happen with other numbers?
------- Comment #4 From 2008-08-15 08:49:06 PST -------
(In reply to comment #3)
> It looks like you re-autogenerated a bunch of SVG tests, too. Was that
> intentional?

No. That was an accident and I didn't notice it when creating the patch.

> +        if (v1 == JSImmediate::from(0))
> +            return !JSImmediate::isImmediate(v2)
> +                && static_cast<JSCell*>(v2)->isNumber()
> +                && static_cast<JSNumberCell*>(v2)->value() == 0;
> +        return v2 == JSImmediate::from(0)
> +            && !JSImmediate::isImmediate(v1)
> +            && static_cast<JSCell*>(v1)->isNumber()
> +            && static_cast<JSNumberCell*>(v1)->value() == 0;
> 
> This surprised me a little bit. Is there a case where 0 gets stored on the heap
> instead of as an immediate? How do we know this doesn't happen with other
> numbers?

This is to handle negative 0.
------- Comment #5 From 2008-08-20 10:24:59 PST -------
(From update of attachment 22766 [details])
Clearing review flag since this patch was landed and the bug is not yet fixed.
------- Comment #6 From 2008-08-21 15:14:33 PST -------
Created an attachment (id=22926) [details]
remove the need for InternalFunction to return a UString& to its name

Geoff, this is what we talked about.
------- Comment #7 From 2008-08-22 17:33:41 PST -------
(From update of attachment 22926 [details])
I don't think you want to commit the first change to the XCode project, because Geoff committed changes to all of the XCode projects to update them to XCode 3.1 and that undoes one of them. However, I am no XCode wizard, so I may be wrong.

Otherwise r=me.
------- Comment #8 From 2008-08-29 17:26:06 PST -------
(From update of attachment 22926 [details])
I've decided not to make this change at this time. I'm taking a different approach to optimizing the single character case.
------- Comment #9 From 2008-08-29 17:26:37 PST -------
Created an attachment (id=23077) [details]
work in progress
------- Comment #10 From 2008-08-30 16:04:13 PST -------
Created an attachment (id=23083) [details]
patch
------- Comment #11 From 2008-08-30 19:03:57 PST -------
r=me

Consider breaking SmallStringStorage into its own header and implementation file.
------- Comment #12 From 2008-08-30 23:58:47 PST -------
http://trac.webkit.org/projects/webkit/changeset/36006