Bug 44104 - Refactor number parsing in the lexer
Summary: Refactor number parsing in the lexer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-17 05:52 PDT by Zoltan Herczeg
Modified: 2010-08-30 01:46 PDT (History)
1 user (show)

See Also:


Attachments
patch (10.34 KB, patch)
2010-08-17 06:08 PDT, Zoltan Herczeg
no flags Details | Formatted Diff | Diff
patch 2 (11.54 KB, patch)
2010-08-19 01:12 PDT, Zoltan Herczeg
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Herczeg 2010-08-17 05:52:49 PDT
Remove that uncountable number of gotos there.
Comment 1 Zoltan Herczeg 2010-08-17 06:08:24 PDT
Created attachment 64578 [details]
patch
Comment 2 Zoltan Herczeg 2010-08-17 06:09:57 PDT
SS has no change (forgot to mention in the ChangeLog)

TEST                           COMPARISON            FROM                 TO             DETAILS

=============================================================================

** TOTAL **:                   -                 33.3ms +/- 2.0%   32.7ms +/- 1.1%

=============================================================================

  jquery:                      -                  5.2ms +/- 5.8%    4.9ms +/- 4.6%
    1.3.2:                     -                  5.2ms +/- 5.8%    4.9ms +/- 4.6%

  mootools:                    -                  5.6ms +/- 6.6%    5.5ms +/- 6.8%
    1.2.2-core-nc:             -                  5.6ms +/- 6.6%    5.5ms +/- 6.8%

  prototype:                   -                  6.2ms +/- 4.9%    6.2ms +/- 4.9%
    1.6.0.3:                   -                  6.2ms +/- 4.9%    6.2ms +/- 4.9%

  concat:                      -                 16.3ms +/- 2.1%   16.1ms +/- 1.4%
    jquery-mootools-prototype: -                 16.3ms +/- 2.1%   16.1ms +/- 1.4%
Comment 3 Zoltan Herczeg 2010-08-17 06:15:24 PDT
Some thoughts:

There is still one got in the code, and I have no idea how to remove that.

Octal numbers seems unsupported in the newest ecmascript:

Past editions of ECMAScript have included additional syntax and semantics for specifying octal literals and octal escape sequences. These have been removed from this edition of ECMAScript.

And octal parsing looks strange to me:
01.1 is invalid, while 09.1 is a valid number (if an octal number followed by '8' or '9' it is considered as a decimal number.)

Although there are regression tests for the current parsing, thus I follow it right now.
Comment 4 Darin Adler 2010-08-17 15:11:39 PDT
Comment on attachment 64578 [details]
patch

> +        record8(m_current);

Seems a shame we have to do this just in case of the overflow. It would be nice to find a way to skip this in the fast path.

> +    int maximumDigits = !m_buffer8.size() ? 9 : -1;

This is a tricky line of code and needs a comment.
Comment 5 Zoltan Herczeg 2010-08-19 01:12:51 PDT
Created attachment 64817 [details]
patch 2
Comment 6 Zoltan Herczeg 2010-08-19 01:16:44 PDT
> Seems a shame we have to do this just in case of the overflow. It would be nice to find a way to skip this in the fast path.

The way is found, but the introduced complexity is not necessary worth the efforts.

Now the parsing is slightly faster:

TEST                           COMPARISON            FROM                 TO             DETAILS

=============================================================================

** TOTAL **:                   1.028x as fast    33.3ms +/- 2.0%   32.4ms +/- 1.1%     significant

=============================================================================

  jquery:                      -                  5.2ms +/- 5.8%    5.0ms +/- 0.0%
    1.3.2:                     -                  5.2ms +/- 5.8%    5.0ms +/- 0.0%

  mootools:                    -                  5.6ms +/- 6.6%    5.3ms +/- 6.5%
    1.2.2-core-nc:             -                  5.6ms +/- 6.6%    5.3ms +/- 6.5%

  prototype:                   -                  6.2ms +/- 4.9%    6.1ms +/- 3.7%
    1.6.0.3:                   -                  6.2ms +/- 4.9%    6.1ms +/- 3.7%

  concat:                      -                 16.3ms +/- 2.1%   16.0ms +/- 0.0%
    jquery-mootools-prototype: -                 16.3ms +/- 2.1%   16.0ms +/- 0.0%
Comment 7 Darin Adler 2010-08-19 11:21:26 PDT
Comment on attachment 64817 [details]
patch 2

I don’t have time to review right now. I think the extra complexity is worth it. The fact that it caused a measurable speedup is exciting. I think we can make additional speedups building on this.
Comment 8 Zoltan Herczeg 2010-08-30 01:46:08 PDT
Landed in http://trac.webkit.org/changeset/66375
Closing bug.