]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - heap/HeapBlock.h
JavaScriptCore-1218.tar.gz
[apple/javascriptcore.git] / heap / HeapBlock.h
index 591520d2b75747b4a3843155339a072f0bd03829..6f2a74c08d7271a8fb1fc6e04aee9086fd909230 100644 (file)
 #define HeapBlock_h
 
 #include <wtf/DoublyLinkedList.h>
 #define HeapBlock_h
 
 #include <wtf/DoublyLinkedList.h>
-#include <wtf/PageAllocationAligned.h>
 #include <wtf/StdLibExtras.h>
 
 namespace JSC {
 
 enum AllocationEffort { AllocationCanFail, AllocationMustSucceed };
 
 #include <wtf/StdLibExtras.h>
 
 namespace JSC {
 
 enum AllocationEffort { AllocationCanFail, AllocationMustSucceed };
 
-class HeapBlock : public DoublyLinkedListNode<HeapBlock> {
+class Region;
+
+#if COMPILER(GCC)
+#define CLASS_IF_GCC class
+#else
+#define CLASS_IF_GCC
+#endif
+
+template<typename T>
+class HeapBlock : public DoublyLinkedListNode<T> {
+    friend CLASS_IF_GCC DoublyLinkedListNode<T>;
 public:
 public:
-    HeapBlock(PageAllocationAligned& allocation)
-        : DoublyLinkedListNode<HeapBlock>()
+    static HeapBlock* destroy(HeapBlock* block) WARN_UNUSED_RETURN
+    {
+        static_cast<T*>(block)->~T();
+        return block;
+    }
+
+    HeapBlock(Region* region)
+        : DoublyLinkedListNode<T>()
+        , m_region(region)
         , m_prev(0)
         , m_next(0)
         , m_prev(0)
         , m_next(0)
-        , m_allocation(allocation)
     {
     {
-        ASSERT(allocation);
+        ASSERT(m_region);
     }
 
     }
 
-    HeapBlock* m_prev;
-    HeapBlock* m_next;
-    PageAllocationAligned m_allocation;
-    
-    static const size_t s_blockSize = 64 * KB;
+    Region* region() const { return m_region; }
+
+private:
+    Region* m_region;
+    T* m_prev;
+    T* m_next;
 };
 
 } // namespace JSC
 };
 
 } // namespace JSC