Ignore:
Timestamp:
Aug 27, 2010, 1:12:01 PM (15 years ago)
Author:
[email protected]
Message:

Bug 44745 - Number.toFixed/toExponential/toPrecision are inaccurate.

Reviewed by Oliver Hunt.

These methods should be using a version of dtoa that can generate results accurate
to the requested precision, whereas our version of dtoa is only currently able to
support producing results sufficiently accurate to distinguish the value from any
other IEEE-754 double precision number.

JavaScriptCore:

This change has no impact on benchmarks we track.

On microbenchmarks for these functions, this is a slight regression where a high
precision is requested (dtoa now need to iterate further to generate a a greater
number of digits), but with smaller precision values (hopefully more common) this
improves performance, since it reduced the accurate of result dtoa is required,
to produce, and removes the need to pre-round values before calling dtoa.

doubleToStringInJavaScriptFormat renamed to numberToString

doubleToStringInJavaScriptFormat renamed to numberToString

  • runtime/UString.cpp:

(JSC::UString::number):

doubleToStringInJavaScriptFormat renamed to numberToString

  • wtf/DecimalNumber.h:

(WTF::DecimalNumber::DecimalNumber):
(WTF::DecimalNumber::toStringDecimal):
(WTF::DecimalNumber::toStringExponential):

Remove all pre-rounding of values, instead call dtoa correctly.

  • wtf/dtoa.cpp:

(WTF::dtoa):

  • wtf/dtoa.h:

Reenable support for rounding to specific-figures/decimal-places in dtoa.
Modify to remove unbiased rounding, provide ECMA required away-from-zero.
Rewrite doubleToStringInJavaScriptFormat to use DecimalNumber, rename to
numberToString.

WebCore:

  • html/HTMLTreeBuilder.cpp:

(WebCore::serializeForNumberType):

doubleToStringInJavaScriptFormat renamed to numberToString.

LayoutTests:

Updating expected results, corrected errors in fast/js/kde/script-tests/Number.js
(corrected results confirmed with FireFox).

  • fast/js/kde/Number-expected.txt:
  • fast/js/kde/script-tests/Number.js:
  • fast/js/number-toExponential-expected.txt:
  • fast/js/number-tofixed-expected.txt:
  • fast/js/number-toprecision-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r66159 r66245  
    378378__ZN3WTF13tryFastMallocEm
    379379__ZN3WTF14fastMallocSizeEPKv
     380__ZN3WTF14numberToStringEdPt
    380381__ZN3WTF15ThreadCondition4waitERNS_5MutexE
    381382__ZN3WTF15ThreadCondition6signalEv
     
    412413__ZN3WTF27releaseFastMallocFreeMemoryEv
    413414__ZN3WTF28setMainThreadCallbacksPausedEb
    414 __ZN3WTF32doubleToStringInJavaScriptFormatEdPcPj
    415415__ZN3WTF36lockAtomicallyInitializedStaticMutexEv
    416416__ZN3WTF37parseDateFromNullTerminatedCharactersEPKc
Note: See TracChangeset for help on using the changeset viewer.