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

mjs mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:31:20 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit eb7023efeed22a37186e0dfa69dc77c7c47f59b3
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 15 03:19:38 2002 +0000

            Simplified array handling by using NULL to represent empty cells
    	instead of the Undefined object, so we can use calloc, realloc and
    	memset instead of loops. Inspired by a suggestion of Darin's.
    
    	* kjs/array_object.cpp:
            (ArrayInstanceImp::ArrayInstanceImp):
            (ArrayInstanceImp::~ArrayInstanceImp):
            (ArrayInstanceImp::get):
            (ArrayInstanceImp::hasProperty):
            (ArrayInstanceImp::deleteProperty):
            (ArrayInstanceImp::setLength):
            (ArrayInstanceImp::mark):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1822 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 3f3624d..d738aa0 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,20 @@
 2002-08-14  Maciej Stachowiak  <mjs at apple.com>
 
+        Simplified array handling by using NULL to represent empty cells
+	instead of the Undefined object, so we can use calloc, realloc and
+	memset instead of loops. Inspired by a suggestion of Darin's.
+
+	* kjs/array_object.cpp:
+        (ArrayInstanceImp::ArrayInstanceImp):
+        (ArrayInstanceImp::~ArrayInstanceImp):
+        (ArrayInstanceImp::get):
+        (ArrayInstanceImp::hasProperty):
+        (ArrayInstanceImp::deleteProperty):
+        (ArrayInstanceImp::setLength):
+        (ArrayInstanceImp::mark):
+
+2002-08-14  Maciej Stachowiak  <mjs at apple.com>
+
         Fix major JavaScript memory leak. run-plt says cvs-base improved
 	by 2% and cvs-js-performance improved by 7%. However, this was
 	within the possible noise level in each case.
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 3f3624d..d738aa0 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,5 +1,20 @@
 2002-08-14  Maciej Stachowiak  <mjs at apple.com>
 
+        Simplified array handling by using NULL to represent empty cells
+	instead of the Undefined object, so we can use calloc, realloc and
+	memset instead of loops. Inspired by a suggestion of Darin's.
+
+	* kjs/array_object.cpp:
+        (ArrayInstanceImp::ArrayInstanceImp):
+        (ArrayInstanceImp::~ArrayInstanceImp):
+        (ArrayInstanceImp::get):
+        (ArrayInstanceImp::hasProperty):
+        (ArrayInstanceImp::deleteProperty):
+        (ArrayInstanceImp::setLength):
+        (ArrayInstanceImp::mark):
+
+2002-08-14  Maciej Stachowiak  <mjs at apple.com>
+
         Fix major JavaScript memory leak. run-plt says cvs-base improved
 	by 2% and cvs-js-performance improved by 7%. However, this was
 	within the possible noise level in each case.
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 3f3624d..d738aa0 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,5 +1,20 @@
 2002-08-14  Maciej Stachowiak  <mjs at apple.com>
 
+        Simplified array handling by using NULL to represent empty cells
+	instead of the Undefined object, so we can use calloc, realloc and
+	memset instead of loops. Inspired by a suggestion of Darin's.
+
+	* kjs/array_object.cpp:
+        (ArrayInstanceImp::ArrayInstanceImp):
+        (ArrayInstanceImp::~ArrayInstanceImp):
+        (ArrayInstanceImp::get):
+        (ArrayInstanceImp::hasProperty):
+        (ArrayInstanceImp::deleteProperty):
+        (ArrayInstanceImp::setLength):
+        (ArrayInstanceImp::mark):
+
+2002-08-14  Maciej Stachowiak  <mjs at apple.com>
+
         Fix major JavaScript memory leak. run-plt says cvs-base improved
 	by 2% and cvs-js-performance improved by 7%. However, this was
 	within the possible noise level in each case.
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 6a7a2aa..dcf2203 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -43,12 +43,8 @@ ArrayInstanceImp::ArrayInstanceImp(const Object &proto, unsigned initialLength)
   : ObjectImp(proto)
   , length(initialLength)
   , capacity(length)
-  , storage(length ? new (ValueImp *)[length] : 0)
+  , storage(length ? (ValueImp **)calloc(length, sizeof(ValueImp *)) : 0)
 {
-  unsigned l = length;
-  for (unsigned i = 0; i < l; ++i) {
-    storage[i] = Undefined().imp();
-  }
 }
 
 ArrayInstanceImp::ArrayInstanceImp(const Object &proto, const List &list)
@@ -66,7 +62,7 @@ ArrayInstanceImp::ArrayInstanceImp(const Object &proto, const List &list)
 
 ArrayInstanceImp::~ArrayInstanceImp()
 {
-  delete [] storage;
+  free (storage);
 }
 
 Value ArrayInstanceImp::get(ExecState *exec, const UString &propertyName) const
@@ -77,7 +73,7 @@ Value ArrayInstanceImp::get(ExecState *exec, const UString &propertyName) const
   bool ok;
   unsigned index = propertyName.toULong(&ok);
   if (ok) {
-    if (index >= length)
+    if (index >= length || storage[index] == NULL)
       return Undefined();
     return Value(storage[index]);
   }
@@ -87,7 +83,7 @@ Value ArrayInstanceImp::get(ExecState *exec, const UString &propertyName) const
 
 Value ArrayInstanceImp::get(ExecState *exec, unsigned index) const
 {
-  if (index >= length)
+  if (index >= length || storage[index] == NULL)
     return Undefined();
   return Value(storage[index]);
 }
@@ -127,7 +123,7 @@ bool ArrayInstanceImp::hasProperty(ExecState *exec, const UString &propertyName)
   if (ok) {
     if (index >= length)
       return false;
-    return storage[index]->type() != UndefinedType;
+    return storage[index] != NULL && storage[index]->type() != UndefinedType;
   }
   
   return ObjectImp::hasProperty(exec, propertyName);
@@ -137,7 +133,7 @@ bool ArrayInstanceImp::hasProperty(ExecState *exec, unsigned index) const
 {
   if (index >= length)
     return false;
-  return storage[index]->type() != UndefinedType;
+  return storage[index] != NULL && storage[index]->type() != UndefinedType;
 }
 
 bool ArrayInstanceImp::deleteProperty(ExecState *exec, const UString &propertyName)
@@ -150,7 +146,7 @@ bool ArrayInstanceImp::deleteProperty(ExecState *exec, const UString &propertyNa
   if (ok) {
     if (index >= length)
       return true;
-    storage[index] = Undefined().imp();
+    storage[index] = NULL;
     return true;
   }
   
@@ -161,27 +157,19 @@ bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index)
 {
   if (index >= length)
     return true;
-  storage[index] = Undefined().imp();
+  storage[index] = NULL;
   return true;
 }
 
 void ArrayInstanceImp::setLength(unsigned newLength)
 {
   if (newLength < length) {
-    const unsigned l = length;
-    for (unsigned i = newLength; i < l; ++i)
-      storage[i] = Undefined().imp();
+    memset(storage + newLength, 0, sizeof(ValueImp *) * (length - newLength));
   }
   if (newLength > capacity) {
     unsigned newCapacity = (newLength * 3 + 1) / 2;
-    ValueImp **newStorage = new (ValueImp *)[newCapacity];
-    const unsigned l = length;
-    for (unsigned i = 0; i < l; ++i)
-      newStorage[i] = storage[i];
-    for (unsigned i = l; i < newLength; i++)
-      newStorage[i] = Undefined().imp();
-    delete [] storage;
-    storage = newStorage;
+    storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *));
+    memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity));
     capacity = newCapacity;
   }
   length = newLength;
@@ -193,7 +181,7 @@ void ArrayInstanceImp::mark()
   const unsigned l = length;
   for (unsigned i = 0; i < l; ++i) {
     ValueImp *imp = storage[i];
-    if (!imp->marked())
+    if (imp != NULL && !imp->marked())
       imp->mark();
   }
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list