Changeset 64302 in webkit
- Timestamp:
- Jul 29, 2010 12:52:22 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r64281 r64302 1 2010-07-29 Gabor Loki <loki@webkit.org> 2 3 Reviewed by Gavin Barraclough. 4 5 Avoid increasing required alignment of target type warning on ARM 6 https://bugs.webkit.org/show_bug.cgi?id=38045 7 8 The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where 9 sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM: 10 increases required alignment of target type warnings. 11 Casting the type of [pointer to Type2] object to void* bypasses the 12 warning. 13 14 * assembler/ARMAssembler.cpp: 15 (JSC::ARMAssembler::executableCopy): 16 * assembler/AssemblerBuffer.h: 17 (JSC::AssemblerBuffer::putShortUnchecked): 18 (JSC::AssemblerBuffer::putIntUnchecked): 19 (JSC::AssemblerBuffer::putInt64Unchecked): 20 * jit/JITStubs.cpp: 21 * pcre/pcre_compile.cpp: 22 (jsRegExpCompile): 23 * wtf/FastMalloc.cpp: 24 (WTF::PageHeapAllocator::New): 25 (WTF::TCMalloc_Central_FreeList::Populate): 26 * wtf/MD5.cpp: 27 (WTF::reverseBytes): 28 (WTF::MD5::addBytes): 29 (WTF::MD5::checksum): 30 * wtf/StdLibExtras.h: 31 (reinterpret_cast_ptr): 32 * wtf/Vector.h: 33 (WTF::VectorBuffer::inlineBuffer): 34 * wtf/qt/StringQt.cpp: 35 (WebCore::String::String): 36 1 37 2010-07-29 Martin Robinson <mrobinson@igalia.com> 2 38 -
trunk/JavaScriptCore/assembler/ARMAssembler.cpp
r63228 r64302 356 356 // The last bit is set if the constant must be placed on constant pool. 357 357 int pos = (*iter) & (~0x1); 358 ARMWord* ldrAddr = reinterpret_cast <ARMWord*>(data + pos);358 ARMWord* ldrAddr = reinterpret_cast_ptr<ARMWord*>(data + pos); 359 359 ARMWord* addr = getLdrImmAddress(ldrAddr); 360 360 if (*addr != InvalidBranchTarget) { 361 361 if (!(*iter & 1)) { 362 int diff = reinterpret_cast <ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetching);362 int diff = reinterpret_cast_ptr<ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetching); 363 363 364 364 if ((diff <= BOFFSET_MAX && diff >= BOFFSET_MIN)) { -
trunk/JavaScriptCore/assembler/AssemblerBuffer.h
r61851 r64302 34 34 #include <wtf/Assertions.h> 35 35 #include <wtf/FastMalloc.h> 36 #include <wtf/StdLibExtras.h> 36 37 37 38 namespace JSC { … … 82 83 { 83 84 ASSERT(!(m_size > m_capacity - 4)); 84 *reinterpret_cast <short*>(&m_buffer[m_size]) = value;85 *reinterpret_cast_ptr<short*>(&m_buffer[m_size]) = value; 85 86 m_size += 2; 86 87 } … … 96 97 { 97 98 ASSERT(!(m_size > m_capacity - 4)); 98 *reinterpret_cast <int*>(&m_buffer[m_size]) = value;99 *reinterpret_cast_ptr<int*>(&m_buffer[m_size]) = value; 99 100 m_size += 4; 100 101 } … … 103 104 { 104 105 ASSERT(!(m_size > m_capacity - 8)); 105 *reinterpret_cast <int64_t*>(&m_buffer[m_size]) = value;106 *reinterpret_cast_ptr<int64_t*>(&m_buffer[m_size]) = value; 106 107 m_size += 8; 107 108 } -
trunk/JavaScriptCore/jit/JITStubs.cpp
r63954 r64302 987 987 }; 988 988 989 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast <JITStackFrame*>(STUB_ARGS); StackHack stackHack(stackFrame)989 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast_ptr<JITStackFrame*>(STUB_ARGS); StackHack stackHack(stackFrame) 990 990 #define STUB_SET_RETURN_ADDRESS(returnAddress) stackHack.savedReturnAddress = ReturnAddressPtr(returnAddress) 991 991 #define STUB_RETURN_ADDRESS stackHack.savedReturnAddress … … 993 993 #else 994 994 995 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast <JITStackFrame*>(STUB_ARGS)995 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast_ptr<JITStackFrame*>(STUB_ARGS) 996 996 #define STUB_SET_RETURN_ADDRESS(returnAddress) *stackFrame.returnAddressSlot() = ReturnAddressPtr(returnAddress) 997 997 #define STUB_RETURN_ADDRESS *stackFrame.returnAddressSlot() -
trunk/JavaScriptCore/pcre/pcre_compile.cpp
r62367 r64302 50 50 #include <wtf/FastMalloc.h> 51 51 #include <wtf/FixedArray.h> 52 #include <wtf/StdLibExtras.h> 52 53 53 54 using namespace WTF; … … 2591 2592 size = stringOffset + patternLength * sizeof(UChar); 2592 2593 #endif 2593 JSRegExp* re = reinterpret_cast <JSRegExp*>(new char[size]);2594 JSRegExp* re = reinterpret_cast_ptr<JSRegExp*>(new char[size]); 2594 2595 2595 2596 if (!re) -
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r62768 r64302 83 83 #include <pthread.h> 84 84 #endif 85 #include <wtf/StdLibExtras.h> 85 86 86 87 #ifndef NO_TCMALLOC_SAMPLES … … 1016 1017 CRASH(); 1017 1018 1018 * (void**)new_allocation= allocated_regions_;1019 *reinterpret_cast_ptr<void**>(new_allocation) = allocated_regions_; 1019 1020 allocated_regions_ = new_allocation; 1020 1021 free_area_ = new_allocation + kAlignedSize; … … 2711 2712 while ((nptr = ptr + size) <= limit) { 2712 2713 *tail = ptr; 2713 tail = reinterpret_cast <void**>(ptr);2714 tail = reinterpret_cast_ptr<void**>(ptr); 2714 2715 ptr = nptr; 2715 2716 num++; -
trunk/JavaScriptCore/wtf/MD5.cpp
r59067 r64302 55 55 #include "text/CString.h" 56 56 #endif 57 #include <wtf/StdLibExtras.h> 57 58 58 59 namespace WTF { … … 104 105 uint32_t t = static_cast<uint32_t>(buf[3] << 8 | buf[2]) << 16 | buf[1] << 8 | buf[0]; 105 106 ASSERT_WITH_MESSAGE(!(reinterpret_cast<uintptr_t>(buf) % sizeof(t)), "alignment error of buf"); 106 *reinterpret_cast <uint32_t *>(buf) = t;107 *reinterpret_cast_ptr<uint32_t *>(buf) = t; 107 108 buf += 4; 108 109 } while (--longs); … … 239 240 memcpy(p, buf, t); 240 241 reverseBytes(m_in, 16); 241 MD5Transform(m_buf, reinterpret_cast <uint32_t*>(m_in)); // m_in is 4-byte aligned.242 MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); // m_in is 4-byte aligned. 242 243 buf += t; 243 244 length -= t; … … 249 250 memcpy(m_in, buf, 64); 250 251 reverseBytes(m_in, 16); 251 MD5Transform(m_buf, reinterpret_cast <uint32_t*>(m_in)); // m_in is 4-byte aligned.252 MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); // m_in is 4-byte aligned. 252 253 buf += 64; 253 254 length -= 64; … … 276 277 memset(p, 0, count); 277 278 reverseBytes(m_in, 16); 278 MD5Transform(m_buf, reinterpret_cast <uint32_t *>(m_in)); // m_in is 4-byte aligned.279 MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t *>(m_in)); // m_in is 4-byte aligned. 279 280 280 281 // Now fill the next block with 56 bytes … … 288 289 // Append length in bits and transform 289 290 // m_in is 4-byte aligned. 290 (reinterpret_cast <uint32_t*>(m_in))[14] = m_bits[0];291 (reinterpret_cast <uint32_t*>(m_in))[15] = m_bits[1];292 293 MD5Transform(m_buf, reinterpret_cast <uint32_t*>(m_in));291 (reinterpret_cast_ptr<uint32_t*>(m_in))[14] = m_bits[0]; 292 (reinterpret_cast_ptr<uint32_t*>(m_in))[15] = m_bits[1]; 293 294 MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); 294 295 reverseBytes(reinterpret_cast<uint8_t*>(m_buf), 4); 295 296 -
trunk/JavaScriptCore/wtf/StdLibExtras.h
r56085 r64302 52 52 #define STRINGIZE_VALUE_OF(exp) STRINGIZE(exp) 53 53 54 /* 55 * The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where 56 * sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM with GCC: 57 * increases required alignment of target type. 58 * 59 * An implicit or an extra static_cast<void*> bypasses the warning. 60 * For more info see the following bugzilla entries: 61 * - https://bugs.webkit.org/show_bug.cgi?id=38045 62 * - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976 63 */ 64 #if CPU(ARM) && COMPILER(GCC) 65 template<typename T> 66 T reinterpret_cast_ptr(void* ptr) 67 { 68 ASSERT(!(reinterpret_cast<unsigned int>(ptr) % __alignof__(T))); 69 return reinterpret_cast<T>(ptr); 70 } 71 template<typename T> 72 T reinterpret_cast_ptr(const void* ptr) 73 { 74 ASSERT(!(reinterpret_cast<unsigned int>(ptr) % __alignof__(T))); 75 return reinterpret_cast<T>(ptr); 76 } 77 #else 78 #define reinterpret_cast_ptr reinterpret_cast 79 #endif 80 54 81 namespace WTF { 55 82 -
trunk/JavaScriptCore/wtf/Vector.h
r62697 r64302 25 25 #include "Noncopyable.h" 26 26 #include "NotFound.h" 27 #include "StdLibExtras.h" 27 28 #include "ValueCheck.h" 28 29 #include "VectorTraits.h" … … 482 483 483 484 static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T); 484 T* inlineBuffer() { return reinterpret_cast <T*>(m_inlineBuffer.buffer); }485 T* inlineBuffer() { return reinterpret_cast_ptr<T*>(m_inlineBuffer.buffer); } 485 486 486 487 AlignedBuffer<m_inlineBufferSize, WTF_ALIGN_OF(T)> m_inlineBuffer; -
trunk/JavaScriptCore/wtf/qt/StringQt.cpp
r58006 r64302 26 26 #include "config.h" 27 27 28 #include <wtf/StdLibExtras.h> 28 29 #include <wtf/text/WTFString.h> 29 30 … … 37 38 if (qstr.isNull()) 38 39 return; 39 m_impl = StringImpl::create(reinterpret_cast <const UChar*>(qstr.constData()), qstr.length());40 m_impl = StringImpl::create(reinterpret_cast_ptr<const UChar*>(qstr.constData()), qstr.length()); 40 41 } 41 42 … … 44 45 if (!ref.string()) 45 46 return; 46 m_impl = StringImpl::create(reinterpret_cast <const UChar*>(ref.unicode()), ref.length());47 m_impl = StringImpl::create(reinterpret_cast_ptr<const UChar*>(ref.unicode()), ref.length()); 47 48 } 48 49
Note: See TracChangeset
for help on using the changeset viewer.