Changeset 65311 in webkit for trunk/JavaScriptCore
- Timestamp:
- Aug 13, 2010, 3:14:36 AM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r65305 r65311 1 2010-08-13 Gabor Loki <[email protected]> 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 * interpreter/RegisterFile.h: 21 (JSC::RegisterFile::RegisterFile): 22 (JSC::RegisterFile::grow): 23 * jit/JITStubs.cpp: 24 * pcre/pcre_compile.cpp: 25 (jsRegExpCompile): 26 * runtime/JSArray.cpp: 27 (JSC::JSArray::putSlowCase): 28 (JSC::JSArray::increaseVectorLength): 29 (JSC::JSArray::increaseVectorPrefixLength): 30 (JSC::JSArray::shiftCount): 31 (JSC::JSArray::unshiftCount): 32 * wtf/FastMalloc.cpp: 33 (WTF::PageHeapAllocator::New): 34 (WTF::TCMalloc_Central_FreeList::Populate): 35 * wtf/MD5.cpp: 36 (WTF::reverseBytes): 37 (WTF::MD5::addBytes): 38 (WTF::MD5::checksum): 39 * wtf/StdLibExtras.h: 40 (isPointerTypeAlignmentOkay): 41 (reinterpret_cast_ptr): 42 * wtf/Vector.h: 43 (WTF::VectorBuffer::inlineBuffer): 44 * wtf/qt/StringQt.cpp: 45 (WTF::String::String): 46 1 47 2010-08-13 Gavin Barraclough <[email protected]> 2 48 -
trunk/JavaScriptCore/assembler/ARMAssembler.cpp
r64608 r65311 358 358 // The last bit is set if the constant must be placed on constant pool. 359 359 int pos = (*iter) & (~0x1); 360 ARMWord* ldrAddr = reinterpret_cast <ARMWord*>(data + pos);360 ARMWord* ldrAddr = reinterpret_cast_ptr<ARMWord*>(data + pos); 361 361 ARMWord* addr = getLdrImmAddress(ldrAddr); 362 362 if (*addr != InvalidBranchTarget) { 363 363 if (!(*iter & 1)) { 364 int diff = reinterpret_cast <ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetching);364 int diff = reinterpret_cast_ptr<ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetching); 365 365 366 366 if ((diff <= BOFFSET_MAX && diff >= BOFFSET_MIN)) { -
trunk/JavaScriptCore/assembler/AssemblerBuffer.h
r64327 r65311 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/interpreter/RegisterFile.h
r64782 r65311 167 167 size_t committedSize = roundUpAllocationSize(maxGlobals * sizeof(Register), commitSize); 168 168 checkAllocatedOkay(m_reservation.commit(base, committedSize)); 169 m_commitEnd = reinterpret_cast <Register*>(reinterpret_cast<char*>(base) + committedSize);169 m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(base) + committedSize); 170 170 m_start = static_cast<Register*>(base) + maxGlobals; 171 171 m_end = m_start; … … 194 194 size_t size = roundUpAllocationSize(reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_commitEnd), commitSize); 195 195 checkAllocatedOkay(m_reservation.commit(m_commitEnd, size)); 196 m_commitEnd = reinterpret_cast <Register*>(reinterpret_cast<char*>(m_commitEnd) + size);196 m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitEnd) + size); 197 197 } 198 198 -
trunk/JavaScriptCore/jit/JITStubs.cpp
r65104 r65311 968 968 }; 969 969 970 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast <JITStackFrame*>(STUB_ARGS); StackHack stackHack(stackFrame)970 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast_ptr<JITStackFrame*>(STUB_ARGS); StackHack stackHack(stackFrame) 971 971 #define STUB_SET_RETURN_ADDRESS(returnAddress) stackHack.savedReturnAddress = ReturnAddressPtr(returnAddress) 972 972 #define STUB_RETURN_ADDRESS stackHack.savedReturnAddress … … 974 974 #else 975 975 976 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast <JITStackFrame*>(STUB_ARGS)976 #define STUB_INIT_STACK_FRAME(stackFrame) JITStackFrame& stackFrame = *reinterpret_cast_ptr<JITStackFrame*>(STUB_ARGS) 977 977 #define STUB_SET_RETURN_ADDRESS(returnAddress) *stackFrame.returnAddressSlot() = ReturnAddressPtr(returnAddress) 978 978 #define STUB_RETURN_ADDRESS *stackFrame.returnAddressSlot() -
trunk/JavaScriptCore/pcre/pcre_compile.cpp
r64327 r65311 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/runtime/JSArray.cpp
r65305 r65311 442 442 } 443 443 444 m_storage = reinterpret_cast <ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));444 m_storage = reinterpret_cast_ptr<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue)); 445 445 m_storage->m_allocBase = baseStorage; 446 446 storage = m_storage; … … 592 592 return false; 593 593 594 storage = m_storage = reinterpret_cast <ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue));594 storage = m_storage = reinterpret_cast_ptr<ArrayStorage*>(static_cast<char*>(baseStorage) + m_indexBias * sizeof(JSValue)); 595 595 m_storage->m_allocBase = baseStorage; 596 596 … … 624 624 m_indexBias += newVectorLength - newLength; 625 625 626 m_storage = reinterpret_cast <ArrayStorage*>(static_cast<char*>(newBaseStorage) + m_indexBias * sizeof(JSValue));626 m_storage = reinterpret_cast_ptr<ArrayStorage*>(static_cast<char*>(newBaseStorage) + m_indexBias * sizeof(JSValue)); 627 627 628 628 memcpy(m_storage, storage, storageSize(0)); … … 803 803 char* newBaseStorage = reinterpret_cast<char*>(storage) + count * sizeof(JSValue); 804 804 memmove(newBaseStorage, storage, storageSize(0)); 805 m_storage = reinterpret_cast <ArrayStorage*>(newBaseStorage);805 m_storage = reinterpret_cast_ptr<ArrayStorage*>(newBaseStorage); 806 806 807 807 m_indexBias += count; … … 840 840 char* newBaseStorage = reinterpret_cast<char*>(storage) - count * sizeof(JSValue); 841 841 memmove(newBaseStorage, storage, storageSize(0)); 842 m_storage = reinterpret_cast <ArrayStorage*>(newBaseStorage);842 m_storage = reinterpret_cast_ptr<ArrayStorage*>(newBaseStorage); 843 843 m_vectorLength += count; 844 844 } else if (!increaseVectorPrefixLength(m_vectorLength + count)) { -
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r65091 r65311 83 83 #include <pthread.h> 84 84 #endif 85 #include <wtf/StdLibExtras.h> 85 86 86 87 #ifndef NO_TCMALLOC_SAMPLES … … 1018 1019 CRASH(); 1019 1020 1020 * (void**)new_allocation= allocated_regions_;1021 *reinterpret_cast_ptr<void**>(new_allocation) = allocated_regions_; 1021 1022 allocated_regions_ = new_allocation; 1022 1023 free_area_ = new_allocation + kAlignedSize; … … 2719 2720 while ((nptr = ptr + size) <= limit) { 2720 2721 *tail = ptr; 2721 tail = reinterpret_cast <void**>(ptr);2722 tail = reinterpret_cast_ptr<void**>(ptr); 2722 2723 ptr = nptr; 2723 2724 num++; -
trunk/JavaScriptCore/wtf/MD5.cpp
r64327 r65311 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
r64327 r65311 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 Type> 66 bool isPointerTypeAlignmentOkay(Type* ptr) 67 { 68 return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type)); 69 } 70 71 template<typename TypePtr> 72 TypePtr reinterpret_cast_ptr(void* ptr) 73 { 74 ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr))); 75 return reinterpret_cast<TypePtr>(ptr); 76 } 77 78 template<typename TypePtr> 79 TypePtr reinterpret_cast_ptr(const void* ptr) 80 { 81 ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr))); 82 return reinterpret_cast<TypePtr>(ptr); 83 } 84 #else 85 #define reinterpret_cast_ptr reinterpret_cast 86 #endif 87 54 88 namespace WTF { 55 89 -
trunk/JavaScriptCore/wtf/Vector.h
r64327 r65311 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
r65022 r65311 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.