Title: [108553] trunk/Source/_javascript_Core
- Revision
- 108553
- Author
- [email protected]
- Date
- 2012-02-22 14:26:22 -0800 (Wed, 22 Feb 2012)
Log Message
Allocations from CopiedBlocks should always be 8-byte aligned
https://bugs.webkit.org/show_bug.cgi?id=79271
Reviewed by Geoffrey Garen.
* heap/CopiedAllocator.h:
(JSC::CopiedAllocator::allocate):
* heap/CopiedBlock.h: Changed to add padding so that the start of the payload is always
guaranteed to be 8 byte aligned on both 64- and 32-bit platforms.
(CopiedBlock):
* heap/CopiedSpace.cpp: Changed all assertions of isPointerAligned to is8ByteAligned.
(JSC::CopiedSpace::tryAllocateOversize):
(JSC::CopiedSpace::getFreshBlock):
* heap/CopiedSpaceInlineMethods.h:
(JSC::CopiedSpace::allocateFromBlock):
* runtime/JSArray.h:
(ArrayStorage): Added padding for ArrayStorage to make sure that it is always 8 byte
aligned on both 64- and 32-bit platforms.
* wtf/StdLibExtras.h:
(WTF::is8ByteAligned): Added new utility function that functions similarly to the
way isPointerAligned does, but it just always checks for 8 byte alignment.
(WTF):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (108552 => 108553)
--- trunk/Source/_javascript_Core/ChangeLog 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-02-22 22:26:22 UTC (rev 108553)
@@ -1,3 +1,28 @@
+2012-02-22 Mark Hahnenberg <[email protected]>
+
+ Allocations from CopiedBlocks should always be 8-byte aligned
+ https://bugs.webkit.org/show_bug.cgi?id=79271
+
+ Reviewed by Geoffrey Garen.
+
+ * heap/CopiedAllocator.h:
+ (JSC::CopiedAllocator::allocate):
+ * heap/CopiedBlock.h: Changed to add padding so that the start of the payload is always
+ guaranteed to be 8 byte aligned on both 64- and 32-bit platforms.
+ (CopiedBlock):
+ * heap/CopiedSpace.cpp: Changed all assertions of isPointerAligned to is8ByteAligned.
+ (JSC::CopiedSpace::tryAllocateOversize):
+ (JSC::CopiedSpace::getFreshBlock):
+ * heap/CopiedSpaceInlineMethods.h:
+ (JSC::CopiedSpace::allocateFromBlock):
+ * runtime/JSArray.h:
+ (ArrayStorage): Added padding for ArrayStorage to make sure that it is always 8 byte
+ aligned on both 64- and 32-bit platforms.
+ * wtf/StdLibExtras.h:
+ (WTF::is8ByteAligned): Added new utility function that functions similarly to the
+ way isPointerAligned does, but it just always checks for 8 byte alignment.
+ (WTF):
+
2012-02-22 Sheriff Bot <[email protected]>
Unreviewed, rolling out r108456.
Modified: trunk/Source/_javascript_Core/heap/CopiedAllocator.h (108552 => 108553)
--- trunk/Source/_javascript_Core/heap/CopiedAllocator.h 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/heap/CopiedAllocator.h 2012-02-22 22:26:22 UTC (rev 108553)
@@ -57,10 +57,11 @@
inline void* CopiedAllocator::allocate(size_t bytes)
{
ASSERT(m_currentOffset);
+ ASSERT(is8ByteAligned(reinterpret_cast<void*>(bytes)));
ASSERT(fitsInCurrentBlock(bytes));
void* ptr = static_cast<void*>(m_currentOffset);
m_currentOffset += bytes;
- ASSERT(isPointerAligned(ptr));
+ ASSERT(is8ByteAligned(ptr));
return ptr;
}
Modified: trunk/Source/_javascript_Core/heap/CopiedBlock.h (108552 => 108553)
--- trunk/Source/_javascript_Core/heap/CopiedBlock.h 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/heap/CopiedBlock.h 2012-02-22 22:26:22 UTC (rev 108553)
@@ -46,6 +46,7 @@
private:
void* m_offset;
uintptr_t m_isPinned;
+ uintptr_t m_padding;
char m_payload[1];
};
Modified: trunk/Source/_javascript_Core/heap/CopiedSpace.cpp (108552 => 108553)
--- trunk/Source/_javascript_Core/heap/CopiedSpace.cpp 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/heap/CopiedSpace.cpp 2012-02-22 22:26:22 UTC (rev 108553)
@@ -79,7 +79,7 @@
}
CopiedBlock* block = new (NotNull, allocation.base()) CopiedBlock(allocation);
m_oversizeBlocks.push(block);
- ASSERT(isPointerAligned(block->m_offset));
+ ASSERT(is8ByteAligned(block->m_offset));
m_oversizeFilter.add(reinterpret_cast<Bits>(block));
@@ -256,7 +256,7 @@
}
}
ASSERT(block);
- ASSERT(isPointerAligned(block->m_offset));
+ ASSERT(is8ByteAligned(block->m_offset));
*outBlock = block;
return true;
}
Modified: trunk/Source/_javascript_Core/heap/CopiedSpaceInlineMethods.h (108552 => 108553)
--- trunk/Source/_javascript_Core/heap/CopiedSpaceInlineMethods.h 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/heap/CopiedSpaceInlineMethods.h 2012-02-22 22:26:22 UTC (rev 108553)
@@ -148,14 +148,14 @@
{
ASSERT(!isOversize(bytes));
ASSERT(fitsInBlock(block, bytes));
- ASSERT(isPointerAligned(block->m_offset));
+ ASSERT(is8ByteAligned(block->m_offset));
void* ptr = block->m_offset;
ASSERT(block->m_offset >= block->m_payload && block->m_offset < reinterpret_cast<char*>(block) + HeapBlock::s_blockSize);
block->m_offset = static_cast<void*>((static_cast<char*>(ptr) + bytes));
ASSERT(block->m_offset >= block->m_payload && block->m_offset < reinterpret_cast<char*>(block) + HeapBlock::s_blockSize);
- ASSERT(isPointerAligned(ptr));
+ ASSERT(is8ByteAligned(ptr));
return ptr;
}
Modified: trunk/Source/_javascript_Core/runtime/JSArray.h (108552 => 108553)
--- trunk/Source/_javascript_Core/runtime/JSArray.h 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/runtime/JSArray.h 2012-02-22 22:26:22 UTC (rev 108553)
@@ -117,7 +117,9 @@
unsigned m_numValuesInVector;
void* m_allocBase; // Pointer to base address returned by malloc(). Keeping this pointer does eliminate false positives from the leak detector.
#if CHECK_ARRAY_CONSISTENCY
- bool m_inCompactInitialization;
+ uintptr_t m_inCompactInitialization; // Needs to be a uintptr_t for alignment purposes.
+#else
+ uintptr_t m_padding;
#endif
WriteBarrier<Unknown> m_vector[1];
};
Modified: trunk/Source/_javascript_Core/wtf/StdLibExtras.h (108552 => 108553)
--- trunk/Source/_javascript_Core/wtf/StdLibExtras.h 2012-02-22 22:25:18 UTC (rev 108552)
+++ trunk/Source/_javascript_Core/wtf/StdLibExtras.h 2012-02-22 22:26:22 UTC (rev 108553)
@@ -114,6 +114,11 @@
return !((intptr_t)(p) & (sizeof(char*) - 1));
}
+inline bool is8ByteAligned(void* p)
+{
+ return !((uintptr_t)(p) & (sizeof(double) - 1));
+}
+
/*
* C++'s idea of a reinterpret_cast lacks sufficient cojones.
*/
@@ -292,6 +297,7 @@
using WTF::KB;
using WTF::isPointerAligned;
+using WTF::is8ByteAligned;
using WTF::binarySearch;
using WTF::bitwise_cast;
using WTF::safeCast;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes