[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:47:16 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 08e4b21a0160440cc04524410cf308780707aa95
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jul 13 21:40:45 2003 +0000

            Reviewed by Maciej.
    
            - do some improvements Maciej suggested while reviewing the array index change
    
            * kjs/array_object.cpp:
            (getArrayIndex): Return a flag to say whether the index was value separately, to avoid
            in-band signalling.
            (ArrayInstanceImp::get): Update for new getArrayIndex parameters.
            (ArrayInstanceImp::put): Ditto.
            (ArrayInstanceImp::hasProperty): Ditto.
            (ArrayInstanceImp::setLength): Ditto.
    
            * kjs/ustring.cpp: (UString::toStrictUInt32): Check for overflow in a way that avoids doing
            a divide every time through the loop. But note that it adds an extra branch to the loop.
            I wonder which is worse.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4639 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index a9ceb59..59a9ea1 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,21 @@
+2003-07-13  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - do some improvements Maciej suggested while reviewing the array index change
+
+        * kjs/array_object.cpp:
+        (getArrayIndex): Return a flag to say whether the index was value separately, to avoid
+        in-band signalling.
+        (ArrayInstanceImp::get): Update for new getArrayIndex parameters.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::setLength): Ditto.
+        
+        * kjs/ustring.cpp: (UString::toStrictUInt32): Check for overflow in a way that avoids doing
+        a divide every time through the loop. But note that it adds an extra branch to the loop.
+        I wonder which is worse.
+
 2003-07-12  Darin Adler  <darin at apple.com>
 
         Fixed broken build.
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index a9ceb59..59a9ea1 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,21 @@
+2003-07-13  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - do some improvements Maciej suggested while reviewing the array index change
+
+        * kjs/array_object.cpp:
+        (getArrayIndex): Return a flag to say whether the index was value separately, to avoid
+        in-band signalling.
+        (ArrayInstanceImp::get): Update for new getArrayIndex parameters.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::setLength): Ditto.
+        
+        * kjs/ustring.cpp: (UString::toStrictUInt32): Check for overflow in a way that avoids doing
+        a divide every time through the loop. But note that it adds an extra branch to the loop.
+        I wonder which is worse.
+
 2003-07-12  Darin Adler  <darin at apple.com>
 
         Fixed broken build.
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 42fcbfa..8afe630 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -72,17 +72,14 @@ ArrayInstanceImp::~ArrayInstanceImp()
 
 // Rule from ECMA 15.2 about what an array index is.
 // Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
-
-const unsigned maxUInt32 = 0xFFFFFFFFU;
-const unsigned notArrayIndex = maxUInt32;
-
-unsigned getArrayIndex(const Identifier &propertyName)
+bool getArrayIndex(const Identifier &propertyName, unsigned &index)
 {
   bool ok;
-  unsigned index = propertyName.toStrictUInt32(&ok);
-  if (!ok || index >= maxUInt32)
-    return notArrayIndex;
-  return index;
+  unsigned i = propertyName.toStrictUInt32(&ok);
+  if (!ok || i >= 0xFFFFFFFFU)
+    return false;
+  index = i;
+  return true;
 }
 
 Value ArrayInstanceImp::get(ExecState *exec, const Identifier &propertyName) const
@@ -90,8 +87,8 @@ Value ArrayInstanceImp::get(ExecState *exec, const Identifier &propertyName) con
   if (propertyName == lengthPropertyName)
     return Number(length);
 
-  unsigned index = getArrayIndex(propertyName);
-  if (index != notArrayIndex) {
+  unsigned index;
+  if (getArrayIndex(propertyName, index)) {
     if (index >= length)
       return Undefined();
     if (index < storageLength) {
@@ -123,8 +120,8 @@ void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, cons
     return;
   }
   
-  unsigned index = getArrayIndex(propertyName);
-  if (index != notArrayIndex) {
+  unsigned index;
+  if (getArrayIndex(propertyName, index)) {
     put(exec, index, value, attr);
     return;
   }
@@ -156,8 +153,8 @@ bool ArrayInstanceImp::hasProperty(ExecState *exec, const Identifier &propertyNa
   if (propertyName == lengthPropertyName)
     return true;
   
-  unsigned index = getArrayIndex(propertyName);
-  if (index != notArrayIndex) {
+  unsigned index;
+  if (getArrayIndex(propertyName, index)) {
     if (index >= length)
       return false;
     if (index < storageLength) {
@@ -264,8 +261,8 @@ void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec)
     ReferenceListIterator it = sparseProperties.begin();
     while (it != sparseProperties.end()) {
       Reference ref = it++;
-      unsigned index = getArrayIndex(ref.getPropertyName(exec));
-      if (index != notArrayIndex && index > newLength) {
+      unsigned index;
+      if (getArrayIndex(ref.getPropertyName(exec), index) && index > newLength) {
 	ref.deleteValue(exec);
       }
     }
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index 1e788fb..30d975a 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -685,13 +685,15 @@ uint32_t UString::toStrictUInt32(bool *ok) const
       return 0;
     const unsigned d = c - '0';
     
-    // Check for overflow.
-    const unsigned maxProduct = 0xFFFFFFFFU - d;
-    if (i > maxProduct / 10)
+    // Multiply by 10, checking for overflow out of 32 bits.
+    if (i > 0xFFFFFFFFU / 10)
       return 0;
-    
-    // Add in another digit.
     i *= 10;
+    
+    // Add in the digit, checking for overflow out of 32 bits.
+    const unsigned max = 0xFFFFFFFFU - d;
+    if (i > max)
+        return 0;
     i += d;
     
     // Handle end of string.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list