Ignore:
Timestamp:
Dec 10, 2009, 6:07:42 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=32400
Switch remaining cases of string addition to use ropes.

Reviewed by Oliver Hunt.

~1% progression on Sunspidey.

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/JSString.h:

(JSC::JSString::JSString):
(JSC::JSString::appendStringInConstruct):

  • runtime/Operations.cpp:

(JSC::jsAddSlowCase):

  • runtime/Operations.h:

(JSC::jsString):
(JSC::jsAdd):

File:
1 edited

Legend:

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

    r51964 r51975  
    204204            ASSERT(ropeLength == index);
    205205        }
     206        // This constructor constructs a new string by concatenating s1 & s2.
     207        // This should only be called with ropeLength <= 3.
     208        JSString(JSGlobalData* globalData, unsigned ropeLength, JSString* s1, const UString& u2)
     209            : JSCell(globalData->stringStructure.get())
     210            , m_stringLength(s1->length() + u2.size())
     211            , m_ropeLength(ropeLength)
     212        {
     213            ASSERT(ropeLength <= s_maxInternalRopeLength);
     214            unsigned index = 0;
     215            appendStringInConstruct(index, s1);
     216            appendStringInConstruct(index, u2);
     217            ASSERT(ropeLength == index);
     218        }
     219        // This constructor constructs a new string by concatenating s1 & s2.
     220        // This should only be called with ropeLength <= 3.
     221        JSString(JSGlobalData* globalData, unsigned ropeLength, const UString& u1, JSString* s2)
     222            : JSCell(globalData->stringStructure.get())
     223            , m_stringLength(u1.size() + s2->length())
     224            , m_ropeLength(ropeLength)
     225        {
     226            ASSERT(ropeLength <= s_maxInternalRopeLength);
     227            unsigned index = 0;
     228            appendStringInConstruct(index, u1);
     229            appendStringInConstruct(index, s2);
     230            ASSERT(ropeLength == index);
     231        }
    206232        // This constructor constructs a new string by concatenating v1, v2 & v3.
    207233        // This should only be called with ropeLength <= 3 ... which since every
     
    259285        void resolveRope(ExecState*) const;
    260286
     287        void appendStringInConstruct(unsigned& index, const UString& string)
     288        {
     289            m_fibers[index++] = Rope::Fiber(string.rep()->ref());
     290        }
     291
    261292        void appendStringInConstruct(unsigned& index, JSString* jsString)
    262293        {
     
    265296                    m_fibers[index++] = jsString->m_fibers[i].ref();
    266297            } else
    267                 m_fibers[index++] = Rope::Fiber(jsString->string().rep()->ref());
     298                appendStringInConstruct(index, jsString->string());
    268299        }
    269300
     
    312343
    313344        friend JSValue jsString(ExecState* exec, JSString* s1, JSString* s2);
     345        friend JSValue jsString(ExecState* exec, const UString& u1, JSString* s2);
     346        friend JSValue jsString(ExecState* exec, JSString* s1, const UString& u2);
    314347        friend JSValue jsString(ExecState* exec, Register* strings, unsigned count);
    315348    };
Note: See TracChangeset for help on using the changeset viewer.