Changeset 52500 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Dec 22, 2009, 2:05:17 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/SmallStrings.cpp
r52463 r52500 42 42 43 43 private: 44 UChar m_characters[numCharactersToStore];45 UString::Rep m_base;46 44 UString::Rep m_reps[numCharactersToStore]; 47 45 }; 48 46 49 47 SmallStringsStorage::SmallStringsStorage() 50 : m_base(m_characters, numCharactersToStore, UStringImpl::ConstructStaticString)51 48 { 52 m_base.checkConsistency(); 53 54 for (unsigned i = 0; i < numCharactersToStore; ++i) 55 m_characters[i] = i; 56 57 memset(&m_reps, 0, sizeof(m_reps)); 58 for (unsigned i = 0; i < numCharactersToStore; ++i) 59 new (&m_reps[i]) UString::Rep(m_base.data() + i, 1, &m_base); 49 UChar* characterBuffer = 0; 50 RefPtr<UStringImpl> baseString = UStringImpl::createUninitialized(numCharactersToStore, characterBuffer); 51 for (unsigned i = 0; i < numCharactersToStore; ++i) { 52 characterBuffer[i] = i; 53 new (&m_reps[i]) UString::Rep(&characterBuffer[i], 1, PassRefPtr<UStringImpl>(baseString)); 54 } 60 55 } 61 56 -
trunk/JavaScriptCore/runtime/UStringImpl.h
r52470 r52500 45 45 UntypedPtrAndBitfield(void* ptrValue, uintptr_t bitValue) 46 46 : m_value(reinterpret_cast<uintptr_t>(ptrValue) | bitValue) 47 #ifndef NDEBUG 48 , m_leaksPtr(ptrValue) 49 #endif 47 50 { 48 51 ASSERT(ptrValue == asPtr<void*>()); … … 73 76 static const uintptr_t s_alignmentMask = ~static_cast<uintptr_t>(0x7); 74 77 uintptr_t m_value; 78 #ifndef NDEBUG 79 void* m_leaksPtr; // Only used to allow tools like leaks on OSX to detect that the memory is referenced. 80 #endif 75 81 }; 76 82 … … 217 223 , m_dataBuffer(base.releaseRef(), BufferSubstring) 218 224 { 225 // Do use static strings as a base for substrings; UntypedPtrAndBitfield assumes 226 // that all pointers will be at least 8-byte aligned, we cannot guarantee that of 227 // UStringImpls that are not heap allocated. 228 ASSERT(m_dataBuffer.asPtr<UStringImpl*>()->size()); 229 ASSERT(!m_dataBuffer.asPtr<UStringImpl*>()->isStatic()); 219 230 checkConsistency(); 220 231 }
Note:
See TracChangeset
for help on using the changeset viewer.