[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

barraclough at apple.com barraclough at apple.com
Wed Dec 22 11:41:59 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6031c645f7c4adffcc1e39528a3950e26c79f37e
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 4 03:27:13 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=43269
    
    Patch by Nathan Lawrence <nlawrence at apple.com> on 2010-08-03
    Reviewed by Gavin Barraclough.
    
    Added new allocateAligned methods to PageAllocation.  In order to
    prevent a regress in performance, the function needs to be inlined.
    
    Additionally, I ported the symbian block allocator to use
    PageAllocation and added a new WTF::Bitmap class to support this.
    
    * GNUmakefile.am:
    * JavaScriptCore.gypi:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * runtime/AlignedMemoryAllocator.h: Added.
    (JSC::AlignedMemory::deallocate):
    (JSC::AlignedMemory::base):
    (JSC::AlignedMemory::AlignedMemory):
    (JSC::AlignedMemoryAllocator::destroy):
    (JSC::AlignedMemoryAllocator::allocate):
    (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator):
    (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator):
    (JSC::AlignedMemoryAllocator::free):
    * runtime/Collector.cpp:
    (JSC::Heap::Heap):
    (JSC::Heap::destroy):
    (JSC::Heap::allocateBlock):
    (JSC::Heap::freeBlock):
    (JSC::Heap::freeBlocks):
    (JSC::Heap::allocate):
    (JSC::Heap::shrinkBlocks):
    (JSC::Heap::markConservatively):
    (JSC::Heap::clearMarkBits):
    (JSC::Heap::markedCells):
    * runtime/Collector.h:
    (JSC::CollectorHeap::collectorBlock):
    * runtime/CollectorHeapIterator.h:
    (JSC::CollectorHeapIterator::operator*):
    (JSC::LiveObjectIterator::operator++):
    (JSC::DeadObjectIterator::operator++):
    * wtf/Bitmap.h: Added.
    (WTF::Bitmap::get):
    (WTF::Bitmap::set):
    (WTF::Bitmap::clear):
    (WTF::Bitmap::clearAll):
    (WTF::Bitmap::advanceToNextFreeBit):
    (WTF::Bitmap::count):
    (WTF::Bitmap::isEmpty):
    (WTF::Bitmap::isFull):
    * wtf/PageAllocation.h:
    (WTF::PageAllocation::operator UnspecifiedBoolType):
    (WTF::PageAllocation::allocateAligned):
    (WTF::PageAllocation::reserveAligned):
    * wtf/Platform.h:
    * wtf/symbian: Removed.
    * wtf/symbian/BlockAllocatorSymbian.cpp: Removed.
    * wtf/symbian/BlockAllocatorSymbian.h: Removed.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64624 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index cda77fa..8267676 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,62 @@
+2010-08-03  Nathan Lawrence  <nlawrence at apple.com>
+
+        Reviewed by Gavin Barraclough.
+
+        https://bugs.webkit.org/show_bug.cgi?id=43269
+
+        Added new allocateAligned methods to PageAllocation.  In order to
+        prevent a regress in performance, the function needs to be inlined.
+
+        Additionally, I ported the symbian block allocator to use
+        PageAllocation and added a new WTF::Bitmap class to support this.
+
+        * GNUmakefile.am:
+        * JavaScriptCore.gypi:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * runtime/AlignedMemoryAllocator.h: Added.
+        (JSC::AlignedMemory::deallocate):
+        (JSC::AlignedMemory::base):
+        (JSC::AlignedMemory::AlignedMemory):
+        (JSC::AlignedMemoryAllocator::destroy):
+        (JSC::AlignedMemoryAllocator::allocate):
+        (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator):
+        (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator):
+        (JSC::AlignedMemoryAllocator::free):
+        * runtime/Collector.cpp:
+        (JSC::Heap::Heap):
+        (JSC::Heap::destroy):
+        (JSC::Heap::allocateBlock):
+        (JSC::Heap::freeBlock):
+        (JSC::Heap::freeBlocks):
+        (JSC::Heap::allocate):
+        (JSC::Heap::shrinkBlocks):
+        (JSC::Heap::markConservatively):
+        (JSC::Heap::clearMarkBits):
+        (JSC::Heap::markedCells):
+        * runtime/Collector.h:
+        (JSC::CollectorHeap::collectorBlock):
+        * runtime/CollectorHeapIterator.h:
+        (JSC::CollectorHeapIterator::operator*):
+        (JSC::LiveObjectIterator::operator++):
+        (JSC::DeadObjectIterator::operator++):
+        * wtf/Bitmap.h: Added.
+        (WTF::Bitmap::get):
+        (WTF::Bitmap::set):
+        (WTF::Bitmap::clear):
+        (WTF::Bitmap::clearAll):
+        (WTF::Bitmap::advanceToNextFreeBit):
+        (WTF::Bitmap::count):
+        (WTF::Bitmap::isEmpty):
+        (WTF::Bitmap::isFull):
+        * wtf/PageAllocation.h:
+        (WTF::PageAllocation::operator UnspecifiedBoolType):
+        (WTF::PageAllocation::allocateAligned):
+        (WTF::PageAllocation::reserveAligned):
+        * wtf/Platform.h:
+        * wtf/symbian: Removed.
+        * wtf/symbian/BlockAllocatorSymbian.cpp: Removed.
+        * wtf/symbian/BlockAllocatorSymbian.h: Removed.
+
 2010-08-03  Michael Saboff  <msaboff at apple.com>
 
         Reviewed by Gavin Barraclough.
diff --git a/JavaScriptCore/GNUmakefile.am b/JavaScriptCore/GNUmakefile.am
index 7ee1246..281cbe3 100644
--- a/JavaScriptCore/GNUmakefile.am
+++ b/JavaScriptCore/GNUmakefile.am
@@ -212,6 +212,7 @@ javascriptcore_sources += \
 	JavaScriptCore/profiler/ProfileNode.h \
 	JavaScriptCore/profiler/Profiler.cpp \
 	JavaScriptCore/profiler/Profiler.h \
+	JavaScriptCore/runtime/AlignedMemoryAllocator.h \
 	JavaScriptCore/runtime/ArgList.cpp \
 	JavaScriptCore/runtime/ArgList.h \
 	JavaScriptCore/runtime/Arguments.cpp \
@@ -411,6 +412,7 @@ javascriptcore_sources += \
 	JavaScriptCore/wtf/Assertions.h \
 	JavaScriptCore/wtf/Atomics.h \
 	JavaScriptCore/wtf/AVLTree.h \
+	JavaScriptCore/wtf/Bitmap.h \
 	JavaScriptCore/wtf/BumpPointerAllocator.h \
 	JavaScriptCore/wtf/ByteArray.cpp \
 	JavaScriptCore/wtf/ByteArray.h \
diff --git a/JavaScriptCore/JavaScriptCore.gypi b/JavaScriptCore/JavaScriptCore.gypi
index a902af9..1b806af 100644
--- a/JavaScriptCore/JavaScriptCore.gypi
+++ b/JavaScriptCore/JavaScriptCore.gypi
@@ -164,6 +164,7 @@
             'profiler/Profiler.cpp',
             'profiler/Profiler.h',
             'profiler/ProfilerServer.h',
+            'runtime/AlignedMemoryAllocator.h',
             'runtime/ArgList.cpp',
             'runtime/ArgList.h',
             'runtime/Arguments.cpp',
@@ -350,6 +351,7 @@
             'wtf/Assertions.h',
             'wtf/Atomics.h',
             'wtf/AVLTree.h',
+            'wtf/Bitmap.h',
             'wtf/ByteArray.cpp',
             'wtf/ByteArray.h',
             'wtf/chromium/ChromiumThreading.h',
diff --git a/JavaScriptCore/JavaScriptCore.pro b/JavaScriptCore/JavaScriptCore.pro
index f30e50d..88ca876 100644
--- a/JavaScriptCore/JavaScriptCore.pro
+++ b/JavaScriptCore/JavaScriptCore.pro
@@ -216,7 +216,6 @@ SOURCES += \
     wtf/PageAllocation.cpp \
     wtf/RandomNumber.cpp \
     wtf/RefCountedLeakCounter.cpp \
-    wtf/symbian/BlockAllocatorSymbian.cpp \
     wtf/ThreadingNone.cpp \
     wtf/Threading.cpp \
     wtf/TypeTraits.cpp \
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 4616e47..24202a2 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -508,6 +508,9 @@
 		BCFD8C920EEB2EE700283848 /* JumpTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCFD8C900EEB2EE700283848 /* JumpTable.cpp */; };
 		BCFD8C930EEB2EE700283848 /* JumpTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFD8C910EEB2EE700283848 /* JumpTable.h */; };
 		C0A272630E50A06300E96E15 /* NotFound.h in Headers */ = {isa = PBXBuildFile; fileRef = C0A2723F0E509F1E00E96E15 /* NotFound.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		DD2724681208D1FF00F9ABE7 /* AlignedMemoryAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2724671208D1FF00F9ABE7 /* AlignedMemoryAllocator.h */; };
+		DD2724691208D1FF00F9ABE7 /* AlignedMemoryAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2724671208D1FF00F9ABE7 /* AlignedMemoryAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		DD377CBC12072C18006A2517 /* Bitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = DD377CBB12072C18006A2517 /* Bitmap.h */; };
 		DDF7ABD411F60ED200108E36 /* GCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = DDF7ABD211F60ED200108E36 /* GCActivityCallback.h */; };
 		DDF7ABD511F60ED200108E36 /* GCActivityCallbackCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDF7ABD311F60ED200108E36 /* GCActivityCallbackCF.cpp */; };
 		E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */ = {isa = PBXBuildFile; fileRef = E124A8F50E555775003091F1 /* OpaqueJSString.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1051,6 +1054,8 @@
 		C0A2723F0E509F1E00E96E15 /* NotFound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotFound.h; sourceTree = "<group>"; };
 		D21202280AD4310C00ED79B6 /* DateConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DateConversion.cpp; sourceTree = "<group>"; };
 		D21202290AD4310C00ED79B6 /* DateConversion.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DateConversion.h; sourceTree = "<group>"; };
+		DD2724671208D1FF00F9ABE7 /* AlignedMemoryAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlignedMemoryAllocator.h; sourceTree = "<group>"; };
+		DD377CBB12072C18006A2517 /* Bitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bitmap.h; sourceTree = "<group>"; };
 		DDF7ABD211F60ED200108E36 /* GCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCActivityCallback.h; sourceTree = "<group>"; };
 		DDF7ABD311F60ED200108E36 /* GCActivityCallbackCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCActivityCallbackCF.cpp; sourceTree = "<group>"; };
 		E11D51750B2E798D0056C188 /* StringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringExtras.h; sourceTree = "<group>"; };
@@ -1410,6 +1415,7 @@
 				65E217B708E7EECC0023E5F6 /* Assertions.h */,
 				BC5F7BBB11823B590052C02C /* Atomics.h */,
 				E1A596370DE3E1C300C17E37 /* AVLTree.h */,
+				DD377CBB12072C18006A2517 /* Bitmap.h */,
 				86676D4D11FED55D004B6863 /* BumpPointerAllocator.h */,
 				A7A1F7AA0F252B3C00E184E2 /* ByteArray.cpp */,
 				A7A1F7AB0F252B3C00E184E2 /* ByteArray.h */,
@@ -1559,6 +1565,7 @@
 		7EF6E0BB0EB7A1EC0079AFAF /* runtime */ = {
 			isa = PBXGroup;
 			children = (
+				DD2724671208D1FF00F9ABE7 /* AlignedMemoryAllocator.h */,
 				DDF7ABD211F60ED200108E36 /* GCActivityCallback.h */,
 				DDF7ABD311F60ED200108E36 /* GCActivityCallbackCF.cpp */,
 				BCF605110E203EF800B9A64D /* ArgList.cpp */,
@@ -1901,6 +1908,7 @@
 				144007570A5370D20005F061 /* JSNodeList.h in Headers */,
 				144005CC0A5338F80005F061 /* Node.h in Headers */,
 				1440074A0A536CC20005F061 /* NodeList.h in Headers */,
+				DD2724681208D1FF00F9ABE7 /* AlignedMemoryAllocator.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2199,7 +2207,9 @@
 				868BFA18117CF19900B908B1 /* WTFString.h in Headers */,
 				86D08D5411793613006E5ED0 /* WTFThreadData.h in Headers */,
 				9688CB160ED12B4E001D649F /* X86Assembler.h in Headers */,
+				DD377CBC12072C18006A2517 /* Bitmap.h in Headers */,
 				DDF7ABD411F60ED200108E36 /* GCActivityCallback.h in Headers */,
+				DD2724691208D1FF00F9ABE7 /* AlignedMemoryAllocator.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/JavaScriptCore/runtime/AlignedMemoryAllocator.h b/JavaScriptCore/runtime/AlignedMemoryAllocator.h
new file mode 100644
index 0000000..2451bf3
--- /dev/null
+++ b/JavaScriptCore/runtime/AlignedMemoryAllocator.h
@@ -0,0 +1,239 @@
+/*
+ *  Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef AlignedMemoryAllocator_h
+#define AlignedMemoryAllocator_h
+
+#include <wtf/Bitmap.h>
+#include <wtf/PageAllocation.h>
+
+namespace JSC {
+
+struct AlignedMemoryAllocatorConstants {
+// Set sane defaults if -D<flagname=value> wasn't provided via compiler args
+#if defined(JSCCOLLECTOR_VIRTUALMEM_RESERVATION)
+    // Keep backwards compatibility with symbian build system
+    static const size_t virtualMemoryReservation = JSCCOLLECTOR_VIRTUALMEM_RESERVATION;
+#elif defined(__WINS__)
+    // Emulator has limited virtual address space
+    static const size_t virtualMemoryReservation = 0x400000;
+#else
+    // HW has plenty of virtual addresses
+    static const size_t virtualMemoryReservation = 0x8000000;
+#endif
+};
+
+template<size_t blockSize> class AlignedMemory;
+template<size_t blockSize> class AlignedMemoryAllocator;
+
+#if HAVE(ALIGNED_ALLOCATE)
+
+template<size_t blockSize>
+class AlignedMemoryAllocator;
+
+template<size_t blockSize>
+class AlignedMemory {
+public:
+    void deallocate();
+    void* base();
+
+private:
+    friend class AlignedMemoryAllocator<blockSize>;
+
+    AlignedMemory(PageAllocation);
+
+    PageAllocation m_allocation;
+};
+
+template<size_t blockSize>
+class AlignedMemoryAllocator {
+public:
+    void destroy();
+    AlignedMemory<blockSize> allocate();
+};
+
+template<size_t blockSize>
+inline void AlignedMemoryAllocator<blockSize>::destroy()
+{
+}
+
+template<size_t blockSize>
+inline AlignedMemory<blockSize> AlignedMemoryAllocator<blockSize>::allocate()
+{
+    return AlignedMemory<blockSize>(PageAllocation::allocateAligned(blockSize));
+}
+
+template<size_t blockSize>
+inline void AlignedMemory<blockSize>::deallocate()
+{
+    m_allocation.deallocate();
+}
+
+template<size_t blockSize>
+inline void* AlignedMemory<blockSize>::base()
+{
+    return m_allocation.base();
+}
+
+template<size_t blockSize>
+inline AlignedMemory<blockSize>::AlignedMemory(PageAllocation allocation)
+    : m_allocation(allocation)
+{
+}
+
+#else
+
+template<size_t blockSize>
+class AlignedMemory {
+public:
+    void deallocate();
+    void* base();
+
+private:
+    friend class AlignedMemoryAllocator<blockSize>;
+
+    AlignedMemory(void* base, AlignedMemoryAllocator<blockSize>* allocator);
+
+    void* m_base;
+    AlignedMemoryAllocator<blockSize>* m_allocator;
+};
+
+template<size_t blockSize>
+class AlignedMemoryAllocator {
+public:
+    AlignedMemoryAllocator();
+    ~AlignedMemoryAllocator();
+
+    void destroy();
+    AlignedMemory<blockSize> allocate();
+    void free(AlignedMemory<blockSize>);
+
+private:
+    static const size_t reservationSize = AlignedMemoryAllocatorConstants::virtualMemoryReservation;
+    static const size_t bitmapSize = reservationSize / blockSize;
+
+    PageAllocation m_reservation;
+    size_t m_nextFree;
+    uintptr_t m_reservationBase;
+    WTF::Bitmap<bitmapSize> m_bitmap;
+};
+
+template<size_t blockSize>
+AlignedMemoryAllocator<blockSize>::AlignedMemoryAllocator()
+    : m_reservation(PageAllocation::reserve(reservationSize + blockSize))
+    , m_nextFree(0)
+{
+    // check that blockSize and reservationSize are powers of two
+    ASSERT(!(blockSize & (blockSize - 1)));
+    ASSERT(!(reservationSize & (reservationSize - 1)));
+
+    // check that blockSize is a multiple of pageSize and that
+    // reservationSize is a multiple of blockSize
+    ASSERT(!(blockSize & (PageAllocation::pagesize() - 1)));
+    ASSERT(!(reservationSize & (blockSize - 1)));
+
+    ASSERT(m_reservation);
+
+    m_reservationBase = reinterpret_cast<uintptr_t>(m_reservation.base());
+    m_reservationBase = (m_reservationBase + blockSize) & ~(blockSize - 1);
+}
+
+template<size_t blockSize>
+AlignedMemoryAllocator<blockSize>::~AlignedMemoryAllocator()
+{
+    destroy();
+    m_reservation.deallocate();
+}
+
+template<size_t blockSize>
+inline void AlignedMemoryAllocator<blockSize>::destroy()
+{
+    for (unsigned i = 0; i < bitmapSize; ++i) {
+        if (m_bitmap.get(i)) {
+            void* blockAddress = reinterpret_cast<void*>(m_reservationBase + m_nextFree * blockSize);
+            m_reservation.decommit(blockAddress, blockSize);
+
+            m_bitmap.clear(i);
+        }
+    }
+}
+
+template<size_t blockSize>
+AlignedMemory<blockSize> AlignedMemoryAllocator<blockSize>::allocate()
+{
+    while (m_nextFree < bitmapSize) {
+        if (!m_bitmap.get(m_nextFree)) {
+            void* blockAddress = reinterpret_cast<void*>(m_reservationBase + m_nextFree * blockSize);
+            m_reservation.commit(blockAddress, blockSize);
+
+            m_bitmap.set(m_nextFree);
+            ++m_nextFree;
+
+            return AlignedMemory<blockSize>(blockAddress, this);
+        }
+        m_bitmap.advanceToNextFreeBit(m_nextFree);
+    }
+
+    if (m_bitmap.isFull())
+        return AlignedMemory<blockSize>(0, this);
+
+    m_nextFree = 0;
+
+    return allocate();
+}
+
+template<size_t blockSize>
+void AlignedMemoryAllocator<blockSize>::free(AlignedMemory<blockSize> allocation)
+{
+    ASSERT(allocation.base());
+    m_reservation.decommit(allocation.base(), blockSize);
+
+    size_t diff = (reinterpret_cast<uintptr_t>(allocation.base()) - m_reservationBase);
+    ASSERT(!(diff & (blockSize - 1)));
+
+    size_t i = diff / blockSize;
+    ASSERT(m_bitmap.get(i));
+
+    m_bitmap.clear(i);
+}
+
+template<size_t blockSize>
+inline void AlignedMemory<blockSize>::deallocate()
+{
+    m_allocator->free(*this);
+}
+
+template<size_t blockSize>
+inline void* AlignedMemory<blockSize>::base()
+{
+    return m_base;
+}
+
+template<size_t blockSize>
+AlignedMemory<blockSize>::AlignedMemory(void* base, AlignedMemoryAllocator<blockSize>* allocator)
+    : m_base(base)
+    , m_allocator(allocator)
+{
+}
+
+#endif
+
+}
+
+#endif
diff --git a/JavaScriptCore/runtime/Collector.cpp b/JavaScriptCore/runtime/Collector.cpp
index 4a56ede..93649dd 100644
--- a/JavaScriptCore/runtime/Collector.cpp
+++ b/JavaScriptCore/runtime/Collector.cpp
@@ -136,9 +136,6 @@ Heap::Heap(JSGlobalData* globalData)
     , m_registeredThreads(0)
     , m_currentThreadRegistrar(0)
 #endif
-#if OS(SYMBIAN)
-    , m_blockallocator(JSCCOLLECTOR_VIRTUALMEM_RESERVATION, BLOCK_SIZE)
-#endif
     , m_globalData(globalData)
 {
     ASSERT(globalData);
@@ -186,63 +183,17 @@ void Heap::destroy()
         t = next;
     }
 #endif
-#if OS(SYMBIAN)
     m_blockallocator.destroy();
-#endif
     m_globalData = 0;
 }
 
 NEVER_INLINE CollectorBlock* Heap::allocateBlock()
 {
-#if OS(DARWIN)
-    vm_address_t address = 0;
-    vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT);
-#elif OS(SYMBIAN)
-    void* address = m_blockallocator.alloc();  
-    if (!address)
-        CRASH();
-#elif OS(WINCE)
-    void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
-#elif OS(WINDOWS)
-#if COMPILER(MINGW) && !COMPILER(MINGW64)
-    void* address = __mingw_aligned_malloc(BLOCK_SIZE, BLOCK_SIZE);
-#else
-    void* address = _aligned_malloc(BLOCK_SIZE, BLOCK_SIZE);
-#endif
-    memset(address, 0, BLOCK_SIZE);
-#elif HAVE(POSIX_MEMALIGN)
-    void* address;
-    posix_memalign(&address, BLOCK_SIZE, BLOCK_SIZE);
-#else
-
-#if ENABLE(JSC_MULTIPLE_THREADS)
-#error Need to initialize pagesize safely.
-#endif
-    static size_t pagesize = getpagesize();
-
-    size_t extra = 0;
-    if (BLOCK_SIZE > pagesize)
-        extra = BLOCK_SIZE - pagesize;
-
-    void* mmapResult = mmap(NULL, BLOCK_SIZE + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
-    uintptr_t address = reinterpret_cast<uintptr_t>(mmapResult);
-
-    size_t adjust = 0;
-    if ((address & BLOCK_OFFSET_MASK) != 0)
-        adjust = BLOCK_SIZE - (address & BLOCK_OFFSET_MASK);
-
-    if (adjust > 0)
-        munmap(reinterpret_cast<char*>(address), adjust);
-
-    if (adjust < extra)
-        munmap(reinterpret_cast<char*>(address + adjust + BLOCK_SIZE), extra - adjust);
-
-    address += adjust;
-#endif
+    AlignedBlock allocation = m_blockallocator.allocate();
+    CollectorBlock* block = static_cast<CollectorBlock*>(allocation.base());
 
     // Initialize block.
 
-    CollectorBlock* block = reinterpret_cast<CollectorBlock*>(address);
     block->heap = this;
     clearMarkBits(block);
 
@@ -254,14 +205,14 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock()
 
     size_t numBlocks = m_heap.numBlocks;
     if (m_heap.usedBlocks == numBlocks) {
-        static const size_t maxNumBlocks = ULONG_MAX / sizeof(CollectorBlock*) / GROWTH_FACTOR;
+        static const size_t maxNumBlocks = ULONG_MAX / sizeof(AlignedBlock) / GROWTH_FACTOR;
         if (numBlocks > maxNumBlocks)
             CRASH();
         numBlocks = max(MIN_ARRAY_SIZE, numBlocks * GROWTH_FACTOR);
         m_heap.numBlocks = numBlocks;
-        m_heap.blocks = static_cast<CollectorBlock**>(fastRealloc(m_heap.blocks, numBlocks * sizeof(CollectorBlock*)));
+        m_heap.blocks = static_cast<AlignedBlock*>(fastRealloc(m_heap.blocks, numBlocks * sizeof(AlignedBlock)));
     }
-    m_heap.blocks[m_heap.usedBlocks++] = block;
+    m_heap.blocks[m_heap.usedBlocks++] = allocation;
 
     return block;
 }
@@ -274,7 +225,7 @@ NEVER_INLINE void Heap::freeBlock(size_t block)
     ObjectIterator end(m_heap, block + 1);
     for ( ; it != end; ++it)
         (*it)->~JSCell();
-    freeBlockPtr(m_heap.blocks[block]);
+    m_heap.blocks[block].deallocate();
 
     // swap with the last block so we compact as we go
     m_heap.blocks[block] = m_heap.blocks[m_heap.usedBlocks - 1];
@@ -282,31 +233,10 @@ NEVER_INLINE void Heap::freeBlock(size_t block)
 
     if (m_heap.numBlocks > MIN_ARRAY_SIZE && m_heap.usedBlocks < m_heap.numBlocks / LOW_WATER_FACTOR) {
         m_heap.numBlocks = m_heap.numBlocks / GROWTH_FACTOR; 
-        m_heap.blocks = static_cast<CollectorBlock**>(fastRealloc(m_heap.blocks, m_heap.numBlocks * sizeof(CollectorBlock*)));
+        m_heap.blocks = static_cast<AlignedBlock*>(fastRealloc(m_heap.blocks, m_heap.numBlocks * sizeof(AlignedBlock)));
     }
 }
 
-NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block)
-{
-#if OS(DARWIN)    
-    vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(block), BLOCK_SIZE);
-#elif OS(SYMBIAN)
-    m_blockallocator.free(reinterpret_cast<void*>(block));
-#elif OS(WINCE)
-    VirtualFree(block, 0, MEM_RELEASE);
-#elif OS(WINDOWS)
-#if COMPILER(MINGW) && !COMPILER(MINGW64)
-    __mingw_aligned_free(block);
-#else
-    _aligned_free(block);
-#endif
-#elif HAVE(POSIX_MEMALIGN)
-    free(block);
-#else
-    munmap(reinterpret_cast<char*>(block), BLOCK_SIZE);
-#endif
-}
-
 void Heap::freeBlocks()
 {
     ProtectCountSet protectedValuesCopy = m_protectedValues;
@@ -330,7 +260,7 @@ void Heap::freeBlocks()
         it->first->~JSCell();
 
     for (size_t block = 0; block < m_heap.usedBlocks; ++block)
-        freeBlockPtr(m_heap.blocks[block]);
+        m_heap.blocks[block].deallocate();
 
     fastFree(m_heap.blocks);
 
@@ -383,7 +313,7 @@ allocate:
 
     do {
         ASSERT(m_heap.nextBlock < m_heap.usedBlocks);
-        Block* block = reinterpret_cast<Block*>(m_heap.blocks[m_heap.nextBlock]);
+        Block* block = m_heap.collectorBlock(m_heap.nextBlock);
         do {
             ASSERT(m_heap.nextCell < HeapConstants::cellsPerBlock);
             if (!block->marked.get(m_heap.nextCell)) { // Always false for the last cell in the block
@@ -438,10 +368,10 @@ void Heap::shrinkBlocks(size_t neededBlocks)
     
     // Clear the always-on last bit, so isEmpty() isn't fooled by it.
     for (size_t i = 0; i < m_heap.usedBlocks; ++i)
-        m_heap.blocks[i]->marked.clear(HeapConstants::cellsPerBlock - 1);
+        m_heap.collectorBlock(i)->marked.clear(HeapConstants::cellsPerBlock - 1);
 
     for (size_t i = 0; i != m_heap.usedBlocks && m_heap.usedBlocks != neededBlocks; ) {
-        if (m_heap.blocks[i]->marked.isEmpty()) {
+        if (m_heap.collectorBlock(i)->marked.isEmpty()) {
             freeBlock(i);
         } else
             ++i;
@@ -449,7 +379,7 @@ void Heap::shrinkBlocks(size_t neededBlocks)
 
     // Reset the always-on last bit.
     for (size_t i = 0; i < m_heap.usedBlocks; ++i)
-        m_heap.blocks[i]->marked.set(HeapConstants::cellsPerBlock - 1);
+        m_heap.collectorBlock(i)->marked.set(HeapConstants::cellsPerBlock - 1);
 }
 
 #if OS(WINCE)
@@ -744,7 +674,6 @@ void Heap::markConservatively(MarkStack& markStack, void* start, void* end)
     char** p = static_cast<char**>(start);
     char** e = static_cast<char**>(end);
 
-    CollectorBlock** blocks = m_heap.blocks;
     while (p != e) {
         char* x = *p++;
         if (isPossibleCell(x)) {
@@ -760,7 +689,7 @@ void Heap::markConservatively(MarkStack& markStack, void* start, void* end)
             CollectorBlock* blockAddr = reinterpret_cast<CollectorBlock*>(xAsBits - offset);
             usedBlocks = m_heap.usedBlocks;
             for (size_t block = 0; block < usedBlocks; block++) {
-                if (blocks[block] != blockAddr)
+                if (m_heap.collectorBlock(block) != blockAddr)
                     continue;
                 markStack.append(reinterpret_cast<JSCell*>(xAsBits));
                 markStack.drain();
@@ -1009,7 +938,7 @@ void Heap::markProtectedObjects(MarkStack& markStack)
 void Heap::clearMarkBits()
 {
     for (size_t i = 0; i < m_heap.usedBlocks; ++i)
-        clearMarkBits(m_heap.blocks[i]);
+        clearMarkBits(m_heap.collectorBlock(i));
 }
 
 void Heap::clearMarkBits(CollectorBlock* block)
@@ -1028,9 +957,9 @@ size_t Heap::markedCells(size_t startBlock, size_t startCell) const
         return 0;
 
     size_t result = 0;
-    result += m_heap.blocks[startBlock]->marked.count(startCell);
+    result += m_heap.collectorBlock(startBlock)->marked.count(startCell);
     for (size_t i = startBlock + 1; i < m_heap.usedBlocks; ++i)
-        result += m_heap.blocks[i]->marked.count();
+        result += m_heap.collectorBlock(i)->marked.count();
 
     return result;
 }
diff --git a/JavaScriptCore/runtime/Collector.h b/JavaScriptCore/runtime/Collector.h
index 6657e42..726a273 100644
--- a/JavaScriptCore/runtime/Collector.h
+++ b/JavaScriptCore/runtime/Collector.h
@@ -22,13 +22,16 @@
 #ifndef Collector_h
 #define Collector_h
 
+#include "AlignedMemoryAllocator.h"
 #include <stddef.h>
 #include <string.h>
+#include <wtf/Bitmap.h>
 #include <wtf/FixedArray.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/OwnPtr.h>
+#include <wtf/PageAllocation.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Threading.h>
@@ -37,10 +40,6 @@
 #include <pthread.h>
 #endif
 
-#if OS(SYMBIAN)
-#include <wtf/symbian/BlockAllocatorSymbian.h>
-#endif
-
 #define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell)
 
 namespace JSC {
@@ -57,10 +56,19 @@ namespace JSC {
 
     class LiveObjectIterator;
 
+#if OS(WINCE) || OS(SYMBIAN)
+    const size_t BLOCK_SIZE = 64 * 1024; // 64k
+#else
+    const size_t BLOCK_SIZE = 64 * 4096; // 256k
+#endif
+
+    typedef AlignedMemoryAllocator<BLOCK_SIZE> AlignedAllocator;
+    typedef AlignedMemory<BLOCK_SIZE> AlignedBlock;
+
     struct CollectorHeap {
         size_t nextBlock;
         size_t nextCell;
-        CollectorBlock** blocks;
+        AlignedBlock* blocks;
         
         void* nextNumber;
 
@@ -71,6 +79,11 @@ namespace JSC {
         bool didShrink;
 
         OperationInProgress operationInProgress;
+
+        CollectorBlock* collectorBlock(size_t index) const
+        {
+            return static_cast<CollectorBlock*>(blocks[index].base());
+        }
     };
 
     class Heap : public Noncopyable {
@@ -140,7 +153,6 @@ namespace JSC {
 
         NEVER_INLINE CollectorBlock* allocateBlock();
         NEVER_INLINE void freeBlock(size_t);
-        NEVER_INLINE void freeBlockPtr(CollectorBlock*);
         void freeBlocks();
         void resizeBlocks();
         void growBlocks(size_t neededBlocks);
@@ -181,21 +193,13 @@ namespace JSC {
         pthread_key_t m_currentThreadRegistrar;
 #endif
 
-#if OS(SYMBIAN)
         // Allocates collector blocks with correct alignment
-        WTF::AlignedBlockAllocator m_blockallocator; 
-#endif
+        AlignedAllocator m_blockallocator; 
         
         JSGlobalData* m_globalData;
     };
 
     // tunable parameters
-#if OS(WINCE) || OS(SYMBIAN)
-    const size_t BLOCK_SIZE = 64 * 1024; // 64k
-#else
-    const size_t BLOCK_SIZE = 64 * 4096; // 256k
-#endif
-
     // derived constants
     const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1;
     const size_t BLOCK_MASK = ~BLOCK_OFFSET_MASK;
diff --git a/JavaScriptCore/runtime/CollectorHeapIterator.h b/JavaScriptCore/runtime/CollectorHeapIterator.h
index 9a3327c..9d107b7 100644
--- a/JavaScriptCore/runtime/CollectorHeapIterator.h
+++ b/JavaScriptCore/runtime/CollectorHeapIterator.h
@@ -77,7 +77,7 @@ namespace JSC {
 
     inline JSCell* CollectorHeapIterator::operator*() const
     {
-        return reinterpret_cast<JSCell*>(&m_heap.blocks[m_block]->cells[m_cell]);
+        return reinterpret_cast<JSCell*>(&m_heap.collectorBlock(m_block)->cells[m_cell]);
     }
     
     // Iterators advance up to the next-to-last -- and not the last -- cell in a
@@ -103,7 +103,7 @@ namespace JSC {
         if (m_block < m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell))
             return *this;
 
-        while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell))
+        while (m_block < m_heap.usedBlocks && !m_heap.collectorBlock(m_block)->marked.get(m_cell))
             advance(HeapConstants::cellsPerBlock - 1);
         return *this;
     }
@@ -119,7 +119,7 @@ namespace JSC {
         do {
             advance(HeapConstants::cellsPerBlock - 1);
             ASSERT(m_block > m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell >= m_heap.nextCell));
-        } while (m_block < m_heap.usedBlocks && m_heap.blocks[m_block]->marked.get(m_cell));
+        } while (m_block < m_heap.usedBlocks && m_heap.collectorBlock(m_block)->marked.get(m_cell));
         return *this;
     }
 
diff --git a/JavaScriptCore/wtf/Bitmap.h b/JavaScriptCore/wtf/Bitmap.h
new file mode 100644
index 0000000..9672aa2
--- /dev/null
+++ b/JavaScriptCore/wtf/Bitmap.h
@@ -0,0 +1,121 @@
+/*
+ *  Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+#ifndef Bitmap_h
+#define Bitmap_h
+
+#include "FixedArray.h"
+#include "StdLibExtras.h"
+
+namespace WTF {
+
+template<size_t size>
+class Bitmap {
+private:
+    typedef uint32_t WordType;
+
+public:
+    bool get(size_t) const;
+    void set(size_t);
+    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;
+
+private:
+    static const WordType wordSize = sizeof(WordType) * 8;
+    static const WordType words = (size + wordSize - 1) / wordSize;
+
+    // the literal '1' is of type signed int.  We want to use an unsigned
+    // version of the correct size when doing the calculations because if
+    // WordType is larger than int, '1 << 31' will first be sign extended
+    // and then casted to unsigned, meaning that set(31) when WordType is
+    // a 64 bit unsigned int would give 0xffff8000
+    static const WordType one = 1;
+
+    FixedArray<WordType, words> bits;
+};
+
+template<size_t size>
+inline bool Bitmap<size>::get(size_t n) const
+{
+    return !!(bits[n / wordSize] & (one << (n % wordSize)));
+}
+
+template<size_t size>
+inline void Bitmap<size>::set(size_t n)
+{
+    bits[n / wordSize] |= (one << (n % wordSize));
+}
+
+template<size_t size>
+inline void Bitmap<size>::clear(size_t n)
+{
+    bits[n / wordSize] &= ~(one << (n % wordSize));
+}
+
+template<size_t size>
+inline void Bitmap<size>::clearAll()
+{
+    memset(bits.data(), 0, sizeof(bits));
+}
+
+template<size_t size>
+inline void Bitmap<size>::advanceToNextFreeBit(size_t& start) const
+{
+    if (!~bits[start / wordSize])
+        start = ((start / wordSize) + 1) * wordSize;
+    else
+        ++start;
+}
+
+template<size_t size>
+inline size_t Bitmap<size>::count(size_t start) const
+{
+    size_t result = 0;
+    for ( ; (start % wordSize); ++start) {
+        if (get(start))
+            ++result;
+    }
+    for (size_t i = start / wordSize; i < words; ++i)
+        result += WTF::bitCount(bits[i]);
+    return result;
+}
+
+template<size_t size>
+inline size_t Bitmap<size>::isEmpty() const
+{
+    for (size_t i = 0; i < words; ++i)
+        if (bits[i])
+            return false;
+    return true;
+}
+
+template<size_t size>
+inline size_t Bitmap<size>::isFull() const
+{
+    for (size_t i = 0; i < words; ++i)
+        if (~bits[i])
+            return false;
+    return true;
+}
+
+}
+#endif
diff --git a/JavaScriptCore/wtf/PageAllocation.h b/JavaScriptCore/wtf/PageAllocation.h
index 03bb0a6..fab9051 100644
--- a/JavaScriptCore/wtf/PageAllocation.h
+++ b/JavaScriptCore/wtf/PageAllocation.h
@@ -39,6 +39,51 @@
 #define PAGE_ALLOCATION_ALLOCATE_AT 0
 #endif
 
+#if HAVE(MMAP)
+#include <sys/mman.h>
+#include <unistd.h>
+#endif
+
+#if OS(DARWIN)
+
+#include <mach/mach_init.h>
+#include <mach/mach_port.h>
+#include <mach/task.h>
+#include <mach/thread_act.h>
+#include <mach/vm_map.h>
+
+#elif OS(WINDOWS)
+
+#include <malloc.h>
+#include <windows.h>
+
+#elif OS(HAIKU)
+
+#include <OS.h>
+
+#elif OS(UNIX)
+
+#include <stdlib.h>
+
+#if OS(SOLARIS)
+#include <thread.h>
+#else
+#include <pthread.h>
+#endif
+
+#if HAVE(PTHREAD_NP_H)
+#include <pthread_np.h>
+#endif
+
+#if OS(QNX)
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/procfs.h>
+#endif
+
+#endif
+
 namespace WTF {
 
 class PageAllocation {
@@ -82,6 +127,12 @@ public:
     size_t size() const { return m_size; }
 
     bool operator!() const { return !m_base; }
+#if COMPILER(WINSCW)
+    operator bool const { return m_base; }
+#else
+    typedef void* PageAllocation::*UnspecifiedBoolType;
+    operator UnspecifiedBoolType() const { return m_base ? &PageAllocation::m_base : 0; }
+#endif
 
     bool commit(void*, size_t, bool writable = true, bool executable = false) const;
     void decommit(void*, size_t) const;
@@ -93,6 +144,11 @@ public:
     static PageAllocation allocateAt(void* address, bool fixed, size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
     static PageAllocation reserveAt(void* address, bool fixed, size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
 #endif
+
+#if HAVE(ALIGNED_ALLOCATE)
+    static PageAllocation allocateAligned(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false);
+#endif
+
     static size_t pagesize();
 
 private:
@@ -118,6 +174,89 @@ private:
 #endif
 };
 
+#if HAVE(ALIGNED_ALLOCATE)
+
+#if OS(DARWIN)
+
+inline PageAllocation PageAllocation::allocateAligned(size_t size, Usage, bool writable, bool executable)
+{
+    ASSERT(!(size & (size - 1)));
+    vm_address_t address = 0;
+    vm_prot_t protection = VM_PROT_READ;
+    protection |= executable ? VM_PROT_EXECUTE : 0;
+    protection |= writable ? VM_PROT_WRITE : 0;
+    vm_map(current_task(), &address, size, (size - 1), VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, protection, protection, VM_INHERIT_DEFAULT);
+    return PageAllocation(reinterpret_cast<void*>(address), size);
+}
+
+#elif OS(WINDOWS)
+
+inline PageAllocation PageAllocation::allocateAligned(size_t size, Usage usage, bool writable, bool executable)
+{
+    ASSERT(writable && !executable);
+#if COMPILER(MINGW) && !COMPILER(MINGW64)
+    void* address = __mingw_aligned_malloc(size, size);
+#else
+    void* address = _aligned_malloc(size, size);
+#endif
+    memset(address, 0, size);
+    return PageAllocation(address, size);
+}
+
+#elif HAVE(POSIX_MEMALIGN)
+
+inline PageAllocation PageAllocation::allocateAligned(size_t size, Usage usage, bool writable, bool executable)
+{
+    ASSERT(writable && !executable);
+
+    void* address;
+    posix_memalign(&address, size, size);
+    return PageAllocation(address, size);
+}
+
+#elif HAVE(MMAP)
+
+inline PageAllocation PageAllocation::allocateAligned(size_t size, Usage usage, bool writable, bool executable)
+{
+    ASSERT(!(size & (size - 1)));
+    ASSERT(writable && !executable);
+    static size_t pagesize = getpagesize();
+
+    size_t extra = 0;
+    if (size > pagesize)
+        extra = size - pagesize;
+
+    int flags = MAP_PRIVATE | MAP_ANON;
+
+    int protection = PROT_READ;
+    if (writable)
+        protection |= PROT_WRITE;
+    if (executable)
+        protection |= PROT_EXEC;
+
+    // use page allocation
+    void* mmapResult = mmap(0, size + extra, protection, flags, usage, 0);
+    uintptr_t address = reinterpret_cast<uintptr_t>(mmapResult);
+
+    size_t adjust = 0;
+    if ((address & (size - 1)))
+        adjust = size - (address & (size - 1));
+
+    if (adjust > 0)
+        munmap(reinterpret_cast<char*>(address), adjust);
+
+    if (adjust < extra)
+        munmap(reinterpret_cast<char*>(address + adjust + size), extra - adjust);
+
+    address += adjust;
+
+    return PageAllocation(reinterpret_cast<void*>(address), size);
+}
+
+#endif
+
+#endif
+
 }
 
 using WTF::PageAllocation;
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h
index 6fe4eeb..0eea29f 100644
--- a/JavaScriptCore/wtf/Platform.h
+++ b/JavaScriptCore/wtf/Platform.h
@@ -708,6 +708,7 @@
 #define HAVE_ERRNO_H 1
 #define HAVE_LANGINFO_H 1
 #define HAVE_MMAP 1
+#define HAVE_ALIGNED_ALLOCATE 1
 #define HAVE_MERGESORT 1
 #define HAVE_SBRK 1
 #define HAVE_STRINGS_H 1
@@ -736,8 +737,10 @@
 
 #if OS(WINCE)
 #define HAVE_ERRNO_H 0
+#define HAVE_ALIGNED_ALLOCATE 0
 #else
 #define HAVE_SYS_TIMEB_H 1
+#define HAVE_ALIGNED_ALLOCATE 1
 #endif
 #define HAVE_VIRTUALALLOC 1
 
@@ -794,6 +797,14 @@
 
 #endif
 
+#if !defined(HAVE_ALIGNED_ALLOCATE)
+#if HAVE(POSIX_MEMALIGN)
+#define HAVE_ALIGNED_ALLOCATE 1
+#else
+#define HAVE_ALIGNED_ALLOCATE 0
+#endif
+#endif
+
 /* ENABLE macro defaults */
 
 #if PLATFORM(QT)
diff --git a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp b/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp
deleted file mode 100644
index 6a28e9e..0000000
--- a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if OS(SYMBIAN)
-
-#include "BlockAllocatorSymbian.h"
-
-
-namespace WTF {
-
-/** Efficiently allocates blocks of size blockSize with blockSize alignment. 
- * Primarly designed for JSC Collector's needs. 
- * Not thread-safe.    
- */
-AlignedBlockAllocator::AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize )
-    : m_reservation(reservationSize), 
-      m_blockSize(blockSize)
-{
-
-     // Get system's page size value.
-     SYMBIAN_PAGESIZE(m_pageSize); 
-     
-     // We only accept multiples of system page size for both initial reservation and the alignment/block size
-     m_reservation = SYMBIAN_ROUNDUPTOMULTIPLE(m_reservation, m_pageSize);
-     __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_blockSize, m_pageSize), User::Panic(_L("AlignedBlockAllocator1"), KErrArgument));
-     
-     // Calculate max. bit flags we need to carve a reservationSize range into blockSize-sized blocks
-     m_map.numBits = m_reservation / m_blockSize;   
-     const TUint32 bitsPerWord = 8*sizeof(TUint32); 
-     const TUint32 numWords = (m_map.numBits + bitsPerWord -1) / bitsPerWord; 
-   
-     m_map.bits = new TUint32[numWords];
-     __ASSERT_ALWAYS(m_map.bits, User::Panic(_L("AlignedBlockAllocator2"), KErrNoMemory));
-     m_map.clearAll();
-     
-     // Open a Symbian RChunk, and reserve requested virtual address range   
-     // Any thread in this process can operate this rchunk due to EOwnerProcess access rights. 
-     TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reservation , EOwnerProcess);  
-     if (ret != KErrNone) 
-         User::Panic(_L("AlignedBlockAllocator3"), ret);
-       
-     // This is the offset to m_chunk.Base() required to make it m_blockSize-aligned
-     m_offset = SYMBIAN_ROUNDUPTOMULTIPLE(TUint32(m_chunk.Base()), m_blockSize) - TUint(m_chunk.Base()); 
-
-}
-
-void* AlignedBlockAllocator::alloc()
-{
-
-    TInt  freeRam = 0; 
-    void* address = 0;
-    
-    // Look up first free slot in bit map
-    const TInt freeIdx = m_map.findFree();
-        
-    // Pseudo OOM: We ate up the address space we reserved..
-    // ..even though the device may have free RAM left
-    if (freeIdx < 0)
-        return 0;
-        
-    TInt ret = m_chunk.Commit(m_offset + (m_blockSize * freeIdx), m_blockSize);
-    if (ret != KErrNone)  
-        return 0; // True OOM: Device didn't have physical RAM to spare
-        
-    // Updated bit to mark region as in use. 
-    m_map.set(freeIdx); 
-    
-    // Calculate address of committed region (block)
-    address = (void*)( (m_chunk.Base() + m_offset) + (TUint)(m_blockSize * freeIdx) );
-    
-    return address;
-}
-
-void AlignedBlockAllocator::free(void* block)
-{
-    // Calculate index of block to be freed
-    TInt idx = TUint(static_cast<TUint8*>(block) - m_chunk.Base() - m_offset) / m_blockSize;
-    
-    __ASSERT_DEBUG(idx >= 0 && idx < m_map.numBits, User::Panic(_L("AlignedBlockAllocator4"), KErrCorrupt)); // valid index check
-    __ASSERT_DEBUG(m_map.get(idx), User::Panic(_L("AlignedBlockAllocator5"), KErrCorrupt)); // in-use flag check    
-    
-    // Return committed region to system RAM pool (the physical RAM becomes usable by others)
-    TInt ret = m_chunk.Decommit(m_offset + m_blockSize * idx, m_blockSize);
-            
-    // mark this available again
-    m_map.clear(idx); 
-}
-
-void AlignedBlockAllocator::destroy() 
-{
-    // release everything!
-    m_chunk.Decommit(0, m_chunk.MaxSize());
-    m_map.clearAll();
-}
-
-AlignedBlockAllocator::~AlignedBlockAllocator()
-{
-    destroy();
-    m_chunk.Close();
-    delete [] m_map.bits;
-}
-
-} // end of namespace
-
-#endif // SYMBIAN
diff --git a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h b/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h
deleted file mode 100644
index 21422f6..0000000
--- a/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BlockAllocatorSymbian_h
-#define BlockAllocatorSymbian_h
-
-#include <e32cmn.h>
-#include <e32std.h>
-#include <hal.h>
-
-
-#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x));
-#define SYMBIAN_FREERAM(x)  (HAL::Get(HALData::EMemoryRAMFree, x));
-#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof)    ( (x + multipleof - 1) & ~(multipleof - 1) )
-
-// Set sane defaults if -D<flagname=value> wasn't provided via compiler args
-#ifndef JSCCOLLECTOR_VIRTUALMEM_RESERVATION
-#if defined(__WINS__) 
-    // Emulator has limited virtual address space
-    #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (4*1024*1024)
-#else
-    // HW has plenty of virtual addresses
-    #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (128*1024*1024)
-#endif
-#endif
-
-namespace WTF {
-
-/** 
- *  Allocates contiguous region of size blockSize with blockSize-aligned address. 
- *  blockSize must be a multiple of system page size (typically 4K on Symbian/ARM)
- *
- *  @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes).
- *  @param blockSize Size of a single allocation. Returned address will also be blockSize-aligned.
- */
-class AlignedBlockAllocator {
-    public:
-        AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize);
-        ~AlignedBlockAllocator();
-        void destroy();
-        void* alloc();
-        void free(void* data);
-    
-    private: 
-        RChunk   m_chunk; // Symbian chunk that lets us reserve/commit/decommit
-        TUint    m_offset; // offset of first committed region from base 
-        TInt     m_pageSize; // cached value of system page size, typically 4K on Symbian
-        TUint32  m_reservation;
-        TUint32  m_blockSize;  
-
-        // Tracks comitted/decommitted state of a blockSize region
-        struct {
-            
-            TUint32 *bits; // array of bit flags 
-            TUint32  numBits; // number of regions to keep track of
-            
-            bool get(TUint32 n) const
-            {
-                return !!(bits[n >> 5] & (1 << (n & 0x1F)));
-            }
-            
-            void set(TUint32 n)
-            {
-                bits[n >> 5] |= (1 << (n & 0x1F));
-            }
-            
-            void clear(TUint32 n)
-            {
-                bits[n >> 5] &= ~(1 << (n & 0x1F));
-            }
-            
-            void clearAll()
-            {
-               for (TUint32 i = 0; i < numBits; i++)
-                    clear(i);
-            }
-            
-            TInt findFree() const
-            {
-                for (TUint32 i = 0; i < numBits; i++) {
-                    if (!get(i)) 
-                        return i;
-                }
-                return -1;
-            }
-            
-        } m_map;  
-
-};
- 
-}
-
-#endif // end of BlockAllocatorSymbian_h
-
-

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list