summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lind <plind@mips.com>2012-11-19 22:14:24 -0800
committerPaul Lind <plind@mips.com>2012-11-19 22:14:24 -0800
commitdec5441e170f6cacbb0326406169cc5f4d6429ee (patch)
treed5f0f6b76237a573ef11af59c328ad2a8c5b6143
parente1e9db52f8df0681114665b56368f7b19449ee33 (diff)
downloadwebkit-dec5441e170f6cacbb0326406169cc5f4d6429ee.tar.gz
[MIPS] Ensure correct buffer alignment for doubles.
For mips, doubles and objects containing them must be aligned to 8 bytes. This fixes up the LinearAllocator, so that the graphics context recording storage is properly aligned. This fixes a browser startup crash in Recording::draw() for concatCTM(), as AffineTransform contains an array of doubles. Change-Id: I8c06d0f4ed38d6ff0aad06d77016e55d57bb39b9
-rw-r--r--Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp b/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
index b94594485..636c30cc4 100644
--- a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
+++ b/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
@@ -44,7 +44,14 @@ namespace WebCore {
// Must be smaller than INITIAL_PAGE_SIZE
#define MAX_WASTE_SIZE ((size_t)1024)
-#define ALIGN(x) (x + (x % sizeof(int)))
+#if CPU(MIPS)
+#define ALIGN_SZ (sizeof(double))
+#else
+#define ALIGN_SZ (sizeof(int))
+#endif
+
+#define ALIGN(x) ((x + ALIGN_SZ - 1 ) & ~(ALIGN_SZ - 1))
+#define ALIGN_PTR(p) ((void*)(ALIGN((unsigned int)p)))
#if LOG_NDEBUG
#define ADD_ALLOCATION(size)
@@ -123,7 +130,7 @@ LinearAllocator::~LinearAllocator(void)
void* LinearAllocator::start(Page* p)
{
- return ((char*)p) + sizeof(Page);
+ return ALIGN_PTR(((char*)p) + sizeof(Page));
}
void* LinearAllocator::end(Page* p)
@@ -178,6 +185,7 @@ void* LinearAllocator::alloc(size_t size)
void LinearAllocator::rewindIfLastAlloc(void* ptr, size_t allocSize)
{
// Don't bother rewinding across pages
+ allocSize = ALIGN(allocSize);
if (ptr >= start(m_currentPage) && ptr < end(m_currentPage)
&& ptr == ((char*)m_next - allocSize)) {
m_totalAllocated -= allocSize;
@@ -188,7 +196,7 @@ void LinearAllocator::rewindIfLastAlloc(void* ptr, size_t allocSize)
LinearAllocator::Page* LinearAllocator::newPage(size_t pageSize)
{
- pageSize += sizeof(LinearAllocator::Page);
+ pageSize = ALIGN(pageSize + sizeof(LinearAllocator::Page));
ADD_ALLOCATION(pageSize);
m_totalAllocated += pageSize;
m_pageCount++;