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

Issue 944863002: dart2js: don't emit big integers as integer, but instead use their exponential representation. (Closed)

Created:
5 years, 10 months ago by floitsch
Modified:
5 years, 10 months ago
Reviewers:
herhut, sra1
CC:
reviews_dartlang.org, sra1
Target Ref:
refs/heads/master
Visibility:
Public.

Description

dart2js: don't emit big integers as integer, but instead use their exponential representation. BUG= http://dartbug.com/16600 R=herhut@google.com Committed: https://code.google.com/p/dart/source/detail?r=43913

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -1 line) Patch
M pkg/compiler/lib/src/js_backend/constant_emitter.dart View 1 chunk +16 lines, -1 line 4 comments Download
A tests/compiler/dart2js/number_output_test.dart View 1 chunk +33 lines, -0 lines 2 comments Download

Messages

Total messages: 7 (2 generated)
floitsch
5 years, 10 months ago (2015-02-20 13:33:42 UTC) #2
herhut
lgtm
5 years, 10 months ago (2015-02-20 13:57:31 UTC) #3
floitsch
Committed patchset #1 (id:1) manually as 43913 (presubmit successful).
5 years, 10 months ago (2015-02-20 14:29:53 UTC) #4
sra1
I think I would keep "1000" for the sanity of the reader and only generate ...
5 years, 10 months ago (2015-02-20 17:02:54 UTC) #6
floitsch
5 years, 10 months ago (2015-02-20 20:23:21 UTC) #7
Message was sent while issue was closed.
Didn't test gzip. It most likely depends on the program. The main-benefit of
this patch is to make sure we don't emit 308 characters for some constants...

https://codereview.chromium.org/944863002/diff/1/pkg/compiler/lib/src/js_back...
File pkg/compiler/lib/src/js_backend/constant_emitter.dart (right):

https://codereview.chromium.org/944863002/diff/1/pkg/compiler/lib/src/js_back...
pkg/compiler/lib/src/js_backend/constant_emitter.dart:208: // For example:
"1e+4" is shorter than "10000".
On 2015/02/20 17:02:54, sra1 wrote:
> The + is not necessary, making "1e3" shorter than "1000".
> The period is never necessary for integer values:
> 
> 1.2e+10 ->  12e9
> 
> I might be a bit nervous about hacking the string output outside the
> exact-integer (2^53) range, but the parser should be just counting digits to
> adjust the exponent before dividing.
> 
> Make sure all this works when running dart2js self-compiled, when the 'int' is
> represented as an integer valued double.  This basically means you can't rely
on
> the int toString() returning only digits.

https://codereview.chromium.org/938323003

https://codereview.chromium.org/944863002/diff/1/pkg/compiler/lib/src/js_back...
pkg/compiler/lib/src/js_backend/constant_emitter.dart:212: // However, since
JavaScript engines implicitly convert to double, these
On 2015/02/20 17:02:54, sra1 wrote:
> nit. They don't 'implicitly convert to' so much as 'represent as'.

done in https://codereview.chromium.org/938323003

https://codereview.chromium.org/944863002/diff/1/tests/compiler/dart2js/numbe...
File tests/compiler/dart2js/number_output_test.dart (right):

https://codereview.chromium.org/944863002/diff/1/tests/compiler/dart2js/numbe...
tests/compiler/dart2js/number_output_test.dart:24:
Expect.isTrue(jsOutput.contains('1.23e+7')); // Shorter than 12300000.
On 2015/02/20 17:02:54, sra1 wrote:
> 123e5 would be better

https://codereview.chromium.org/938323003

Powered by Google App Engine
This is Rietveld 408576698