[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

ossy at webkit.org ossy at webkit.org
Wed Dec 22 11:34:48 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d1270bc87f2c62c9bf8a6c58877188c3d28dc1cd
Author: ossy at webkit.org <ossy at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jul 29 19:52:22 2010 +0000

    2010-07-29  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):
            * jit/JITStubs.cpp:
            * pcre/pcre_compile.cpp:
            (jsRegExpCompile):
            * 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:
            (reinterpret_cast_ptr):
            * wtf/Vector.h:
            (WTF::VectorBuffer::inlineBuffer):
            * wtf/qt/StringQt.cpp:
            (WebCore::String::String):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64302 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 4ca763c..a0be677 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,39 @@
+2010-07-29  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):
+        * jit/JITStubs.cpp:
+        * pcre/pcre_compile.cpp:
+        (jsRegExpCompile):
+        * 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:
+        (reinterpret_cast_ptr):
+        * wtf/Vector.h:
+        (WTF::VectorBuffer::inlineBuffer):
+        * wtf/qt/StringQt.cpp:
+        (WebCore::String::String):
+
 2010-07-29  Martin Robinson  <mrobinson at igalia.com>
 
         Unreviewed build fix.
diff --git a/JavaScriptCore/assembler/ARMAssembler.cpp b/JavaScriptCore/assembler/ARMAssembler.cpp
index 0016540..86a1c14 100644
--- a/JavaScriptCore/assembler/ARMAssembler.cpp
+++ b/JavaScriptCore/assembler/ARMAssembler.cpp
@@ -355,11 +355,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/jit/JITStubs.cpp b/JavaScriptCore/jit/JITStubs.cpp
index f088b6e..150a4af 100644
--- a/JavaScriptCore/jit/JITStubs.cpp
+++ b/JavaScriptCore/jit/JITStubs.cpp
@@ -986,13 +986,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/wtf/FastMalloc.cpp b/JavaScriptCore/wtf/FastMalloc.cpp
index 9dfbc6b..ae7df9e 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
@@ -1015,7 +1016,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;
@@ -2710,7 +2711,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..6c7ea94 100644
--- a/JavaScriptCore/wtf/StdLibExtras.h
+++ b/JavaScriptCore/wtf/StdLibExtras.h
@@ -51,6 +51,33 @@
 #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 T>
+T reinterpret_cast_ptr(void* ptr)
+{
+    ASSERT(!(reinterpret_cast<unsigned int>(ptr) % __alignof__(T)));
+    return reinterpret_cast<T>(ptr);
+}
+template<typename T>
+T reinterpret_cast_ptr(const void* ptr)
+{
+    ASSERT(!(reinterpret_cast<unsigned int>(ptr) % __alignof__(T)));
+    return reinterpret_cast<T>(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 b2c621a..171d532 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