[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
loki at webkit.org
loki at webkit.org
Wed Dec 22 12:03:50 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 7534a3fa33563d8712a51ec0439cc9968eaf2fa2
Author: loki at webkit.org <loki at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 13 10:14:36 2010 +0000
Avoid increasing required alignment of target type warning on ARM
https://bugs.webkit.org/show_bug.cgi?id=38045
Reviewed by Gavin Barraclough.
The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM:
increases required alignment of target type warnings.
Casting the type of [pointer to Type2] object to void* bypasses the
warning.
* JavaScriptCore/assembler/ARMAssembler.cpp:
(JSC::ARMAssembler::executableCopy):
* JavaScriptCore/assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::putShortUnchecked):
(JSC::AssemblerBuffer::putIntUnchecked):
(JSC::AssemblerBuffer::putInt64Unchecked):
* JavaScriptCore/interpreter/RegisterFile.h:
(JSC::RegisterFile::RegisterFile):
(JSC::RegisterFile::grow):
* JavaScriptCore/jit/JITStubs.cpp:
* JavaScriptCore/pcre/pcre_compile.cpp:
(jsRegExpCompile):
* JavaScriptCore/runtime/JSArray.cpp:
(JSC::JSArray::putSlowCase):
(JSC::JSArray::increaseVectorLength):
(JSC::JSArray::increaseVectorPrefixLength):
(JSC::JSArray::shiftCount):
(JSC::JSArray::unshiftCount):
* JavaScriptCore/wtf/FastMalloc.cpp:
(WTF::PageHeapAllocator::New):
(WTF::TCMalloc_Central_FreeList::Populate):
* wtf/MD5.cpp:
(WTF::reverseBytes):
(WTF::MD5::addBytes):
(WTF::MD5::checksum):
* JavaScriptCore/wtf/StdLibExtras.h:
(isPointerTypeAlignmentOkay):
(reinterpret_cast_ptr):
* JavaScriptCore/wtf/Vector.h:
(WTF::VectorBuffer::inlineBuffer):
* JavaScriptCore/wtf/qt/StringQt.cpp:
(WTF::String::String):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index c83ba39..024e68c 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,49 @@
+2010-08-13 Gabor Loki <loki at webkit.org>
+
+ Reviewed by Gavin Barraclough.
+
+ Avoid increasing required alignment of target type warning on ARM
+ https://bugs.webkit.org/show_bug.cgi?id=38045
+
+ The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
+ sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM:
+ increases required alignment of target type warnings.
+ Casting the type of [pointer to Type2] object to void* bypasses the
+ warning.
+
+ * assembler/ARMAssembler.cpp:
+ (JSC::ARMAssembler::executableCopy):
+ * assembler/AssemblerBuffer.h:
+ (JSC::AssemblerBuffer::putShortUnchecked):
+ (JSC::AssemblerBuffer::putIntUnchecked):
+ (JSC::AssemblerBuffer::putInt64Unchecked):
+ * interpreter/RegisterFile.h:
+ (JSC::RegisterFile::RegisterFile):
+ (JSC::RegisterFile::grow):
+ * jit/JITStubs.cpp:
+ * pcre/pcre_compile.cpp:
+ (jsRegExpCompile):
+ * runtime/JSArray.cpp:
+ (JSC::JSArray::putSlowCase):
+ (JSC::JSArray::increaseVectorLength):
+ (JSC::JSArray::increaseVectorPrefixLength):
+ (JSC::JSArray::shiftCount):
+ (JSC::JSArray::unshiftCount):
+ * wtf/FastMalloc.cpp:
+ (WTF::PageHeapAllocator::New):
+ (WTF::TCMalloc_Central_FreeList::Populate):
+ * wtf/MD5.cpp:
+ (WTF::reverseBytes):
+ (WTF::MD5::addBytes):
+ (WTF::MD5::checksum):
+ * wtf/StdLibExtras.h:
+ (isPointerTypeAlignmentOkay):
+ (reinterpret_cast_ptr):
+ * wtf/Vector.h:
+ (WTF::VectorBuffer::inlineBuffer):
+ * wtf/qt/StringQt.cpp:
+ (WTF::String::String):
+
2010-08-13 Gavin Barraclough <barraclough at apple.com>
Reviewed by Sam Weinig
diff --git a/JavaScriptCore/assembler/ARMAssembler.cpp b/JavaScriptCore/assembler/ARMAssembler.cpp
index 9442b4b..42a6402 100644
--- a/JavaScriptCore/assembler/ARMAssembler.cpp
+++ b/JavaScriptCore/assembler/ARMAssembler.cpp
@@ -357,11 +357,11 @@ void* ARMAssembler::executableCopy(ExecutablePool* allocator)
for (Jumps::Iterator iter = m_jumps.begin(); iter != m_jumps.end(); ++iter) {
// The last bit is set if the constant must be placed on constant pool.
int pos = (*iter) & (~0x1);
- ARMWord* ldrAddr = reinterpret_cast<ARMWord*>(data + pos);
+ ARMWord* ldrAddr = reinterpret_cast_ptr<ARMWord*>(data + pos);
ARMWord* addr = getLdrImmAddress(ldrAddr);
if (*addr != InvalidBranchTarget) {
if (!(*iter & 1)) {
- int diff = reinterpret_cast<ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetching);
+ int diff = reinterpret_cast_ptr<ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetching);
if ((diff <= BOFFSET_MAX && diff >= BOFFSET_MIN)) {
*ldrAddr = B | getConditionalField(*ldrAddr) | (diff & BRANCH_MASK);
diff --git a/JavaScriptCore/assembler/AssemblerBuffer.h b/JavaScriptCore/assembler/AssemblerBuffer.h
index 11e0df0..0454a99 100644
--- a/JavaScriptCore/assembler/AssemblerBuffer.h
+++ b/JavaScriptCore/assembler/AssemblerBuffer.h
@@ -33,6 +33,7 @@
#include <jit/ExecutableAllocator.h>
#include <wtf/Assertions.h>
#include <wtf/FastMalloc.h>
+#include <wtf/StdLibExtras.h>
namespace JSC {
@@ -81,7 +82,7 @@ namespace JSC {
void putShortUnchecked(int value)
{
ASSERT(!(m_size > m_capacity - 4));
- *reinterpret_cast<short*>(&m_buffer[m_size]) = value;
+ *reinterpret_cast_ptr<short*>(&m_buffer[m_size]) = value;
m_size += 2;
}
@@ -95,14 +96,14 @@ namespace JSC {
void putIntUnchecked(int value)
{
ASSERT(!(m_size > m_capacity - 4));
- *reinterpret_cast<int*>(&m_buffer[m_size]) = value;
+ *reinterpret_cast_ptr<int*>(&m_buffer[m_size]) = value;
m_size += 4;
}
void putInt64Unchecked(int64_t value)
{
ASSERT(!(m_size > m_capacity - 8));
- *reinterpret_cast<int64_t*>(&m_buffer[m_size]) = value;
+ *reinterpret_cast_ptr<int64_t*>(&m_buffer[m_size]) = value;
m_size += 8;
}
diff --git a/JavaScriptCore/interpreter/RegisterFile.h b/JavaScriptCore/interpreter/RegisterFile.h
index 6c4e969..f3284ff 100644
--- a/JavaScriptCore/interpreter/RegisterFile.h
+++ b/JavaScriptCore/interpreter/RegisterFile.h
@@ -166,7 +166,7 @@ namespace JSC {
checkAllocatedOkay(base);
size_t committedSize = roundUpAllocationSize(maxGlobals * sizeof(Register), commitSize);
checkAllocatedOkay(m_reservation.commit(base, committedSize));
- m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(base) + committedSize);
+ m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(base) + committedSize);
m_start = static_cast<Register*>(base) + maxGlobals;
m_end = m_start;
m_maxUsed = m_end;
@@ -193,7 +193,7 @@ namespace JSC {
if (newEnd > m_commitEnd) {
size_t size = roundUpAllocationSize(reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_commitEnd), commitSize);
checkAllocatedOkay(m_reservation.commit(m_commitEnd, size));
- m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_commitEnd) + size);
+ m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitEnd) + size);
}
if (newEnd > m_maxUsed)
diff --git a/JavaScriptCore/jit/JITStubs.cpp b/JavaScriptCore/jit/JITStubs.cpp
index c5dcd41..8052d2c 100644
--- a/JavaScriptCore/jit/JITStubs.cpp
+++ b/JavaScriptCore/jit/JITStubs.cpp
@@ -967,13 +967,13 @@ struct StackHack {
ReturnAddressPtr savedReturnAddress;
};
-#define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast<JITStackFrame*>(STUB_ARGS); StackHack stackHack(stackFrame)
+#define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast_ptr<JITStackFrame*>(STUB_ARGS); StackHack stackHack(stackFrame)
#define STUB_SET_RETURN_ADDRESS(returnAddress) stackHack.savedReturnAddress = ReturnAddressPtr(returnAddress)
#define STUB_RETURN_ADDRESS stackHack.savedReturnAddress
#else
-#define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast<JITStackFrame*>(STUB_ARGS)
+#define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast_ptr<JITStackFrame*>(STUB_ARGS)
#define STUB_SET_RETURN_ADDRESS(returnAddress) *stackFrame.returnAddressSlot() = ReturnAddressPtr(returnAddress)
#define STUB_RETURN_ADDRESS *stackFrame.returnAddressSlot()
diff --git a/JavaScriptCore/pcre/pcre_compile.cpp b/JavaScriptCore/pcre/pcre_compile.cpp
index ea6e44c..9d472d8 100644
--- a/JavaScriptCore/pcre/pcre_compile.cpp
+++ b/JavaScriptCore/pcre/pcre_compile.cpp
@@ -49,6 +49,7 @@ supporting internal functions that are not used by other modules. */
#include <wtf/ASCIICType.h>
#include <wtf/FastMalloc.h>
#include <wtf/FixedArray.h>
+#include <wtf/StdLibExtras.h>
using namespace WTF;
@@ -2590,7 +2591,7 @@ JSRegExp* jsRegExpCompile(const UChar* pattern, int patternLength,
size_t stringOffset = (size + sizeof(UChar) - 1) / sizeof(UChar) * sizeof(UChar);
size = stringOffset + patternLength * sizeof(UChar);
#endif
- JSRegExp* re = reinterpret_cast<JSRegExp*>(new char[size]);
+ JSRegExp* re = reinterpret_cast_ptr<JSRegExp*>(new char[size]);
if (!re)
return returnError(ERR13, errorPtr);
diff --git a/JavaScriptCore/runtime/JSArray.cpp b/JavaScriptCore/runtime/JSArray.cpp
index ffb8d9e..a0c46da 100644
--- a/JavaScriptCore/runtime/JSArray.cpp
+++ b/JavaScriptCore/runtime/JSArray.cpp
@@ -441,7 +441,7 @@ NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue valu
return;
}
- m_storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
+ m_storage = reinterpret_cast_ptr<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
m_storage->m_allocBase = baseStorage;
storage = m_storage;
@@ -591,7 +591,7 @@ bool JSArray::increaseVectorLength(unsigned newLength)
if (!tryFastRealloc(baseStorage, storageSize(newVectorLength + m_indexBias)).getValue(baseStorage))
return false;
- storage = m_storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
+ storage = m_storage = reinterpret_cast_ptr<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));
m_storage->m_allocBase = baseStorage;
JSValue* vector = storage->m_vector;
@@ -623,7 +623,7 @@ bool JSArray::increaseVectorPrefixLength(unsigned newLength)
m_indexBias += newVectorLength - newLength;
- m_storage = reinterpret_cast<ArrayStorage*>(static_cast<char*>(newBaseStorage) + m_indexBias * sizeof(JSValue));
+ m_storage = reinterpret_cast_ptr<ArrayStorage*>(static_cast<char*>(newBaseStorage) + m_indexBias * sizeof(JSValue));
memcpy(m_storage, storage, storageSize(0));
memcpy(&m_storage->m_vector[newLength - m_vectorLength], &storage->m_vector[0], vectorLength * sizeof(JSValue));
@@ -802,7 +802,7 @@ void JSArray::shiftCount(ExecState* exec, int count)
if (m_vectorLength) {
char* newBaseStorage = reinterpret_cast<char*>(storage) + count * sizeof(JSValue);
memmove(newBaseStorage, storage, storageSize(0));
- m_storage = reinterpret_cast<ArrayStorage*>(newBaseStorage);
+ m_storage = reinterpret_cast_ptr<ArrayStorage*>(newBaseStorage);
m_indexBias += count;
}
@@ -839,7 +839,7 @@ void JSArray::unshiftCount(ExecState* exec, int count)
m_indexBias -= count;
char* newBaseStorage = reinterpret_cast<char*>(storage) - count * sizeof(JSValue);
memmove(newBaseStorage, storage, storageSize(0));
- m_storage = reinterpret_cast<ArrayStorage*>(newBaseStorage);
+ m_storage = reinterpret_cast_ptr<ArrayStorage*>(newBaseStorage);
m_vectorLength += count;
} else if (!increaseVectorPrefixLength(m_vectorLength + count)) {
throwOutOfMemoryError(exec);
diff --git a/JavaScriptCore/wtf/FastMalloc.cpp b/JavaScriptCore/wtf/FastMalloc.cpp
index b1b2416..39cd324 100644
--- a/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/JavaScriptCore/wtf/FastMalloc.cpp
@@ -82,6 +82,7 @@
#if ENABLE(JSC_MULTIPLE_THREADS)
#include <pthread.h>
#endif
+#include <wtf/StdLibExtras.h>
#ifndef NO_TCMALLOC_SAMPLES
#ifdef WTF_CHANGES
@@ -1017,7 +1018,7 @@ class PageHeapAllocator {
if (!new_allocation)
CRASH();
- *(void**)new_allocation = allocated_regions_;
+ *reinterpret_cast_ptr<void**>(new_allocation) = allocated_regions_;
allocated_regions_ = new_allocation;
free_area_ = new_allocation + kAlignedSize;
free_avail_ = kAllocIncrement - kAlignedSize;
@@ -2718,7 +2719,7 @@ ALWAYS_INLINE void TCMalloc_Central_FreeList::Populate() {
char* nptr;
while ((nptr = ptr + size) <= limit) {
*tail = ptr;
- tail = reinterpret_cast<void**>(ptr);
+ tail = reinterpret_cast_ptr<void**>(ptr);
ptr = nptr;
num++;
}
diff --git a/JavaScriptCore/wtf/MD5.cpp b/JavaScriptCore/wtf/MD5.cpp
index e995102..375446e 100644
--- a/JavaScriptCore/wtf/MD5.cpp
+++ b/JavaScriptCore/wtf/MD5.cpp
@@ -54,6 +54,7 @@
#include "StringExtras.h"
#include "text/CString.h"
#endif
+#include <wtf/StdLibExtras.h>
namespace WTF {
@@ -103,7 +104,7 @@ static void reverseBytes(uint8_t* buf, unsigned longs)
do {
uint32_t t = static_cast<uint32_t>(buf[3] << 8 | buf[2]) << 16 | buf[1] << 8 | buf[0];
ASSERT_WITH_MESSAGE(!(reinterpret_cast<uintptr_t>(buf) % sizeof(t)), "alignment error of buf");
- *reinterpret_cast<uint32_t *>(buf) = t;
+ *reinterpret_cast_ptr<uint32_t *>(buf) = t;
buf += 4;
} while (--longs);
}
@@ -238,7 +239,7 @@ void MD5::addBytes(const uint8_t* input, size_t length)
}
memcpy(p, buf, t);
reverseBytes(m_in, 16);
- MD5Transform(m_buf, reinterpret_cast<uint32_t*>(m_in)); // m_in is 4-byte aligned.
+ MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); // m_in is 4-byte aligned.
buf += t;
length -= t;
}
@@ -248,7 +249,7 @@ void MD5::addBytes(const uint8_t* input, size_t length)
while (length >= 64) {
memcpy(m_in, buf, 64);
reverseBytes(m_in, 16);
- MD5Transform(m_buf, reinterpret_cast<uint32_t*>(m_in)); // m_in is 4-byte aligned.
+ MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); // m_in is 4-byte aligned.
buf += 64;
length -= 64;
}
@@ -275,7 +276,7 @@ void MD5::checksum(Vector<uint8_t, 16>& digest)
// Two lots of padding: Pad the first block to 64 bytes
memset(p, 0, count);
reverseBytes(m_in, 16);
- MD5Transform(m_buf, reinterpret_cast<uint32_t *>(m_in)); // m_in is 4-byte aligned.
+ MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t *>(m_in)); // m_in is 4-byte aligned.
// Now fill the next block with 56 bytes
memset(m_in, 0, 56);
@@ -287,10 +288,10 @@ void MD5::checksum(Vector<uint8_t, 16>& digest)
// Append length in bits and transform
// m_in is 4-byte aligned.
- (reinterpret_cast<uint32_t*>(m_in))[14] = m_bits[0];
- (reinterpret_cast<uint32_t*>(m_in))[15] = m_bits[1];
+ (reinterpret_cast_ptr<uint32_t*>(m_in))[14] = m_bits[0];
+ (reinterpret_cast_ptr<uint32_t*>(m_in))[15] = m_bits[1];
- MD5Transform(m_buf, reinterpret_cast<uint32_t*>(m_in));
+ MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in));
reverseBytes(reinterpret_cast<uint8_t*>(m_buf), 4);
// Now, m_buf contains checksum result.
diff --git a/JavaScriptCore/wtf/StdLibExtras.h b/JavaScriptCore/wtf/StdLibExtras.h
index 96a929c..d594c17 100644
--- a/JavaScriptCore/wtf/StdLibExtras.h
+++ b/JavaScriptCore/wtf/StdLibExtras.h
@@ -51,6 +51,40 @@
#define STRINGIZE(exp) #exp
#define STRINGIZE_VALUE_OF(exp) STRINGIZE(exp)
+/*
+ * The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
+ * sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM with GCC:
+ * increases required alignment of target type.
+ *
+ * An implicit or an extra static_cast<void*> bypasses the warning.
+ * For more info see the following bugzilla entries:
+ * - https://bugs.webkit.org/show_bug.cgi?id=38045
+ * - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976
+ */
+#if CPU(ARM) && COMPILER(GCC)
+template<typename Type>
+bool isPointerTypeAlignmentOkay(Type* ptr)
+{
+ return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type));
+}
+
+template<typename TypePtr>
+TypePtr reinterpret_cast_ptr(void* ptr)
+{
+ ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
+ return reinterpret_cast<TypePtr>(ptr);
+}
+
+template<typename TypePtr>
+TypePtr reinterpret_cast_ptr(const void* ptr)
+{
+ ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
+ return reinterpret_cast<TypePtr>(ptr);
+}
+#else
+#define reinterpret_cast_ptr reinterpret_cast
+#endif
+
namespace WTF {
/*
diff --git a/JavaScriptCore/wtf/Vector.h b/JavaScriptCore/wtf/Vector.h
index c60de15..f73793f 100644
--- a/JavaScriptCore/wtf/Vector.h
+++ b/JavaScriptCore/wtf/Vector.h
@@ -24,6 +24,7 @@
#include "FastAllocBase.h"
#include "Noncopyable.h"
#include "NotFound.h"
+#include "StdLibExtras.h"
#include "ValueCheck.h"
#include "VectorTraits.h"
#include <limits>
@@ -481,7 +482,7 @@ namespace WTF {
using Base::m_capacity;
static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T);
- T* inlineBuffer() { return reinterpret_cast<T*>(m_inlineBuffer.buffer); }
+ T* inlineBuffer() { return reinterpret_cast_ptr<T*>(m_inlineBuffer.buffer); }
AlignedBuffer<m_inlineBufferSize, WTF_ALIGN_OF(T)> m_inlineBuffer;
};
diff --git a/JavaScriptCore/wtf/qt/StringQt.cpp b/JavaScriptCore/wtf/qt/StringQt.cpp
index c02505a..16dd439 100644
--- a/JavaScriptCore/wtf/qt/StringQt.cpp
+++ b/JavaScriptCore/wtf/qt/StringQt.cpp
@@ -25,6 +25,7 @@
#include "config.h"
+#include <wtf/StdLibExtras.h>
#include <wtf/text/WTFString.h>
#include <QString>
@@ -36,14 +37,14 @@ String::String(const QString& qstr)
{
if (qstr.isNull())
return;
- m_impl = StringImpl::create(reinterpret_cast<const UChar*>(qstr.constData()), qstr.length());
+ m_impl = StringImpl::create(reinterpret_cast_ptr<const UChar*>(qstr.constData()), qstr.length());
}
String::String(const QStringRef& ref)
{
if (!ref.string())
return;
- m_impl = StringImpl::create(reinterpret_cast<const UChar*>(ref.unicode()), ref.length());
+ m_impl = StringImpl::create(reinterpret_cast_ptr<const UChar*>(ref.unicode()), ref.length());
}
String::operator QString() const
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list