Changeset 51671 in webkit for trunk/JavaScriptCore/jit


Ignore:
Timestamp:
Dec 3, 2009, 6:15:18 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=32136
Add a rope representation to JSString. Presently JSString always holds its data in UString form.
Instead, allow the result of a string concatenation to be represented in a tree form - with a
variable sized, reference-counted rope node retaining a set of UString::Reps (or other rope nopes).

Reviewed by Oliver "Brraaaaiiiinnnnnzzzzzzzz" Hunt.

Strings must still currently be resolved down to a flat UString representation before being used,
but by holding the string in a rope representation during construction we can avoid copying data
until we know the final size of the string.

~2% progression on SunSpider (~25% on date-format-xparb, ~20% on string-validate-input).

  • Update exports.
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::privateExecute):

  • Make use of new JSString::length() method to avoid prematurely resolving ropes.
  • jit/JITOpcodes.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

  • Switch the string length trampoline to read the length directly from JSString::m_length, rather than from the JSString's UString::Rep's 'len' property.
  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • Modify op_add such that addition of two strings, where either or both strings are already in rope representation, produces a rope as a result.
  • runtime/JSString.cpp:

(JSC::JSString::Rope::~Rope):
(JSC::copyChars):
(JSC::JSString::resolveRope):
(JSC::JSString::getPrimitiveNumber):
(JSC::JSString::toBoolean):
(JSC::JSString::toNumber):
(JSC::JSString::toString):
(JSC::JSString::toThisString):
(JSC::JSString::getStringPropertyDescriptor):

  • runtime/JSString.h:

(JSC::JSString::Rope::Fiber::Fiber):
(JSC::JSString::Rope::Fiber::destroy):
(JSC::JSString::Rope::Fiber::isRope):
(JSC::JSString::Rope::Fiber::rope):
(JSC::JSString::Rope::Fiber::string):
(JSC::JSString::Rope::create):
(JSC::JSString::Rope::initializeFiber):
(JSC::JSString::Rope::ropeLength):
(JSC::JSString::Rope::stringLength):
(JSC::JSString::Rope::fibers):
(JSC::JSString::Rope::Rope):
(JSC::JSString::Rope::operator new):
(JSC::JSString::JSString):
(JSC::JSString::value):
(JSC::JSString::length):
(JSC::JSString::isRope):
(JSC::JSString::rope):
(JSC::JSString::string):
(JSC::JSString::canGetIndex):
(JSC::jsSingleCharacterSubstring):
(JSC::JSString::getIndex):
(JSC::jsSubstring):
(JSC::JSString::getStringPropertySlot):

  • Add rope form.
  • runtime/Operations.h:

(JSC::jsAdd):
(JSC::concatenateStrings):

  • Update string concatenation, and addition of ropes, to produce ropes.
  • runtime/StringObject.cpp:

(JSC::StringObject::getOwnPropertyNames):

  • Make use of new JSString::length() method to avoid prematurely resolving ropes.
Location:
trunk/JavaScriptCore/jit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITOpcodes.cpp

    r50981 r51671  
    5353
    5454    // Checks out okay! - get the length from the Ustring.
    55     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSString, m_value) + OBJECT_OFFSETOF(UString, m_rep)), regT2);
    56     load32(Address(regT2, OBJECT_OFFSETOF(UString::Rep, len)), regT2);
     55    load32(Address(regT0, OBJECT_OFFSETOF(JSString, m_length)), regT2);
    5756
    5857    Jump string_failureCases3 = branch32(Above, regT2, Imm32(INT_MAX));
     
    15941593
    15951594    // Checks out okay! - get the length from the Ustring.
    1596     loadPtr(Address(regT0, OBJECT_OFFSETOF(JSString, m_value) + OBJECT_OFFSETOF(UString, m_rep)), regT0);
    1597     load32(Address(regT0, OBJECT_OFFSETOF(UString::Rep, len)), regT0);
     1595    load32(Address(regT0, OBJECT_OFFSETOF(JSString, m_length)), regT0);
    15981596
    15991597    Jump string_failureCases3 = branch32(Above, regT0, Imm32(JSImmediate::maxImmediateInt));
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r51141 r51671  
    10441044    bool leftIsString = v1.isString();
    10451045    if (leftIsString && v2.isString()) {
     1046        if (asString(v1)->isRope() || asString(v2)->isRope()) {
     1047            RefPtr<JSString::Rope> rope = JSString::Rope::create(2);
     1048            rope->initializeFiber(0, asString(v1));
     1049            rope->initializeFiber(1, asString(v2));
     1050            JSGlobalData* globalData = &callFrame->globalData();
     1051            return JSValue::encode(new (globalData) JSString(globalData, rope.release()));
     1052        }
     1053
    10461054        RefPtr<UString::Rep> value = concatenate(asString(v1)->value().rep(), asString(v2)->value().rep());
    10471055        if (UNLIKELY(!value)) {
Note: See TracChangeset for help on using the changeset viewer.