[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

ggaren at apple.com ggaren at apple.com
Mon Feb 21 00:21:33 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit c3a8b4383ecc4a4037e23612cf3adb4d4a86430a
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jan 30 05:58:30 2011 +0000

    2011-01-29  Geoffrey Garen  <ggaren at apple.com>
    
            Reviewed by Maciej Stachowiak.
    
            Switched heap to use the Bitmap class and removed CollectorBitmap
            https://bugs.webkit.org/show_bug.cgi?id=53391
    
            SunSpider says 1.005x as fast. Seems like a fluke.
    
            * runtime/MarkedSpace.cpp:
            (JSC::MarkedSpace::allocate): Updated for rename and returning a value
            rather than taking a value by reference.
    
            * runtime/MarkedSpace.h: Code reuse is good.
    
            * wtf/Bitmap.h:
            (WTF::::testAndSet): Added, since this is the one thing Bitmap was missing
            which CollectorBitmap had. (Renamed from the less conventional "getset".)
    
            (WTF::::nextPossiblyUnset): Renamed and changed to return a value for
            clarity. It's all the same with inlining.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77080 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 16bd377..d52f914 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,25 @@
+2011-01-29  Geoffrey Garen  <ggaren at apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        Switched heap to use the Bitmap class and removed CollectorBitmap
+        https://bugs.webkit.org/show_bug.cgi?id=53391
+        
+        SunSpider says 1.005x as fast. Seems like a fluke.
+
+        * runtime/MarkedSpace.cpp:
+        (JSC::MarkedSpace::allocate): Updated for rename and returning a value
+        rather than taking a value by reference.
+
+        * runtime/MarkedSpace.h: Code reuse is good.
+
+        * wtf/Bitmap.h:
+        (WTF::::testAndSet): Added, since this is the one thing Bitmap was missing
+        which CollectorBitmap had. (Renamed from the less conventional "getset".)
+
+        (WTF::::nextPossiblyUnset): Renamed and changed to return a value for
+        clarity. It's all the same with inlining.
+
 2011-01-28  Geoffrey Garen  <ggaren at apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.cpp b/Source/JavaScriptCore/runtime/MarkedSpace.cpp
index aeb520f..f26e4f2 100644
--- a/Source/JavaScriptCore/runtime/MarkedSpace.cpp
+++ b/Source/JavaScriptCore/runtime/MarkedSpace.cpp
@@ -150,7 +150,7 @@ void* MarkedSpace::allocate(size_t s)
                 ++m_heap.nextCell;
                 return cell;
             }
-            block->marked.advanceToNextPossibleFreeCell(m_heap.nextCell);
+            m_heap.nextCell = block->marked.nextPossiblyUnset(m_heap.nextCell);
         } while (m_heap.nextCell != HeapConstants::cellsPerBlock);
         m_heap.nextCell = 0;
     } while (++m_heap.nextBlock != m_heap.usedBlocks);
diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.h b/Source/JavaScriptCore/runtime/MarkedSpace.h
index 3b23d8c..a51e697 100644
--- a/Source/JavaScriptCore/runtime/MarkedSpace.h
+++ b/Source/JavaScriptCore/runtime/MarkedSpace.h
@@ -24,6 +24,7 @@
 
 #include "MachineStackMarker.h"
 #include "PageAllocationAligned.h"
+#include <wtf/Bitmap.h>
 #include <wtf/FixedArray.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/Noncopyable.h>
@@ -124,50 +125,6 @@ namespace JSC {
     const size_t CELL_ALIGN_MASK = ~CELL_MASK;
     const size_t CELLS_PER_BLOCK = (BLOCK_SIZE - sizeof(MarkedSpace*)) * 8 * CELL_SIZE / (8 * CELL_SIZE + 1) / CELL_SIZE; // one bitmap byte can represent 8 cells.
     
-    const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8;
-    const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t);
-
-    struct CollectorBitmap {
-        FixedArray<uint32_t, BITMAP_WORDS> bits;
-        bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } 
-        void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } 
-        bool getset(size_t n)
-        {
-            unsigned i = (1 << (n & 0x1F));
-            uint32_t& b = bits[n >> 5];
-            bool r = !!(b & i);
-            b |= i;
-            return r;
-        } 
-        void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } 
-        void clearAll() { memset(bits.data(), 0, sizeof(bits)); }
-        ALWAYS_INLINE void advanceToNextPossibleFreeCell(size_t& startCell)
-        {
-            if (!~bits[startCell >> 5])
-                startCell = (startCell & (~0x1F)) + 32;
-            else
-                ++startCell;
-        }
-        size_t count(size_t startCell = 0)
-        {
-            size_t result = 0;
-            for ( ; (startCell & 0x1F) != 0; ++startCell) {
-                if (get(startCell))
-                    ++result;
-            }
-            for (size_t i = startCell >> 5; i < BITMAP_WORDS; ++i)
-                result += WTF::bitCount(bits[i]);
-            return result;
-        }
-        size_t isEmpty() // Much more efficient than testing count() == 0.
-        {
-            for (size_t i = 0; i < BITMAP_WORDS; ++i)
-                if (bits[i] != 0)
-                    return false;
-            return true;
-        }
-    };
-  
     struct CollectorCell {
         FixedArray<double, CELL_ARRAY_LENGTH> memory;
     };
@@ -175,7 +132,7 @@ namespace JSC {
     class CollectorBlock {
     public:
         FixedArray<CollectorCell, CELLS_PER_BLOCK> cells;
-        CollectorBitmap marked;
+        WTF::Bitmap<CELLS_PER_BLOCK> marked;
         Heap* heap;
     };
 
@@ -208,7 +165,7 @@ namespace JSC {
 
     inline bool MarkedSpace::checkMarkCell(const JSCell* cell)
     {
-        return cellBlock(cell)->marked.getset(cellOffset(cell));
+        return cellBlock(cell)->marked.testAndSet(cellOffset(cell));
     }
 
     inline void MarkedSpace::markCell(JSCell* cell)
diff --git a/Source/JavaScriptCore/wtf/Bitmap.h b/Source/JavaScriptCore/wtf/Bitmap.h
index 4dd88f6..2fb7305 100644
--- a/Source/JavaScriptCore/wtf/Bitmap.h
+++ b/Source/JavaScriptCore/wtf/Bitmap.h
@@ -21,7 +21,6 @@
 
 #include "FixedArray.h"
 #include "StdLibExtras.h"
-
 #include <stdint.h>
 
 namespace WTF {
@@ -36,9 +35,10 @@ public:
 
     bool get(size_t) const;
     void set(size_t);
+    bool testAndSet(size_t);
+    size_t nextPossiblyUnset(size_t) const;
     void clear(size_t);
     void clearAll();
-    void advanceToNextFreeBit(size_t&) const;
     size_t count(size_t = 0) const;
     size_t isEmpty() const;
     size_t isFull() const;
@@ -76,6 +76,16 @@ inline void Bitmap<size>::set(size_t n)
 }
 
 template<size_t size>
+inline bool Bitmap<size>::testAndSet(size_t n)
+{
+    WordType mask = one << (n % wordSize);
+    size_t index = n / wordSize;
+    bool result = bits[index] & mask;
+    bits[index] |= mask;
+    return result;
+}
+
+template<size_t size>
 inline void Bitmap<size>::clear(size_t n)
 {
     bits[n / wordSize] &= ~(one << (n % wordSize));
@@ -88,12 +98,11 @@ inline void Bitmap<size>::clearAll()
 }
 
 template<size_t size>
-inline void Bitmap<size>::advanceToNextFreeBit(size_t& start) const
+inline size_t Bitmap<size>::nextPossiblyUnset(size_t start) const
 {
     if (!~bits[start / wordSize])
-        start = ((start / wordSize) + 1) * wordSize;
-    else
-        ++start;
+        return ((start / wordSize) + 1) * wordSize;
+    return start + 1;
 }
 
 template<size_t size>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list