Changeset 152362 in webkit


Ignore:
Timestamp:
Jul 3, 2013 10:05:30 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r152356.
http://trac.webkit.org/changeset/152356
https://bugs.webkit.org/show_bug.cgi?id=118361

Broke JSCore tests (Requested by andersca on #webkit).

  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::createUninitialized):
(WTF::StringImpl::reallocate):
(WTF::StringImpl::create):

  • wtf/text/StringImpl.h:
Location:
trunk/Source/WTF
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r152356 r152362  
     12013-07-03  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r152356.
     4        http://trac.webkit.org/changeset/152356
     5        https://bugs.webkit.org/show_bug.cgi?id=118361
     6
     7        Broke JSCore tests (Requested by andersca on #webkit).
     8
     9        * wtf/text/StringImpl.cpp:
     10        (WTF::StringImpl::createUninitialized):
     11        (WTF::StringImpl::reallocate):
     12        (WTF::StringImpl::create):
     13        * wtf/text/StringImpl.h:
     14
    1152013-07-03  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    216
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r152356 r152362  
    183183}
    184184
    185 template <typename CharType>
    186 inline PassRefPtr<StringImpl> StringImpl::constructInternal(StringImpl* stringImpl, unsigned length)
    187 {
    188     return adoptRef(new (NotNull, stringImpl) StringImpl(length));
    189 }
    190 
    191 template <>
    192 inline PassRefPtr<StringImpl> StringImpl::constructInternal<LChar>(StringImpl* stringImpl, unsigned length)
    193 {
    194     return adoptRef(new (NotNull, stringImpl) StringImpl(length, Force8BitConstructor));
    195 }
    196 
    197 template <typename CharType>
    198 inline PassRefPtr<StringImpl> StringImpl::createUninitializedInternal(unsigned length, CharType*& data)
     185PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data)
    199186{
    200187    if (!length) {
     
    206193    // struct as well as the data which it contains. This removes one
    207194    // heap allocation from this call.
    208     if (length > ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(CharType)))
     195    if (length > ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(LChar)))
    209196        CRASH();
    210     size_t size = sizeof(StringImpl) + length * sizeof(CharType);
     197    size_t size = sizeof(StringImpl) + length * sizeof(LChar);
    211198    StringImpl* string = static_cast<StringImpl*>(fastMalloc(size));
    212199
    213     data = reinterpret_cast<CharType*>(string + 1);
    214     return constructInternal<CharType>(string, length);
    215 }
    216 
    217 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data)
    218 {
    219     return createUninitializedInternal(length, data);
     200    data = reinterpret_cast<LChar*>(string + 1);
     201    return adoptRef(new (NotNull, string) StringImpl(length, Force8BitConstructor));
    220202}
    221203
    222204PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, UChar*& data)
    223205{
    224     return createUninitializedInternal(length, data);
    225 }
    226 
    227 template <typename CharType>
    228 inline PassRefPtr<StringImpl> StringImpl::reallocateInternal(PassRefPtr<StringImpl> originalString, unsigned length, CharType*& data)
     206    if (!length) {
     207        data = 0;
     208        return empty();
     209    }
     210
     211    // Allocate a single buffer large enough to contain the StringImpl
     212    // struct as well as the data which it contains. This removes one
     213    // heap allocation from this call.
     214    if (length > ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(UChar)))
     215        CRASH();
     216    size_t size = sizeof(StringImpl) + length * sizeof(UChar);
     217    StringImpl* string = static_cast<StringImpl*>(fastMalloc(size));
     218
     219    data = reinterpret_cast<UChar*>(string + 1);
     220    return adoptRef(new (NotNull, string) StringImpl(length));
     221}
     222
     223PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalString, unsigned length, LChar*& data)
    229224{
    230225    ASSERT(originalString->is8Bit());
     
    238233
    239234    // Same as createUninitialized() except here we use fastRealloc.
    240     if (length > ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(CharType)))
     235    if (length > ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(LChar)))
    241236        CRASH();
    242     size_t size = sizeof(StringImpl) + length * sizeof(CharType);
     237    size_t size = sizeof(StringImpl) + length * sizeof(LChar);
    243238    originalString->~StringImpl();
    244239    StringImpl* string = static_cast<StringImpl*>(fastRealloc(originalString.leakRef(), size));
    245240
    246     data = reinterpret_cast<CharType*>(string + 1);
    247     return constructInternal<CharType>(string, length);
    248 }
    249 
    250 PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalString, unsigned length, LChar*& data)
    251 {
    252     return reallocateInternal(originalString, length, data);
     241    data = reinterpret_cast<LChar*>(string + 1);
     242    return adoptRef(new (NotNull, string) StringImpl(length, Force8BitConstructor));
    253243}
    254244
    255245PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalString, unsigned length, UChar*& data)
    256246{
    257     return reallocateInternal(originalString, length, data);
    258 }
    259 
    260 template <typename CharType>
    261 inline PassRefPtr<StringImpl> StringImpl::createInternal(const CharType* characters, unsigned length)
     247    ASSERT(!originalString->is8Bit());
     248    ASSERT(originalString->hasOneRef());
     249    ASSERT(originalString->bufferOwnership() == BufferInternal);
     250
     251    if (!length) {
     252        data = 0;
     253        return empty();
     254    }
     255
     256    // Same as createUninitialized() except here we use fastRealloc.
     257    if (length > ((std::numeric_limits<unsigned>::max() - sizeof(StringImpl)) / sizeof(UChar)))
     258        CRASH();
     259    size_t size = sizeof(StringImpl) + length * sizeof(UChar);
     260    originalString->~StringImpl();
     261    StringImpl* string = static_cast<StringImpl*>(fastRealloc(originalString.leakRef(), size));
     262
     263    data = reinterpret_cast<UChar*>(string + 1);
     264    return adoptRef(new (NotNull, string) StringImpl(length));
     265}
     266
     267PassRefPtr<StringImpl> StringImpl::create(const UChar* characters, unsigned length)
    262268{
    263269    if (!characters || !length)
    264270        return empty();
    265271
    266     CharType* data;
     272    UChar* data;
    267273    RefPtr<StringImpl> string = createUninitialized(length, data);
    268     memcpy(data, characters, length * sizeof(CharType));
     274    memcpy(data, characters, length * sizeof(UChar));
    269275    return string.release();
    270276}
    271277
    272 PassRefPtr<StringImpl> StringImpl::create(const UChar* characters, unsigned length)
    273 {
    274     return createInternal(characters, length);
    275 }
    276 
    277278PassRefPtr<StringImpl> StringImpl::create(const LChar* characters, unsigned length)
    278279{
    279     return createInternal(characters, length);
     280    if (!characters || !length)
     281        return empty();
     282
     283    LChar* data;
     284    RefPtr<StringImpl> string = createUninitialized(length, data);
     285    memcpy(data, characters, length * sizeof(LChar));
     286    return string.release();
    280287}
    281288
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r152356 r152362  
    771771    template <class UCharPredicate> PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate);
    772772    template <typename CharType, class UCharPredicate> PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate);
    773     template <typename CharType> static PassRefPtr<StringImpl> constructInternal(StringImpl*, unsigned);
    774     template <typename CharType> static PassRefPtr<StringImpl> createUninitializedInternal(unsigned, CharType*&);
    775     template <typename CharType> static PassRefPtr<StringImpl> reallocateInternal(PassRefPtr<StringImpl>, unsigned, CharType*&);
    776     template <typename CharType> static PassRefPtr<StringImpl> createInternal(const CharType*, unsigned);
    777773    WTF_EXPORT_STRING_API NEVER_INLINE const UChar* getData16SlowCase() const;
    778774    WTF_EXPORT_PRIVATE NEVER_INLINE unsigned hashSlowCase() const;
Note: See TracChangeset for help on using the changeset viewer.