Commit 1ef10580 authored by levin@chromium.org's avatar levin@chromium.org

JavaScriptCore:

2009-06-12  David Levin  <levin@chromium.org>

        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  <levin@chromium.org>

        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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44641 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e553b25a
2009-06-12 David Levin <levin@chromium.org>
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:
2009-06-12 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Eric Seidel.
......@@ -217,7 +217,7 @@ __ZN3JSC7Profile10restoreAllEv
__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE
__ZN3JSC7Profile7forEachEMNS_11ProfileNodeEFvvE
__ZN3JSC7UString10BaseString12sharedBufferEv
__ZN3JSC7UString3Rep12sharedBufferEv
__ZN3JSC7UString3Rep11computeHashEPKci
__ZN3JSC7UString3Rep11computeHashEPKti
__ZN3JSC7UString3Rep14nullBaseStringE
......
......@@ -63,7 +63,7 @@ extern const double NaN;
extern const double Inf;
// This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
static const int minLengthToShare = 30;
static const int minLengthToShare = 10;
static inline size_t overflowIndicator() { return std::numeric_limits<size_t>::max(); }
static inline size_t maxUChars() { return std::numeric_limits<size_t>::max() / sizeof(UChar); }
......@@ -243,6 +243,15 @@ PassRefPtr<UString::Rep> UString::Rep::create(UChar* string, int length, PassRef
return rep;
}
UString::SharedUChar* UString::Rep::sharedBuffer()
{
UString::BaseString* base = baseString();
if (len < minLengthToShare)
return 0;
return base->sharedBuffer();
}
void UString::Rep::destroy()
{
checkConsistency();
......@@ -385,10 +394,6 @@ void UString::Rep::checkConsistency() const
UString::SharedUChar* UString::BaseString::sharedBuffer()
{
if (len < minLengthToShare)
return 0;
if (!m_sharedBuffer)
setSharedBuffer(SharedUChar::create(new OwnFastMallocPtr<UChar>(buf)));
return m_sharedBuffer;
......
......@@ -107,6 +107,7 @@ namespace JSC {
// Uses SharedUChar to have joint ownership over the UChar*.
static PassRefPtr<Rep> create(UChar*, int, PassRefPtr<SharedUChar>);
SharedUChar* sharedBuffer();
void destroy();
bool baseIsSelf() const { return m_identifierTableAndFlags.isFlagSet(BaseStringFlag); }
......@@ -192,7 +193,6 @@ namespace JSC {
struct BaseString : public Rep {
bool isShared() { return rc != 1 || isBufferReadOnly(); }
void setSharedBuffer(PassRefPtr<SharedUChar>);
SharedUChar* sharedBuffer();
bool isBufferReadOnly()
{
......@@ -224,6 +224,7 @@ namespace JSC {
checkConsistency();
}
SharedUChar* sharedBuffer();
bool slowIsBufferReadOnly();
friend struct Rep;
......
2009-06-12 David Levin <levin@chromium.org>
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):
2009-06-12 Peter Kasting <pkasting@google.com>
Fix Chromium and some of Cairo build bustage, fallout from
......@@ -1026,7 +1026,7 @@ PassRefPtr<StringImpl> StringImpl::create(const char* string)
#if USE(JSC)
PassRefPtr<StringImpl> StringImpl::create(const JSC::UString& str)
{
SharedUChar* sharedBuffer = const_cast<JSC::UString*>(&str)->rep()->baseString()->sharedBuffer();
SharedUChar* sharedBuffer = const_cast<JSC::UString*>(&str)->rep()->sharedBuffer();
if (sharedBuffer) {
PassRefPtr<StringImpl> impl = adoptRef(new StringImpl(const_cast<UChar*>(str.data()), str.size(), AdoptBuffer()));
sharedBuffer->ref();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment