Ignore:
Timestamp:
Feb 15, 2010, 1:03:45 PM (15 years ago)
Author:
[email protected]
Message:

Bug 34952 - String lengths in UString should be unsigned.
This matches WebCore::StringImpl, and better unifies behaviour throughout JSC.

Reviewed by Geoff Garen.

JavaScriptCore:

  • JavaScriptCore.exp:
  • bytecode/EvalCodeCache.h:
  • runtime/Identifier.cpp:

(JSC::Identifier::equal):

  • runtime/Identifier.h:
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEscape):

  • runtime/JSONObject.cpp:

(JSC::gap):
(JSC::Stringifier::indent):

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToPrecision):

  • runtime/RegExp.cpp:

(JSC::RegExp::match):

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow):
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncSplit):
(JSC::trimString):

  • runtime/UString.cpp:

(JSC::UString::UString):
(JSC::UString::from):
(JSC::UString::getCString):
(JSC::UString::ascii):
(JSC::UString::operator[]):
(JSC::UString::toStrictUInt32):
(JSC::UString::find):
(JSC::UString::rfind):
(JSC::UString::substr):
(JSC::operator<):
(JSC::operator>):
(JSC::compare):
(JSC::equal):
(JSC::UString::UTF8String):

  • runtime/UString.h:

(JSC::UString::size):
(JSC::operator==):

  • runtime/UStringImpl.cpp:

(JSC::UStringImpl::create):

  • runtime/UStringImpl.h:

(JSC::UStringImpl::create):
(JSC::UStringImpl::size):
(JSC::UStringImpl::computeHash):
(JSC::UStringImpl::UStringImpl):

WebCore:

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::atob):
(WebCore::JSDOMWindow::btoa):

File:
1 edited

Legend:

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

    r54743 r54789  
    5454
    5555    static PassRefPtr<UStringImpl> create(const char* c);
    56     static PassRefPtr<UStringImpl> create(const char* c, int length);
    57     static PassRefPtr<UStringImpl> create(const UChar* buffer, int length);
    58 
    59     static PassRefPtr<UStringImpl> create(PassRefPtr<UStringImpl> rep, int offset, int length)
     56    static PassRefPtr<UStringImpl> create(const char* c, unsigned length);
     57    static PassRefPtr<UStringImpl> create(const UChar* buffer, unsigned length);
     58
     59    static PassRefPtr<UStringImpl> create(PassRefPtr<UStringImpl> rep, unsigned offset, unsigned length)
    6060    {
    6161        ASSERT(rep);
     
    6464    }
    6565
    66     static PassRefPtr<UStringImpl> create(PassRefPtr<SharedUChar> sharedBuffer, UChar* buffer, int length)
     66    static PassRefPtr<UStringImpl> create(PassRefPtr<SharedUChar> sharedBuffer, UChar* buffer, unsigned length)
    6767    {
    6868        return adoptRef(new UStringImpl(buffer, length, sharedBuffer));
     
    101101    SharedUChar* sharedBuffer();
    102102    UChar* data() const { return m_data; }
    103     int size() const { return m_length; }
     103    unsigned size() const { return m_length; }
    104104    size_t cost()
    105105    {
     
    137137    }
    138138
    139     static unsigned computeHash(const UChar* s, int length) { ASSERT(length >= 0); return WTF::stringHash(s, length); }
    140     static unsigned computeHash(const char* s, int length) { ASSERT(length >= 0); return WTF::stringHash(s, length); }
     139    static unsigned computeHash(const UChar* s, unsigned length) { return WTF::stringHash(s, length); }
     140    static unsigned computeHash(const char* s, unsigned length) { return WTF::stringHash(s, length); }
    141141    static unsigned computeHash(const char* s) { return WTF::stringHash(s); }
    142142
     
    163163
    164164    // Used to construct normal strings with an internal or external buffer.
    165     UStringImpl(UChar* data, int length, BufferOwnership ownership)
     165    UStringImpl(UChar* data, unsigned length, BufferOwnership ownership)
    166166        : m_data(data)
    167167        , m_buffer(0)
     
    178178    // static strings will be shared across threads & ref-counted in a non-threadsafe manner.
    179179    enum StaticStringConstructType { ConstructStaticString };
    180     UStringImpl(UChar* data, int length, StaticStringConstructType)
     180    UStringImpl(UChar* data, unsigned length, StaticStringConstructType)
    181181        : m_data(data)
    182182        , m_buffer(0)
     
    189189
    190190    // Used to create new strings that are a substring of an existing string.
    191     UStringImpl(UChar* data, int length, PassRefPtr<UStringImpl> base)
     191    UStringImpl(UChar* data, unsigned length, PassRefPtr<UStringImpl> base)
    192192        : m_data(data)
    193193        , m_bufferSubstring(base.releaseRef())
     
    205205
    206206    // Used to construct new strings sharing an existing shared buffer.
    207     UStringImpl(UChar* data, int length, PassRefPtr<SharedUChar> sharedBuffer)
     207    UStringImpl(UChar* data, unsigned length, PassRefPtr<SharedUChar> sharedBuffer)
    208208        : m_data(data)
    209209        , m_bufferShared(sharedBuffer.releaseRef())
     
    221221
    222222    // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
    223     static const int s_minLengthToShare = 10;
     223    static const unsigned s_minLengthToShare = 10;
    224224    static const unsigned s_copyCharsInlineCutOff = 20;
    225225    // We initialize and increment/decrement the refCount for all normal (non-static) strings by the value 2.
    226226    // We initialize static strings with an odd number (specifically, 1), such that the refCount cannot reach zero.
    227227    static const unsigned s_refCountMask = 0xFFFFFFF0;
    228     static const int s_refCountIncrement = 0x20;
    229     static const int s_refCountFlagStatic = 0x10;
     228    static const unsigned s_refCountIncrement = 0x20;
     229    static const unsigned s_refCountFlagStatic = 0x10;
    230230    static const unsigned s_refCountFlagHasReportedCost = 0x8;
    231231    static const unsigned s_refCountFlagIsIdentifier = 0x4;
     
    245245        SharedUChar* m_bufferShared;
    246246    };
    247     int m_length;
     247    unsigned m_length;
    248248    unsigned m_refCountAndFlags;
    249249    mutable unsigned m_hash;
Note: See TracChangeset for help on using the changeset viewer.