[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

barraclough at apple.com barraclough at apple.com
Wed Dec 22 12:40:39 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5fe1a538756f2f7a3d9287d6ab4356881744e4a2
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 27 00:38:54 2010 +0000

    Rubber Stamped by Oliver Hunt.
    
    Partially revert r65959. The toString changes regressed the v8 tests,
    but keep the toFixed/toExponential/toPrecision changes.
    
    JavaScriptCore:
    
    * JavaScriptCore.exp:
    * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
    * runtime/NumberPrototype.cpp:
    * runtime/UString.cpp:
    (JSC::UString::number):
    * wtf/DecimalNumber.h:
    * wtf/dtoa.cpp:
    (WTF::append):
    (WTF::doubleToStringInJavaScriptFormat):
    * wtf/dtoa.h:
    * wtf/text/WTFString.cpp:
    * wtf/text/WTFString.h:
    
    WebCore:
    
    * html/HTMLTreeBuilder.cpp:
    (WebCore::serializeForNumberType):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66159 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index e437156..eb0c0e8 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-08-26  Gavin Barraclough  <barraclough at apple.com>
+
+        Rubber Stamped by Oliver Hunt.
+
+        Partially revert r65959. The toString changes regressed the v8 tests,
+        but keep the toFixed/toExponential/toPrecision changes.
+
+        * JavaScriptCore.exp:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+        * runtime/NumberPrototype.cpp:
+        * runtime/UString.cpp:
+        (JSC::UString::number):
+        * wtf/DecimalNumber.h:
+        * wtf/dtoa.cpp:
+        (WTF::append):
+        (WTF::doubleToStringInJavaScriptFormat):
+        * wtf/dtoa.h:
+        * wtf/text/WTFString.cpp:
+        * wtf/text/WTFString.h:
+
 2010-08-26  James Robinson  <jamesr at chromium.org>
 
         Reviewed by Darin Fisher.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 4542730..4131e23 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -377,7 +377,6 @@ __ZN3WTF13currentThreadEv
 __ZN3WTF13tryFastCallocEmm
 __ZN3WTF13tryFastMallocEm
 __ZN3WTF14fastMallocSizeEPKv
-__ZN3WTF14numberToStringEdRA96_t
 __ZN3WTF15ThreadCondition4waitERNS_5MutexE
 __ZN3WTF15ThreadCondition6signalEv
 __ZN3WTF15ThreadCondition9broadcastEv
@@ -412,6 +411,7 @@ __ZN3WTF23dayInMonthFromDayInYearEib
 __ZN3WTF23waitForThreadCompletionEjPPv
 __ZN3WTF27releaseFastMallocFreeMemoryEv
 __ZN3WTF28setMainThreadCallbacksPausedEb
+__ZN3WTF32doubleToStringInJavaScriptFormatEdPcPj
 __ZN3WTF36lockAtomicallyInitializedStaticMutexEv
 __ZN3WTF37parseDateFromNullTerminatedCharactersEPKc
 __ZN3WTF38unlockAtomicallyInitializedStaticMutexEv
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index eac99b9..934688f 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -126,7 +126,7 @@ EXPORTS
     ?detach at Debugger@JSC@@UAEXPAVJSGlobalObject at 2@@Z
     ?detachThread at WTF@@YAXI at Z
     ?didTimeOut at TimeoutChecker@JSC@@QAE_NPAVExecState at 2@@Z
-    ?dtoa at WTF@@YAXQADNHPAH1PAPAD at Z
+    ?doubleToStringInJavaScriptFormat at WTF@@YAXNQADPAI at Z
     ?dumpSampleData at JSGlobalData@JSC@@QAEXPAVExecState at 2@@Z
     ?empty at StringImpl@WTF@@SAPAV12 at XZ
     ?enumerable at PropertyDescriptor@JSC@@QBE_NXZ
@@ -149,7 +149,6 @@ EXPORTS
     ?number at UString@JSC@@SA?AV12 at H@Z
     ?number at UString@JSC@@SA?AV12 at I@Z
     ?number at UString@JSC@@SA?AV12 at N@Z
-    ?numberToString at WTF@@YAINAAY0GA at _W@Z
     ?functionGetter at PropertySlot@JSC@@ABE?AVJSValue at 2@PAVExecState at 2@@Z
     ?functionName at DebuggerCallFrame@JSC@@QBEPBVUString at 2@XZ
     ?get at Structure@JSC@@QAEIPBVStringImpl at WTF@@AAIAAPAVJSCell at 2@@Z
diff --git a/JavaScriptCore/runtime/NumberPrototype.cpp b/JavaScriptCore/runtime/NumberPrototype.cpp
index 1a74375..e18553b 100644
--- a/JavaScriptCore/runtime/NumberPrototype.cpp
+++ b/JavaScriptCore/runtime/NumberPrototype.cpp
@@ -29,6 +29,7 @@
 #include "Operations.h"
 #include "PrototypeFunction.h"
 #include "StringBuilder.h"
+#include "dtoa.h"
 #include <wtf/Assertions.h>
 #include <wtf/DecimalNumber.h>
 #include <wtf/MathExtras.h>
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index 7362950..78e349b 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -26,6 +26,7 @@
 
 #include "JSGlobalObjectFunctions.h"
 #include "Collector.h"
+#include "dtoa.h"
 #include "Identifier.h"
 #include "Operations.h"
 #include <ctype.h>
@@ -38,7 +39,6 @@
 #include <wtf/MathExtras.h>
 #include <wtf/StringExtras.h>
 #include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
 #include <wtf/unicode/UTF8.h>
 
 #if HAVE(STRINGS_H)
@@ -198,8 +198,10 @@ UString UString::number(long l)
 
 UString UString::number(double d)
 {
-    NumberToStringBuffer buffer;
-    return StringImpl::create(buffer, numberToString(d, buffer));
+    DtoaBuffer buffer;
+    unsigned length;
+    doubleToStringInJavaScriptFormat(d, buffer, &length);
+    return UString(buffer, length);
 }
 
 UString UString::substringSharingImpl(unsigned offset, unsigned length) const
diff --git a/JavaScriptCore/wtf/DecimalNumber.h b/JavaScriptCore/wtf/DecimalNumber.h
index 118c492..a3e51b9 100644
--- a/JavaScriptCore/wtf/DecimalNumber.h
+++ b/JavaScriptCore/wtf/DecimalNumber.h
@@ -33,6 +33,9 @@
 
 namespace WTF {
 
+// Size = 80 for sizeof(DtoaBuffer) + some sign bits, decimal point, 'e', exponent digits.
+typedef UChar NumberToStringBuffer[96];
+
 enum RoundingSignificantFiguresType { RoundingSignificantFigures };
 enum RoundingDecimalPlacesType { RoundingDecimalPlaces };
 
@@ -321,6 +324,7 @@ private:
 
 } // namespace WTF
 
+using WTF::NumberToStringBuffer;
 using WTF::DecimalNumber;
 using WTF::RoundingSignificantFigures;
 using WTF::RoundingDecimalPlaces;
diff --git a/JavaScriptCore/wtf/dtoa.cpp b/JavaScriptCore/wtf/dtoa.cpp
index fdb07b7..38d182d 100644
--- a/JavaScriptCore/wtf/dtoa.cpp
+++ b/JavaScriptCore/wtf/dtoa.cpp
@@ -2278,4 +2278,83 @@ ret:
         *rve = s;
 }
 
+static ALWAYS_INLINE void append(char*& next, const char* src, unsigned size)
+{
+    for (unsigned i = 0; i < size; ++i)
+        *next++ = *src++;
+}
+
+void doubleToStringInJavaScriptFormat(double d, DtoaBuffer buffer, unsigned* resultLength)
+{
+    ASSERT(buffer);
+
+    // avoid ever printing -NaN, in JS conceptually there is only one NaN value
+    if (isnan(d)) {
+        append(buffer, "NaN", 3);
+        if (resultLength)
+            *resultLength = 3;
+        return;
+    }
+    // -0 -> "0"
+    if (!d) {
+        buffer[0] = '0';
+        if (resultLength)
+            *resultLength = 1;
+        return;
+    }
+
+    int decimalPoint;
+    int sign;
+
+    DtoaBuffer result;
+    char* resultEnd = 0;
+    WTF::dtoa(result, d, 0, &decimalPoint, &sign, &resultEnd);
+    int length = resultEnd - result;
+
+    char* next = buffer;
+    if (sign)
+        *next++ = '-';
+
+    if (decimalPoint <= 0 && decimalPoint > -6) {
+        *next++ = '0';
+        *next++ = '.';
+        for (int j = decimalPoint; j < 0; j++)
+            *next++ = '0';
+        append(next, result, length);
+    } else if (decimalPoint <= 21 && decimalPoint > 0) {
+        if (length <= decimalPoint) {
+            append(next, result, length);
+            for (int j = 0; j < decimalPoint - length; j++)
+                *next++ = '0';
+        } else {
+            append(next, result, decimalPoint);
+            *next++ = '.';
+            append(next, result + decimalPoint, length - decimalPoint);
+        }
+    } else if (result[0] < '0' || result[0] > '9')
+        append(next, result, length);
+    else {
+        *next++ = result[0];
+        if (length > 1) {
+            *next++ = '.';
+            append(next, result + 1, length - 1);
+        }
+
+        *next++ = 'e';
+        *next++ = (decimalPoint >= 0) ? '+' : '-';
+        // decimalPoint can't be more than 3 digits decimal given the
+        // nature of float representation
+        int exponential = decimalPoint - 1;
+        if (exponential < 0)
+            exponential = -exponential;
+        if (exponential >= 100)
+            *next++ = static_cast<char>('0' + exponential / 100);
+        if (exponential >= 10)
+            *next++ = static_cast<char>('0' + (exponential % 100) / 10);
+        *next++ = static_cast<char>('0' + exponential % 10);
+    }
+    if (resultLength)
+        *resultLength = next - buffer;
+}
+
 } // namespace WTF
diff --git a/JavaScriptCore/wtf/dtoa.h b/JavaScriptCore/wtf/dtoa.h
index bf00ccc..e0938ff 100644
--- a/JavaScriptCore/wtf/dtoa.h
+++ b/JavaScriptCore/wtf/dtoa.h
@@ -36,8 +36,14 @@ double strtod(const char* s00, char** se);
 typedef char DtoaBuffer[80];
 void dtoa(DtoaBuffer result, double d, int ndigits, int* decpt, int* sign, char** rve);
 
+// dtoa() for ECMA-262 'ToString Applied to the Number Type.'
+// The *resultLength will have the length of the resultant string in bufer.
+// The resultant string isn't terminated by 0.
+void doubleToStringInJavaScriptFormat(double, DtoaBuffer, unsigned* resultLength);
+
 } // namespace WTF
 
 using WTF::DtoaBuffer;
+using WTF::doubleToStringInJavaScriptFormat;
 
 #endif // WTF_dtoa_h
diff --git a/JavaScriptCore/wtf/text/WTFString.cpp b/JavaScriptCore/wtf/text/WTFString.cpp
index 3f7b39f..84b815a 100644
--- a/JavaScriptCore/wtf/text/WTFString.cpp
+++ b/JavaScriptCore/wtf/text/WTFString.cpp
@@ -25,10 +25,10 @@
 #include <limits>
 #include <stdarg.h>
 #include <wtf/ASCIICType.h>
-#include <wtf/DecimalNumber.h>
+#include <wtf/text/CString.h>
 #include <wtf/StringExtras.h>
 #include <wtf/Vector.h>
-#include <wtf/text/CString.h>
+#include <wtf/dtoa.h>
 #include <wtf/unicode/UTF8.h>
 #include <wtf/unicode/Unicode.h>
 
@@ -947,41 +947,6 @@ float charactersToFloat(const UChar* data, size_t length, bool* ok)
     return static_cast<float>(charactersToDouble(data, length, ok));
 }
 
-static unsigned copyToString(const char* string, unsigned length, NumberToStringBuffer& buffer)
-{
-    for (unsigned i = 0; i < length; ++i)
-        buffer[i] = string[i];
-    return length;
-}
-
-static NEVER_INLINE unsigned nanOrInfToString(double x, NumberToStringBuffer& buffer)
-{
-    ASSERT(isnan(x) || isinf(x));
-    if (isnan(x))
-        return copyToString("NaN", 3, buffer);
-    if (x < 0)
-        return copyToString("-Infinity", 9, buffer);
-    return copyToString("Infinity", 8, buffer);
-}
-
-// toString converts a number to a string without rounding. For values in the range
-// 1e-6 <= x < 1e+21 the result is formatted as a decimal, with values outside of
-// this range being formatted as an exponential.
-unsigned numberToString(double x, NumberToStringBuffer& buffer)
-{
-    // Handle NaN and Infinity.
-    if (UNLIKELY(isnan(x) || isinf(x)))
-        return nanOrInfToString(x, buffer);
-
-    // Convert to decimal, no rounding.
-    DecimalNumber number(x);
-
-    // Format as decimal or exponential, depending on the exponent.
-    return number.exponent() >= -6 && number.exponent() < 21
-        ? number.toStringDecimal(buffer)
-        : number.toStringExponential(buffer);
-}
-
 } // namespace WTF
 
 #ifndef NDEBUG
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index 8a6bab6..fafef12 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -52,10 +52,6 @@ class BString;
 
 namespace WTF {
 
-// Size = 80 for sizeof(DtoaBuffer) + some sign bits, decimal point, 'e', exponent digits.
-typedef UChar NumberToStringBuffer[96];
-unsigned numberToString(double, NumberToStringBuffer&);
-
 class CString;
 
 // Declarations of string operations
@@ -457,7 +453,4 @@ using WTF::charactersToInt;
 using WTF::charactersToFloat;
 using WTF::charactersToDouble;
 
-using WTF::NumberToStringBuffer;
-using WTF::numberToString;
-
 #endif
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 66aa2cc..3920af8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-08-26  Gavin Barraclough  <barraclough at apple.com>
+
+        Rubber Stamped by Oliver Hunt.
+
+        Partially revert r65959. The toString changes regressed the v8 tests,
+        but keep the toFixed/toExponential/toPrecision changes.
+
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::serializeForNumberType):
+
 2010-08-26  Mark Rowe  <mrowe at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/WebCore/html/HTMLTreeBuilder.cpp b/WebCore/html/HTMLTreeBuilder.cpp
index 24eb62f..4f4bb20 100644
--- a/WebCore/html/HTMLTreeBuilder.cpp
+++ b/WebCore/html/HTMLTreeBuilder.cpp
@@ -2850,9 +2850,11 @@ String serializeForNumberType(double number)
 {
     // According to HTML5, "the best representation of the number n as a floating
     // point number" is a string produced by applying ToString() to n.
-    NumberToStringBuffer buffer;
-    return String(buffer, numberToString(number, buffer));
- }
+    DtoaBuffer buffer;
+    unsigned length;
+    doubleToStringInJavaScriptFormat(number, buffer, &length);
+    return String(buffer, length);
+}
 
 // FIXME: Move this function to a more appropriate place.
 bool parseToDoubleForNumberType(const String& src, double* out)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list