[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:05:00 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 1a2088413115dd1ed08cc88218e1cce8048af367
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 20 21:49:31 2002 +0000

    	- oops, checked in big regression instead of 5% speedup
    
            * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking
    	list, not a refing list.
    
    	- a cut at the sparse array implementation
    
            * kjs/array_instance.h: Keep storageLength separate from length.
            * kjs/array_object.cpp:
            (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length.
            (ArrayInstanceImp::get): Check against storage length.
            (ArrayInstanceImp::put): Ditto.
            (ArrayInstanceImp::hasProperty): Ditto.
            (ArrayInstanceImp::deleteProperty): Ditto.
            (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff.
            (ArrayInstanceImp::mark): Use storageLength.
            (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2786 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 351a31b..85066b9 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,25 @@
 2002-11-20  Darin Adler  <darin at apple.com>
 
+	- oops, checked in big regression instead of 5% speedup
+
+        * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking
+	list, not a refing list.
+
+	- a cut at the sparse array implementation
+
+        * kjs/array_instance.h: Keep storageLength separate from length.
+        * kjs/array_object.cpp:
+        (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length.
+        (ArrayInstanceImp::get): Check against storage length.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::deleteProperty): Ditto.
+        (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff.
+        (ArrayInstanceImp::mark): Use storageLength.
+        (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME.
+
+2002-11-20  Darin Adler  <darin at apple.com>
+
 	- decrease ref/deref -- 5% speedup in iBench
 
         * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 351a31b..85066b9 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,5 +1,25 @@
 2002-11-20  Darin Adler  <darin at apple.com>
 
+	- oops, checked in big regression instead of 5% speedup
+
+        * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking
+	list, not a refing list.
+
+	- a cut at the sparse array implementation
+
+        * kjs/array_instance.h: Keep storageLength separate from length.
+        * kjs/array_object.cpp:
+        (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length.
+        (ArrayInstanceImp::get): Check against storage length.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::deleteProperty): Ditto.
+        (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff.
+        (ArrayInstanceImp::mark): Use storageLength.
+        (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME.
+
+2002-11-20  Darin Adler  <darin at apple.com>
+
 	- decrease ref/deref -- 5% speedup in iBench
 
         * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 351a31b..85066b9 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,5 +1,25 @@
 2002-11-20  Darin Adler  <darin at apple.com>
 
+	- oops, checked in big regression instead of 5% speedup
+
+        * kjs/function.cpp: (ActivationImp::ActivationImp): Make a marking
+	list, not a refing list.
+
+	- a cut at the sparse array implementation
+
+        * kjs/array_instance.h: Keep storageLength separate from length.
+        * kjs/array_object.cpp:
+        (ArrayInstanceImp::ArrayInstanceImp): Start with storageLength == length.
+        (ArrayInstanceImp::get): Check against storage length.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::deleteProperty): Ditto.
+        (ArrayInstanceImp::setLength): Only enlarge storage length up to a cutoff.
+        (ArrayInstanceImp::mark): Use storageLength.
+        (ArrayInstanceImp::pushUndefinedObjectsToEnd): Added FIXME.
+
+2002-11-20  Darin Adler  <darin at apple.com>
+
 	- decrease ref/deref -- 5% speedup in iBench
 
         * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
diff --git a/JavaScriptCore/kjs/array_instance.h b/JavaScriptCore/kjs/array_instance.h
index fbce820..860065f 100644
--- a/JavaScriptCore/kjs/array_instance.h
+++ b/JavaScriptCore/kjs/array_instance.h
@@ -57,6 +57,7 @@ namespace KJS {
     unsigned pushUndefinedObjectsToEnd();
     
     unsigned length;
+    unsigned storageLength;
     unsigned capacity;
     ValueImp **storage;
   };
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 9761ea2..2fe7216 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -37,21 +37,25 @@ using namespace KJS;
 
 // ------------------------------ ArrayInstanceImp -----------------------------
 
+const unsigned sparseArrayCutoff = 10000;
+
 const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0};
 
 ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, unsigned initialLength)
   : ObjectImp(proto)
   , length(initialLength)
-  , capacity(length)
-  , storage(length ? (ValueImp **)calloc(length, sizeof(ValueImp *)) : 0)
+  , storageLength(initialLength)
+  , capacity(storageLength)
+  , storage(capacity ? (ValueImp **)calloc(capacity, sizeof(ValueImp *)) : 0)
 {
 }
 
 ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, const List &list)
   : ObjectImp(proto)
   , length(list.size())
-  , capacity(length)
-  , storage(length ? (ValueImp **)malloc(sizeof(ValueImp *) * length) : 0)
+  , storageLength(length)
+  , capacity(storageLength)
+  , storage(capacity ? (ValueImp **)malloc(sizeof(ValueImp *) * capacity) : 0)
 {
   ListIterator it = list.begin();
   unsigned l = length;
@@ -75,8 +79,10 @@ Value ArrayInstanceImp::get(ExecState *exec, const Identifier &propertyName) con
   if (ok) {
     if (index >= length)
       return Undefined();
-    ValueImp *v = storage[index];
-    return v ? Value(v) : Undefined();
+    if (index < storageLength) {
+      ValueImp *v = storage[index];
+      return v ? Value(v) : Undefined();
+    }
   }
 
   return ObjectImp::get(exec, propertyName);
@@ -86,8 +92,12 @@ Value ArrayInstanceImp::get(ExecState *exec, unsigned index) const
 {
   if (index >= length)
     return Undefined();
-  ValueImp *v = storage[index];
-  return v ? Value(v) : Undefined();
+  if (index < storageLength) {
+    ValueImp *v = storage[index];
+    return v ? Value(v) : Undefined();
+  }
+  
+  return ObjectImp::get(exec, Identifier::from(index));
 }
 
 // Special implementation of [[Put]] - see ECMA 15.4.5.1
@@ -103,8 +113,10 @@ void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, cons
   if (ok) {
     if (length <= index)
       setLength(index + 1);
-    storage[index] = value.imp();
-    return;
+    if (index < storageLength) {
+      storage[index] = value.imp();
+      return;
+    }
   }
   
   ObjectImp::put(exec, propertyName, value, attr);
@@ -114,7 +126,12 @@ void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value,
 {
   if (length <= index)
     setLength(index + 1);
-  storage[index] = value.imp();
+  if (index < storageLength) {
+    storage[index] = value.imp();
+    return;
+  }
+  
+  ObjectImp::put(exec, Identifier::from(index), value, attr);
 }
 
 bool ArrayInstanceImp::hasProperty(ExecState *exec, const Identifier &propertyName) const
@@ -127,8 +144,10 @@ bool ArrayInstanceImp::hasProperty(ExecState *exec, const Identifier &propertyNa
   if (ok) {
     if (index >= length)
       return false;
-    ValueImp *v = storage[index];
-    return v && v != UndefinedImp::staticUndefined;
+    if (index < storageLength) {
+      ValueImp *v = storage[index];
+      return v && v != UndefinedImp::staticUndefined;
+    }
   }
   
   return ObjectImp::hasProperty(exec, propertyName);
@@ -138,8 +157,12 @@ bool ArrayInstanceImp::hasProperty(ExecState *exec, unsigned index) const
 {
   if (index >= length)
     return false;
-  ValueImp *v = storage[index];
-  return v && v != UndefinedImp::staticUndefined;
+  if (index < storageLength) {
+    ValueImp *v = storage[index];
+    return v && v != UndefinedImp::staticUndefined;
+  }
+  
+  return ObjectImp::hasProperty(exec, Identifier::from(index));
 }
 
 bool ArrayInstanceImp::deleteProperty(ExecState *exec, const Identifier &propertyName)
@@ -152,8 +175,10 @@ bool ArrayInstanceImp::deleteProperty(ExecState *exec, const Identifier &propert
   if (ok) {
     if (index >= length)
       return true;
-    storage[index] = 0;
-    return true;
+    if (index < storageLength) {
+      storage[index] = 0;
+      return true;
+    }
   }
   
   return ObjectImp::deleteProperty(exec, propertyName);
@@ -163,28 +188,39 @@ bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index)
 {
   if (index >= length)
     return true;
-  storage[index] = 0;
-  return true;
+  if (index < storageLength) {
+    storage[index] = 0;
+    return true;
+  }
+  
+  return ObjectImp::deleteProperty(exec, Identifier::from(index));
 }
 
 void ArrayInstanceImp::setLength(unsigned newLength)
 {
-  if (newLength < length) {
-    memset(storage + newLength, 0, sizeof(ValueImp *) * (length - newLength));
-  }
-  if (newLength > capacity) {
-    unsigned newCapacity = (newLength * 3 + 1) / 2;
-    storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *));
-    memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity));
-    capacity = newCapacity;
+  if (newLength <= sparseArrayCutoff || newLength == length + 1) {
+    if (newLength < storageLength) {
+      memset(storage + newLength, 0, sizeof(ValueImp *) * (storageLength - newLength));
+    }
+    if (newLength > capacity) {
+      unsigned newCapacity = (newLength * 3 + 1) / 2;
+      storage = (ValueImp **)realloc(storage, newCapacity * sizeof (ValueImp *));
+      memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity));
+      capacity = newCapacity;
+    }
+    storageLength = newLength;
   }
+  
+  // FIXME: Need to remove items from the property map when making a sparse
+  // list shorter.
+  
   length = newLength;
 }
 
 void ArrayInstanceImp::mark()
 {
   ObjectImp::mark();
-  unsigned l = length;
+  unsigned l = storageLength;
   for (unsigned i = 0; i < l; ++i) {
     ValueImp *imp = storage[i];
     if (imp && !imp->marked())
@@ -252,7 +288,8 @@ unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd()
     ValueImp *undefined = UndefinedImp::staticUndefined;
 
     unsigned o = 0;
-    for (unsigned i = 0; i != length; ++i) {
+    
+    for (unsigned i = 0; i != storageLength; ++i) {
         ValueImp *v = storage[i];
         if (v && v != undefined) {
             if (o != i)
@@ -260,8 +297,12 @@ unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd()
             o++;
         }
     }
-    if (o != length)
-        memset(storage + o, 0, sizeof(ValueImp *) * (length - o));
+    
+    // FIXME: Get sparse items down here.
+    
+    if (o != storageLength)
+        memset(storage + o, 0, sizeof(ValueImp *) * (storageLength - o));
+    
     return o;
 }
 
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index fe6e5e1..43d5f82 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -330,9 +330,10 @@ const ClassInfo ActivationImp::info = {"Activation", 0, 0, 0};
 
 // ECMA 10.1.6
 ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args)
-  : _function(f), _arguments(args)
+  : _function(f), _arguments(true)
 {
   Value protect(this);
+  _arguments = args;
   _argumentsObject = new ArgumentsImp(exec, f, args);
   putDirect(argumentsPropertyName, _argumentsObject, Internal|DontDelete);
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list