2007-11-13 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2007 20:37:17 +0000 (20:37 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2007 20:37:17 +0000 (20:37 +0000)
        Reviewed by Maciej.

        Add an ASSERT to getTruncatedInt32 to enforce proper usage.
        Best part about this patch?  It doesn't break the web!

        * kjs/JSImmediate.h:
        (KJS::JSImmediate::getTruncatedInt32):
        (KJS::JSImmediate::toDouble):
        (KJS::JSImmediate::getUInt32):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27759 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/kjs/JSImmediate.h

index 6186a004a02a5540098931fc5ef636f0f7524803..52eb6121fdc5d228ae6daa5fccb14a52d69f5c45 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-13  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Maciej.
+
+        Add an ASSERT to getTruncatedInt32 to enforce proper usage.
+        Best part about this patch?  It doesn't break the web!
+
+        * kjs/JSImmediate.h:
+        (KJS::JSImmediate::getTruncatedInt32):
+        (KJS::JSImmediate::toDouble):
+        (KJS::JSImmediate::getUInt32):
+
 2007-11-13  Alexey Proskuryakov  <ap@webkit.org>
 
         Windows build fix.
index 7cef1e5cd2b73b640fb81e1fac6967feba124ad0..4fb511299e20bf5f59a556e3650449d8c88724e1 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
index dfcf2bc29af3222ad5b7b08a904c8abf1921a0f8..049b4c71704c00fcc7036c390f4d43d8d6228359 100644 (file)
@@ -242,13 +242,14 @@ ALWAYS_INLINE JSValue* JSImmediate::from(double d)
 
 ALWAYS_INLINE int32_t JSImmediate::getTruncatedInt32(const JSValue* v)
 {
+    ASSERT(isNumber(v));
     return static_cast<int32_t>(unTag(v)) >> 2;
 }
 
 ALWAYS_INLINE double JSImmediate::toDouble(const JSValue* v)
 {
     ASSERT(isImmediate(v));
-    const int32_t i = getTruncatedInt32(v);
+    const int32_t i = static_cast<int32_t>(unTag(v)) >> 2;
     if (JSImmediate::getTag(v) == UndefinedType && i)
         return std::numeric_limits<double>::quiet_NaN();
     return i;
@@ -256,14 +257,14 @@ ALWAYS_INLINE double JSImmediate::toDouble(const JSValue* v)
 
 ALWAYS_INLINE bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i)
 {
-    const int32_t si = getTruncatedInt32(v);
+    const int32_t si = static_cast<int32_t>(unTag(v)) >> 2;
     i = si;
     return isNumber(v) & (si >= 0);
 }
 
 ALWAYS_INLINE bool JSImmediate::getTruncatedInt32(const JSValue* v, int32_t& i)
 {
-    i = getTruncatedInt32(v);
+    i = static_cast<int32_t>(unTag(v)) >> 2;
     return isNumber(v);
 }