Changeset 44641 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jun 12, 2009, 5:41:03 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

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

Reviewed by Darin Adler.

UString shouldn't create sharedBuffer for SmallStrings.
https://bugs.webkit.org/show_bug.cgi?id=26360

The methods changed are not used by JSC, so there is no JS perf impact. However,
there is a potential DOM perf impact, so I re-ran several of the tests that
I ran previously and ensured that the perf stay the same which caused me to
adjust the minLengthToShare.

  • JavaScriptCore.exp:
  • runtime/UString.cpp: (JSC::UString::Rep::sharedBuffer):

Determines if the buffer being shared is big enough before doing so.
Previously, BaseString::sharedBuffer was called but it would only know
the length of the base string (BaseString::len) which may not be the same
as the string being shared (Rep::len).

(JSC::UString::BaseString::sharedBuffer):

This is now only be used by Rep::sharedBuffer. which does the length check.

  • runtime/UString.h:

WebCore:

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

Reviewed by Darin Adler.

UString shouldn't create sharedBuffer for SmallStrings.
https://bugs.webkit.org/show_bug.cgi?id=26347

Change the call to use the method UString::Rep::sharedBuffer due
to changes in UString.

No noticable change in behavior, so no test.

  • platform/text/StringImpl.cpp: (WebCore::StringImpl::create):
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r44633 r44641  
     12009-06-12  David Levin  <[email protected]>
     2
     3        Reviewed by Darin Adler.
     4
     5        UString shouldn't create sharedBuffer for SmallStrings.
     6        https://bugs.webkit.org/show_bug.cgi?id=26360
     7
     8        The methods changed are not used by JSC, so there is no JS perf impact.  However,
     9        there is a potential DOM perf impact, so I re-ran several of the tests that
     10        I ran previously and ensured that the perf stay the same which caused me to
     11        adjust the minLengthToShare.
     12
     13        * JavaScriptCore.exp:
     14        * runtime/UString.cpp:
     15        (JSC::UString::Rep::sharedBuffer):
     16            Determines if the buffer being shared is big enough before doing so.
     17            Previously, BaseString::sharedBuffer was called but it would only know
     18            the length of the base string (BaseString::len) which may not be the same
     19            as the string being shared (Rep::len).
     20        (JSC::UString::BaseString::sharedBuffer):
     21            This is now only be used by Rep::sharedBuffer. which does the length check.
     22        * runtime/UString.h:
     23
    1242009-06-12  Dimitri Glazkov  <[email protected]>
    225
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r44508 r44641  
    218218__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE
    219219__ZN3JSC7Profile7forEachEMNS_11ProfileNodeEFvvE
    220 __ZN3JSC7UString10BaseString12sharedBufferEv
     220__ZN3JSC7UString3Rep12sharedBufferEv
    221221__ZN3JSC7UString3Rep11computeHashEPKci
    222222__ZN3JSC7UString3Rep11computeHashEPKti
  • trunk/JavaScriptCore/runtime/UString.cpp

    r44325 r44641  
    6464
    6565// This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
    66 static const int minLengthToShare = 30;
     66static const int minLengthToShare = 10;
    6767
    6868static inline size_t overflowIndicator() { return std::numeric_limits<size_t>::max(); }
     
    244244}
    245245
     246UString::SharedUChar* UString::Rep::sharedBuffer()
     247{
     248    UString::BaseString* base = baseString();
     249    if (len < minLengthToShare)
     250        return 0;
     251
     252    return base->sharedBuffer();
     253}
     254
    246255void UString::Rep::destroy()
    247256{
     
    386395UString::SharedUChar* UString::BaseString::sharedBuffer()
    387396{
    388 
    389     if (len < minLengthToShare)
    390         return 0;
    391 
    392397    if (!m_sharedBuffer)
    393398        setSharedBuffer(SharedUChar::create(new OwnFastMallocPtr<UChar>(buf)));
  • trunk/JavaScriptCore/runtime/UString.h

    r44325 r44641  
    108108            static PassRefPtr<Rep> create(UChar*, int, PassRefPtr<SharedUChar>);
    109109
     110            SharedUChar* sharedBuffer();
    110111            void destroy();
    111112
     
    193194            bool isShared() { return rc != 1 || isBufferReadOnly(); }
    194195            void setSharedBuffer(PassRefPtr<SharedUChar>);
    195             SharedUChar* sharedBuffer();
    196196
    197197            bool isBufferReadOnly()
     
    225225            }
    226226
     227            SharedUChar* sharedBuffer();
    227228            bool slowIsBufferReadOnly();
    228229
Note: See TracChangeset for help on using the changeset viewer.