Title: [91555] trunk/Source/_javascript_Core
Revision
91555
Author
[email protected]
Date
2011-07-21 22:34:08 -0700 (Thu, 21 Jul 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=19271
eliminate PIC branches by changing NaN handling in JSValue::toNumber

Reviewed by Sam Weinig.

Moving the non-numeric cases out of line seems to be a consistent
win on SunSpider for me, to the order of about 0.5%.

* runtime/JSCell.h:
(JSC::JSCell::JSValue::toNumber):
    - Changed to only handle values that are already numbers, moce non-numeric cases out of line.
* runtime/JSValue.cpp:
(JSC::JSValue::toNumberSlowCase):
    - Added toNumberSlowCase, handling non-numeric cases.
* runtime/JSValue.h:
    - Add declaration of toNumberSlowCase.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (91554 => 91555)


--- trunk/Source/_javascript_Core/ChangeLog	2011-07-22 05:27:03 UTC (rev 91554)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-07-22 05:34:08 UTC (rev 91555)
@@ -1,5 +1,24 @@
 2011-07-21  Gavin Barraclough  <[email protected]>
 
+        https://bugs.webkit.org/show_bug.cgi?id=19271
+        eliminate PIC branches by changing NaN handling in JSValue::toNumber
+
+        Reviewed by Sam Weinig.
+
+        Moving the non-numeric cases out of line seems to be a consistent
+        win on SunSpider for me, to the order of about 0.5%.
+
+        * runtime/JSCell.h:
+        (JSC::JSCell::JSValue::toNumber):
+            - Changed to only handle values that are already numbers, moce non-numeric cases out of line.
+        * runtime/JSValue.cpp:
+        (JSC::JSValue::toNumberSlowCase):
+            - Added toNumberSlowCase, handling non-numeric cases.
+        * runtime/JSValue.h:
+            - Add declaration of toNumberSlowCase.
+
+2011-07-21  Gavin Barraclough  <[email protected]>
+
         https://bugs.webkit.org/show_bug.cgi?id=64875
         Use of `yield` keyword is broken
 

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (91554 => 91555)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-07-22 05:27:03 UTC (rev 91554)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-07-22 05:34:08 UTC (rev 91555)
@@ -324,11 +324,7 @@
             return asInt32();
         if (isDouble())
             return asDouble();
-        if (isCell())
-            return asCell()->toNumber(exec);
-        if (isTrue())
-            return 1.0;
-        return isUndefined() ? std::numeric_limits<double>::quiet_NaN() : 0; // null and false both convert to 0.
+        return toNumberSlowCase(exec);
     }
 
     inline JSValue JSValue::getJSNumber()

Modified: trunk/Source/_javascript_Core/runtime/JSValue.cpp (91554 => 91555)


--- trunk/Source/_javascript_Core/runtime/JSValue.cpp	2011-07-22 05:27:03 UTC (rev 91554)
+++ trunk/Source/_javascript_Core/runtime/JSValue.cpp	2011-07-22 05:34:08 UTC (rev 91555)
@@ -54,6 +54,16 @@
     return trunc(toNumber(exec));
 }
 
+double JSValue::toNumberSlowCase(ExecState* exec) const
+{
+    ASSERT(!isInt32() && !isDouble());
+    if (isCell())
+        return asCell()->toNumber(exec);
+    if (isTrue())
+        return 1.0;
+    return isUndefined() ? std::numeric_limits<double>::quiet_NaN() : 0; // null and false both convert to 0.
+}
+
 JSObject* JSValue::toObjectSlowCase(ExecState* exec, JSGlobalObject* globalObject) const
 {
     ASSERT(!isCell());

Modified: trunk/Source/_javascript_Core/runtime/JSValue.h (91554 => 91555)


--- trunk/Source/_javascript_Core/runtime/JSValue.h	2011-07-22 05:27:03 UTC (rev 91554)
+++ trunk/Source/_javascript_Core/runtime/JSValue.h	2011-07-22 05:34:08 UTC (rev 91555)
@@ -236,6 +236,7 @@
         JSValue(HashTableDeletedValueTag);
 
         inline const JSValue asValue() const { return *this; }
+        double toNumberSlowCase(ExecState*) const;
         JSObject* toObjectSlowCase(ExecState*, JSGlobalObject*) const;
         JSObject* toThisObjectSlowCase(ExecState*) const;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to