Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Issue 1096002: StringToDouble rewritten not using String::Get and memory allocations.... (Closed)

Created:
10 years, 9 months ago by SeRya
Modified:
9 years, 7 months ago
Reviewers:
Erik Corry, floitschv8, Mads Ager (chromium)
CC:
v8-dev
Visibility:
Public.

Description

StringToDouble rewritten not using String::Get and memory allocations. It converts the number to "canonical" form removing insignificant digits, leading zerroes and spaces what guarantees to fit a fixed size buffer and does not changes result of strtod. Committed: http://code.google.com/p/v8/source/detail?r=4241

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 52

Patch Set 3 : '' #

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Total comments: 12

Patch Set 8 : '' #

Patch Set 9 : '' #

Patch Set 10 : '' #

Patch Set 11 : '' #

Total comments: 17
Unified diffs Side-by-side diffs Delta from patch set Stats (+478 lines, -114 lines) Patch
M src/conversions.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +377 lines, -114 lines 16 comments Download
M test/cctest/test-conversions.cc View 1 2 3 4 5 6 7 8 3 chunks +79 lines, -0 lines 1 comment Download
M test/mjsunit/str-to-num.js View 1 2 3 4 5 6 7 4 chunks +22 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
SeRya
StringToNumber is called ~10M times in SunSpider (according to my measurements) but vast majority of ...
10 years, 9 months ago (2010-03-18 17:12:30 UTC) #1
Erik Corry
LGTM http://codereview.chromium.org/1096002/diff/3002/4003 File src/conversions.cc (right): http://codereview.chromium.org/1096002/diff/3002/4003#newcode109 src/conversions.cc:109: bool operator != (EndMarker const& m) const { ...
10 years, 9 months ago (2010-03-18 20:34:22 UTC) #2
Florian Loitsch
http://codereview.chromium.org/1096002/diff/3002/4003 File src/conversions.cc (right): http://codereview.chromium.org/1096002/diff/3002/4003#newcode162 src/conversions.cc:162: if (*s == '-' || *s == '+') s++; ...
10 years, 9 months ago (2010-03-19 13:39:42 UTC) #3
SeRya
I'm not sure what to do about 100000000000000000000000.0000000000000000000000000000000000000000000001 (by the way, Firefox also spots removing ...
10 years, 9 months ago (2010-03-19 15:46:12 UTC) #4
Florian Loitsch
I will discuss the 100000000000000000000000.0000000000000000000000000000000000000000000001 issue with the V8 team on monday. The way I ...
10 years, 9 months ago (2010-03-20 16:56:51 UTC) #5
Florian Loitsch
LGTM if you increase the buffer size to the max-double string. Please upload a new ...
10 years, 9 months ago (2010-03-23 12:34:54 UTC) #6
SeRya
Buffer size enlarged to 772. Added code checking if all of the dropped digits are ...
10 years, 9 months ago (2010-03-23 15:07:05 UTC) #7
Erik Corry
LGTM http://codereview.chromium.org/1096002/diff/3003/39003 File src/conversions.cc (right): http://codereview.chromium.org/1096002/diff/3003/39003#newcode280 src/conversions.cc:280: // Hexidecomal may have (52) / 4 + ...
10 years, 9 months ago (2010-03-25 12:26:16 UTC) #8
Florian Loitsch
10 years, 9 months ago (2010-03-25 13:51:35 UTC) #9
LGTM.

http://codereview.chromium.org/1096002/diff/3003/39003
File src/conversions.cc (right):

http://codereview.chromium.org/1096002/diff/3003/39003#newcode280
src/conversions.cc:280: // Hexidecomal may have (52) / 4 + 1 significant digit.
Mean of 2
On 2010/03/25 12:26:16, Erik Corry wrote:
> Hexidecomal -> Hexadecimal
> digit -> digits
> I can't understand the sentence that starts "Mean of 2"
Maybe the following explanation is easier to understand:
A double has a 53bit significand (once the hidden bit has been added). Halfway
cases thus have at most 54bits. Therefore 54/4 + 1 digits are sufficient to
represent halfway cases. By adding another digit we can keep track of dropped
digits.

This explanation is still not perfect, but probably better than the current
comment.

http://codereview.chromium.org/1096002/diff/3003/39003#newcode413
src/conversions.cc:413: return (buffer_pos > 0 && buffer[0] == '-') ? -result :
result;
On 2010/03/25 12:26:16, Erik Corry wrote:
> Should this be buffer[buffer_pos - 1]?
lgtm.

http://codereview.chromium.org/1096002/diff/3003/39003#newcode546
src/conversions.cc:546: // ALLOW_OCTALS has set and there is no '8' and '9' in
insignificant
ALLOW_OCTALS is set ...

http://codereview.chromium.org/1096002/diff/3003/39001
File test/cctest/test-conversions.cc (right):

http://codereview.chromium.org/1096002/diff/3003/39001#newcode154
test/cctest/test-conversions.cc:154: int n = snprintf(buffer, sizeof(buffer),
"%.1000Le", (a + b) / 2);
It is (imho) better not to rely on snprintf. Precomputing the string and pasting
it here will use up more than 10 lines, but at least there would be no
dependency on sprintf. Also it is not certain that sprintf behaves correctly on
all platforms (for instance on embedded devices).

Powered by Google App Engine
This is Rietveld 408576698