#define HeapBlock_h
#include <wtf/DoublyLinkedList.h>
-#include <wtf/PageAllocationAligned.h>
#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:
- 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_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