Ignore:
Timestamp:
Jun 1, 2009, 11:41:20 AM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-06-01 David Levin <[email protected]>

Reviewed by Darin Alder and Maciej Stachowiak.

Bug 26057: StringImpl should share buffers with UString.
https://bugs.webkit.org/show_bug.cgi?id=26057

  • JavaScriptCore.exp:
  • runtime/UString.cpp: (JSC::UString::Rep::create): (JSC::UString::BaseString::sharedBuffer): Only do the sharing when the buffer exceeds a certain size. The size was tuned by running various dom benchmarks with numbers ranging from 20 to 800 and finding a place that seemed to do the best overall.
  • runtime/UString.h:

WebCore:

2009-06-01 David Levin <[email protected]>

Reviewed by Darin Alder and Maciej Stachowiak.

Bug 26057: StringImpl should share buffers with UString.
https://bugs.webkit.org/show_bug.cgi?id=26057

This change results in the following performance improvements:
On http://www.hixie.ch/tests/adhoc/perf/dom/artificial/core/001.html
the time went from 78ms to 40ms for append (other times remained constant).

On http://www.hixie.ch/tests/adhoc/perf/dom/artificial/core/002.html,
the time went from 3900ms to 2600ms.

For http://dromaeo.com/?dom, the time for DomModification improved by ~6%.
Other tests in dom seemed to be faster across several runs but within the
margin of error (except DOM Attributes which was slightly ~1.5% worse).

Existing tests cover this code and there is no new functionality
that is exposed to test.

  • platform/text/AtomicString.cpp: (WebCore::AtomicString::add):
  • platform/text/String.cpp: (WebCore::String::String): (WebCore::String::operator UString):
  • platform/text/StringImpl.cpp: (WebCore::StringImpl::StringImpl): (WebCore::StringImpl::~StringImpl): (WebCore::StringImpl::create): Consumes a shared buffer. (WebCore::StringImpl::ustring): Shares the StringImpl's buffer with the UString. (WebCore::StringImpl::sharedBuffer): Exposes the buffer that may be shared.
  • platform/text/StringImpl.h: (WebCore::StringImpl::hasTerminatingNullCharacter): (WebCore::StringImpl::inTable): (WebCore::StringImpl::setInTable): Converted the bools to be inside of PtrAndFlags to avoid growing StringImpl in size.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UString.cpp

    r44224 r44325  
    6363extern const double Inf;
    6464
     65// This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
     66static const int minLengthToShare = 30;
     67
    6568static inline size_t overflowIndicator() { return std::numeric_limits<size_t>::max(); }
    6669static inline size_t maxUChars() { return std::numeric_limits<size_t>::max() / sizeof(UChar); }
     
    233236}
    234237
    235 PassRefPtr<UString::Rep> UString::Rep::share(UChar* string, int length, PassRefPtr<UString::SharedUChar> sharedBuffer)
     238PassRefPtr<UString::Rep> UString::Rep::create(UChar* string, int length, PassRefPtr<UString::SharedUChar> sharedBuffer)
    236239{
    237240    PassRefPtr<UString::Rep> rep = create(string, length);
     
    383386UString::SharedUChar* UString::BaseString::sharedBuffer()
    384387{
    385     // Don't share empty, null and 1 character strings from SmallStrings.
    386     if (len <= 1)
     388
     389    if (len < minLengthToShare)
    387390        return 0;
    388391
Note: See TracChangeset for help on using the changeset viewer.