Title: [109731] trunk/Source/_javascript_Core
Revision
109731
Author
wi...@igalia.com
Date
2012-03-05 03:55:53 -0800 (Mon, 05 Mar 2012)

Log Message

WTF: Micro-optimize cleanup of empty vectors and hash tables
https://bugs.webkit.org/show_bug.cgi?id=79903

Reviewed by Michael Saboff and Geoffrey Garen.

This patch speeds up cleanup of vectors and hash tables whose
backing store was never allocated.  This is the case by default
for most vectors / hash tables that never had any entries added.

The result for me is that calling checkSyntax 1000 times on
concat-jquery-mootools-prototype.js goes from 6.234s to 6.068s, a
2.4% speedup.

* wtf/HashTable.h:
(WTF::HashTable::~HashTable):
(WTF::::clear): Don't deallocate the storage or frob member
variables if there is no backing storage.
* wtf/Vector.h:
(WTF::VectorBufferBase::deallocateBuffer): Likewise.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (109730 => 109731)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-05 10:44:40 UTC (rev 109730)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-05 11:55:53 UTC (rev 109731)
@@ -1,3 +1,25 @@
+2012-03-05  Andy Wingo  <wi...@igalia.com>
+
+        WTF: Micro-optimize cleanup of empty vectors and hash tables
+        https://bugs.webkit.org/show_bug.cgi?id=79903
+
+        Reviewed by Michael Saboff and Geoffrey Garen.
+
+        This patch speeds up cleanup of vectors and hash tables whose
+        backing store was never allocated.  This is the case by default
+        for most vectors / hash tables that never had any entries added.
+
+        The result for me is that calling checkSyntax 1000 times on
+        concat-jquery-mootools-prototype.js goes from 6.234s to 6.068s, a
+        2.4% speedup.
+
+        * wtf/HashTable.h:
+        (WTF::HashTable::~HashTable):
+        (WTF::::clear): Don't deallocate the storage or frob member
+        variables if there is no backing storage.
+        * wtf/Vector.h:
+        (WTF::VectorBufferBase::deallocateBuffer): Likewise.
+
 2012-03-04  Filip Pizlo  <fpi...@apple.com>
 
         JIT heuristics should be hyperbolic

Modified: trunk/Source/_javascript_Core/wtf/HashTable.h (109730 => 109731)


--- trunk/Source/_javascript_Core/wtf/HashTable.h	2012-03-05 10:44:40 UTC (rev 109730)
+++ trunk/Source/_javascript_Core/wtf/HashTable.h	2012-03-05 11:55:53 UTC (rev 109731)
@@ -310,7 +310,8 @@
         ~HashTable() 
         {
             invalidateIterators(); 
-            deallocateTable(m_table, m_tableSize); 
+            if (m_table)
+                deallocateTable(m_table, m_tableSize);
 #if CHECK_HASHTABLE_USE_AFTER_DESTRUCTION
             m_table = (ValueType*)(uintptr_t)0xbbadbeef;
 #endif
@@ -979,6 +980,9 @@
     void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::clear()
     {
         invalidateIterators();
+        if (!m_table)
+            return;
+
         deallocateTable(m_table, m_tableSize);
         m_table = 0;
         m_tableSize = 0;

Modified: trunk/Source/_javascript_Core/wtf/Vector.h (109730 => 109731)


--- trunk/Source/_javascript_Core/wtf/Vector.h	2012-03-05 10:44:40 UTC (rev 109730)
+++ trunk/Source/_javascript_Core/wtf/Vector.h	2012-03-05 11:55:53 UTC (rev 109731)
@@ -281,10 +281,14 @@
 
         void deallocateBuffer(T* bufferToDeallocate)
         {
+            if (!bufferToDeallocate)
+                return;
+            
             if (m_buffer == bufferToDeallocate) {
                 m_buffer = 0;
                 m_capacity = 0;
             }
+
             fastFree(bufferToDeallocate);
         }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to