Ignore:
Timestamp:
Mar 10, 2010, 6:36:08 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=35991
Would be faster to not use a thread specific to implement StringImpl::empty()

Reviewed by Darin Adler, Geoffrey Garen, Maciej Stachowiak.

JavaScriptCore:

Change JSC::UStringImpl's implementation of empty() match to match StringImpl's new implementation
(use a static defined within the empty() method), and change the interface to match too (return
a pointer not a reference).

~0% performance impact (possible minor progression from moving empty() from .h to .cpp).

(JSC::Identifier::add):
(JSC::Identifier::addSlowCase):

  • runtime/PropertyNameArray.cpp:

(JSC::PropertyNameArray::add):

  • runtime/UString.cpp:

(JSC::initializeUString):
(JSC::UString::UString):

  • runtime/UStringImpl.cpp:

(JSC::UStringImpl::empty):
(JSC::UStringImpl::create):

  • runtime/UStringImpl.h:

(JSC::UStringImpl::adopt):
(JSC::UStringImpl::createUninitialized):
(JSC::UStringImpl::tryCreateUninitialized):

WebCore:

Copy JavaScriptCore in making 'static' strings threadsafe, make the empty string a static,
shared by all threads.

~2% progression on Dromaeo DOM core & JS lib tests.

  • platform/ThreadGlobalData.cpp:

(WebCore::ThreadGlobalData::ThreadGlobalData):
(WebCore::ThreadGlobalData::~ThreadGlobalData):

  • platform/ThreadGlobalData.h:

(WebCore::ThreadGlobalData::eventNames):

  • platform/text/StringImpl.cpp:

(WebCore::StringImpl::StringImpl):
(WebCore::StringImpl::empty):

  • platform/text/StringImpl.h:

(WebCore::StringImpl::deref):
(WebCore::StringImpl::hasOneRef):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UStringImpl.h

    r55679 r55825  
    114114            return adoptRef(new UStringImpl(vector.releaseBuffer(), length));
    115115        }
    116         return &empty();
    117     }
    118 
     116        return empty();
     117    }
     118
     119    static PassRefPtr<UStringImpl> create(const UChar* buffer, unsigned length);
     120    static PassRefPtr<UStringImpl> create(const char* c, unsigned length);
    119121    static PassRefPtr<UStringImpl> create(const char* c);
    120     static PassRefPtr<UStringImpl> create(const char* c, unsigned length);
    121     static PassRefPtr<UStringImpl> create(const UChar* buffer, unsigned length);
    122122
    123123    static PassRefPtr<UStringImpl> create(PassRefPtr<UStringImpl> rep, unsigned offset, unsigned length)
     
    137137        if (!length) {
    138138            output = 0;
    139             return &empty();
     139            return empty();
    140140        }
    141141
     
    151151        if (!length) {
    152152            output = 0;
    153             return &empty();
     153            return empty();
    154154        }
    155155
     
    204204    static unsigned computeHash(const char* s) { return WTF::stringHash(s); }
    205205
    206     static UStringImpl& empty() { return *s_empty; }
     206    static UStringImpl* empty();
    207207
    208208    ALWAYS_INLINE void checkConsistency() const
     
    296296    mutable unsigned m_hash;
    297297
    298     JS_EXPORTDATA static UStringImpl* s_empty;
    299 
    300298    friend class JIT;
    301299    friend class SmallStringsStorage;
Note: See TracChangeset for help on using the changeset viewer.