[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:04:23 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 5721aa9d23aa1a36dcbcb9b52800b66c066b47fd
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 20 01:23:02 2002 +0000

    	- another step towards atomic identifiers; storing hash in the string rep. gives about
    	a 1.5% speedup in the JavaScript iBench
    
            * kjs/ustring.h: Add a hash field to UString::Rep.
            * kjs/ustring.cpp:
            (UString::Rep::create): Set hash to uninitialized value.
            (UString::Rep::destroy): Do the deleting in her, and call Identifier if needed.
            (UString::Rep::computeHash): Added.
            (UString::append): Set hash to 0 when modifying the string in place.
            (UString::operator=): Ditto.
    
            * kjs/property_map.cpp: Use the hash from UString.
    
            * kjs/identifier.h: Added aboutToDestroyUStringRep.
            * kjs/identifier.cpp: (Identifier::aboutToDestroyUStringRep): Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2769 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 8856ebb..9cb2cbb 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,23 @@
 2002-11-19  Darin Adler  <darin at apple.com>
 
+	- another step towards atomic identifiers; storing hash in the string rep. gives about
+	a 1.5% speedup in the JavaScript iBench
+
+        * kjs/ustring.h: Add a hash field to UString::Rep.
+        * kjs/ustring.cpp:
+        (UString::Rep::create): Set hash to uninitialized value.
+        (UString::Rep::destroy): Do the deleting in her, and call Identifier if needed.
+        (UString::Rep::computeHash): Added.
+        (UString::append): Set hash to 0 when modifying the string in place.
+        (UString::operator=): Ditto.
+
+        * kjs/property_map.cpp: Use the hash from UString.
+
+        * kjs/identifier.h: Added aboutToDestroyUStringRep.
+        * kjs/identifier.cpp: (Identifier::aboutToDestroyUStringRep): Added.
+
+2002-11-19  Darin Adler  <darin at apple.com>
+
 	- next step towards atomic identifiers; Identifier is no longer derived from UString
 
         * kjs/identifier.h: Remove base class and add _ustring member.
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 8856ebb..9cb2cbb 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,5 +1,23 @@
 2002-11-19  Darin Adler  <darin at apple.com>
 
+	- another step towards atomic identifiers; storing hash in the string rep. gives about
+	a 1.5% speedup in the JavaScript iBench
+
+        * kjs/ustring.h: Add a hash field to UString::Rep.
+        * kjs/ustring.cpp:
+        (UString::Rep::create): Set hash to uninitialized value.
+        (UString::Rep::destroy): Do the deleting in her, and call Identifier if needed.
+        (UString::Rep::computeHash): Added.
+        (UString::append): Set hash to 0 when modifying the string in place.
+        (UString::operator=): Ditto.
+
+        * kjs/property_map.cpp: Use the hash from UString.
+
+        * kjs/identifier.h: Added aboutToDestroyUStringRep.
+        * kjs/identifier.cpp: (Identifier::aboutToDestroyUStringRep): Added.
+
+2002-11-19  Darin Adler  <darin at apple.com>
+
 	- next step towards atomic identifiers; Identifier is no longer derived from UString
 
         * kjs/identifier.h: Remove base class and add _ustring member.
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 8856ebb..9cb2cbb 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,5 +1,23 @@
 2002-11-19  Darin Adler  <darin at apple.com>
 
+	- another step towards atomic identifiers; storing hash in the string rep. gives about
+	a 1.5% speedup in the JavaScript iBench
+
+        * kjs/ustring.h: Add a hash field to UString::Rep.
+        * kjs/ustring.cpp:
+        (UString::Rep::create): Set hash to uninitialized value.
+        (UString::Rep::destroy): Do the deleting in her, and call Identifier if needed.
+        (UString::Rep::computeHash): Added.
+        (UString::append): Set hash to 0 when modifying the string in place.
+        (UString::operator=): Ditto.
+
+        * kjs/property_map.cpp: Use the hash from UString.
+
+        * kjs/identifier.h: Added aboutToDestroyUStringRep.
+        * kjs/identifier.cpp: (Identifier::aboutToDestroyUStringRep): Added.
+
+2002-11-19  Darin Adler  <darin at apple.com>
+
 	- next step towards atomic identifiers; Identifier is no longer derived from UString
 
         * kjs/identifier.h: Remove base class and add _ustring member.
diff --git a/JavaScriptCore/kjs/identifier.cpp b/JavaScriptCore/kjs/identifier.cpp
index 97d68f4..eaf2604 100644
--- a/JavaScriptCore/kjs/identifier.cpp
+++ b/JavaScriptCore/kjs/identifier.cpp
@@ -30,4 +30,8 @@ bool operator==(const Identifier &a, const char *b)
     return a._ustring == b;
 }
 
+void Identifier::aboutToDestroyUStringRep(UString::Rep *)
+{
+}
+
 } // namespace KJS
diff --git a/JavaScriptCore/kjs/identifier.h b/JavaScriptCore/kjs/identifier.h
index 3af67df..1a41fa1 100644
--- a/JavaScriptCore/kjs/identifier.h
+++ b/JavaScriptCore/kjs/identifier.h
@@ -57,6 +57,8 @@ namespace KJS {
 
         friend bool operator==(const Identifier &, const char *);
     
+        static void aboutToDestroyUStringRep(UString::Rep *);
+
     private:
         UString _ustring;
     };
diff --git a/JavaScriptCore/kjs/property_map.cpp b/JavaScriptCore/kjs/property_map.cpp
index e24f3cc..f814e26 100644
--- a/JavaScriptCore/kjs/property_map.cpp
+++ b/JavaScriptCore/kjs/property_map.cpp
@@ -64,17 +64,9 @@ void PropertyMap::clear()
     _keyCount = 0;
 }
 
-int PropertyMap::hash(const UString::Rep *s) const
+inline int PropertyMap::hash(const UString::Rep *s) const
 {
-    int h = 0;
-    int length = s->len;
-    int prefixLength = length < 8 ? length : 8;
-    for (int i = 0; i < prefixLength; i++)
-        h = (127 * h + s->dat[i].unicode()) & _tableSizeHashMask;
-    int suffixPosition = length < 16 ? 8 : length - 8;
-    for (int i = suffixPosition; i < length; i++)
-        h = (127 * h + s->dat[i].unicode()) & _tableSizeHashMask;
-    return h;
+    return s->hash() & _tableSizeHashMask;
 }
 
 bool PropertyMap::keysMatch(const UString::Rep *a, const UString::Rep *b)
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index e498eef..dd35f6e 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -36,6 +36,7 @@
 
 #include "ustring.h"
 #include "operations.h"
+#include "identifier.h"
 #include <math.h>
 
 namespace KJS {
@@ -114,8 +115,8 @@ bool KJS::operator==(const KJS::CString& c1, const KJS::CString& c2)
 }
 
 UChar UChar::null((char)0);
-UString::Rep UString::Rep::null = { 0, 0, 0, 1 };
-UString::Rep UString::Rep::empty = { 0, 0, 0, 1 };
+UString::Rep UString::Rep::null = { 0, 0, 0, 1, 1 };
+UString::Rep UString::Rep::empty = { 0, 0, 0, 1, 1 };
 UString UString::null;
 const int normalStatBufferSize = 4096;
 static char *statBuffer = 0;
@@ -162,10 +163,35 @@ UString::Rep *UString::Rep::create(UChar *d, int l)
   r->len = l;
   r->capacity = l;
   r->rc = 1;
+  r->_hash = 0;
 
   return r;
 }
 
+void UString::Rep::destroy()
+{
+  if (capacity == capacityForIdentifier)
+    Identifier::aboutToDestroyUStringRep(this);
+  delete [] dat;
+  delete this;
+}
+
+void UString::Rep::computeHash() const
+{
+    int length = len;
+    int prefixLength = length < 8 ? length : 8;
+    int suffixPosition = length < 16 ? 8 : length - 8;
+
+    unsigned h = length;
+    for (int i = 0; i < prefixLength; i++)
+        h = 127 * h + dat[i].unicode();
+    for (int i = suffixPosition; i < length; i++)
+        h = 127 * h + dat[i].unicode();
+    if (h == 0)
+        h = 0x80000000;
+    _hash = h;
+}
+
 UString::UString()
 {
   null.rep = &Rep::null;
@@ -328,6 +354,7 @@ UString &UString::append(const UString &t)
   if (rep->rc == 1 && newLen <= rep->capacity) {
     memcpy(rep->dat+l, t.data(), tLen * sizeof(UChar));
     rep->len = newLen;
+    rep->_hash = 0;
     return *this;
   }
   
@@ -388,8 +415,9 @@ UString &UString::operator=(const char *c)
 {
   int l = c ? strlen(c) : 0;
   UChar *d;
-  if (rep->rc == 1 && l < rep->capacity) {
+  if (rep->rc == 1 && l <= rep->capacity) {
     d = rep->dat;
+    rep->_hash = 0;
   } else {
     release();
     d = new UChar[l];
diff --git a/JavaScriptCore/kjs/ustring.h b/JavaScriptCore/kjs/ustring.h
index e67ad88..f411d1d 100644
--- a/JavaScriptCore/kjs/ustring.h
+++ b/JavaScriptCore/kjs/ustring.h
@@ -199,30 +199,37 @@ namespace KJS {
   class UString {
     friend bool operator==(const UString&, const UString&);
     friend class UCharReference;
+    friend class Identifier;
     friend class PropertyMap;
     friend class PropertyMapHashTableEntry;
+
     /**
      * @internal
      */
     struct Rep {
       friend class UString;
       friend bool operator==(const UString&, const UString&);
+      
       static Rep *create(UChar *d, int l);
-      inline UChar *data() const { return dat; }
-      inline int size() const { return len; }
+      void destroy();
+      
+      UChar *data() const { return dat; }
+      int size() const { return len; }
+      
+      int hash() const { if (_hash == 0) computeHash(); return _hash; }
+      void computeHash() const;
 
-      inline void ref() { rc++; }
-      inline void deref() {
-        if (--rc == 0) {
-          delete [] dat;
-          delete this;
-        }
-      }
+      void ref() { ++rc; }
+      void deref() { if (--rc == 0) destroy(); }
 
       UChar *dat;
       int len;
       int capacity;
       int rc;
+      mutable int _hash;
+      
+      enum { capacityForIdentifier = 0x10000000 };
+      
       static Rep null;
       static Rep empty;
     };

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list