From a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 25 May 2012 15:09:11 +0200 Subject: Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516) --- Source/JavaScriptCore/heap/CopiedBlock.h | 51 ++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'Source/JavaScriptCore/heap/CopiedBlock.h') diff --git a/Source/JavaScriptCore/heap/CopiedBlock.h b/Source/JavaScriptCore/heap/CopiedBlock.h index 431b86c38..b408aa40b 100644 --- a/Source/JavaScriptCore/heap/CopiedBlock.h +++ b/Source/JavaScriptCore/heap/CopiedBlock.h @@ -38,32 +38,51 @@ class CopiedBlock : public HeapBlock { friend class CopiedSpace; friend class CopiedAllocator; public: - CopiedBlock(PageAllocationAligned& allocation) - : HeapBlock(allocation) - , m_offset(payload()) - , m_isPinned(false) - { - ASSERT(is8ByteAligned(static_cast(m_offset))); -#if USE(JSVALUE64) - char* offset = static_cast(m_offset); - memset(static_cast(offset), 0, static_cast((reinterpret_cast(this) + allocation.size()) - offset)); -#else - JSValue emptyValue; - JSValue* limit = reinterpret_cast_ptr(reinterpret_cast(this) + allocation.size()); - for (JSValue* currentValue = reinterpret_cast(m_offset); currentValue < limit; currentValue++) - *currentValue = emptyValue; -#endif - } + static CopiedBlock* create(const PageAllocationAligned&); + static PageAllocationAligned destroy(CopiedBlock*); char* payload(); size_t size(); size_t capacity(); private: + CopiedBlock(const PageAllocationAligned&); + void* m_offset; uintptr_t m_isPinned; }; +inline CopiedBlock* CopiedBlock::create(const PageAllocationAligned& allocation) +{ + return new(NotNull, allocation.base()) CopiedBlock(allocation); +} + +inline PageAllocationAligned CopiedBlock::destroy(CopiedBlock* block) +{ + PageAllocationAligned allocation; + swap(allocation, block->m_allocation); + + block->~CopiedBlock(); + return allocation; +} + +inline CopiedBlock::CopiedBlock(const PageAllocationAligned& allocation) + : HeapBlock(allocation) + , m_offset(payload()) + , m_isPinned(false) +{ + ASSERT(is8ByteAligned(static_cast(m_offset))); +#if USE(JSVALUE64) + char* offset = static_cast(m_offset); + memset(static_cast(offset), 0, static_cast((reinterpret_cast(this) + allocation.size()) - offset)); +#else + JSValue emptyValue; + JSValue* limit = reinterpret_cast_ptr(reinterpret_cast(this) + allocation.size()); + for (JSValue* currentValue = reinterpret_cast(m_offset); currentValue < limit; currentValue++) + *currentValue = emptyValue; +#endif +} + inline char* CopiedBlock::payload() { return reinterpret_cast(this) + ((sizeof(CopiedBlock) + 7) & ~7); -- cgit v1.2.1