Ignore:
Timestamp:
Oct 18, 2011, 7:54:29 PM (14 years ago)
Author:
[email protected]
Message:

Switched ropes from malloc memory to GC memory
https://bugs.webkit.org/show_bug.cgi?id=70364

Reviewed by Gavin Barraclough.

~1% SunSpider speedup. Neutral elsewhere. Removes one cause for strings
having C++ destructors.

  • heap/MarkStack.cpp:

(JSC::visitChildren): Call the JSString visitChildren function now,
since it's no longer a no-op.

  • runtime/JSString.cpp:

(JSC::JSString::~JSString): Moved this destructor out of line because
it's called virtually, so there's no value to inlining.

(JSC::JSString::RopeBuilder::expand): Switched RopeBuilder to be a thin
initializing wrapper around JSString. JSString now represents ropes
directly, rather than relying on an underlying malloc object.

(JSC::JSString::visitChildren): Visit our rope fibers, since they're GC
objects now.

(JSC::JSString::resolveRope):
(JSC::JSString::resolveRopeSlowCase):
(JSC::JSString::outOfMemory): Updated for operating on JSStrings instead
of malloc objects.

(JSC::JSString::replaceCharacter): Removed optimizations for substringing
ropes and replacing subsections of ropes. We want to reimplement versions
of these optimizations in the future, but this patch already has good
performance without them.

  • runtime/JSString.h:

(JSC::RopeBuilder::JSString):
(JSC::RopeBuilder::finishCreation):
(JSC::RopeBuilder::createNull):
(JSC::RopeBuilder::create):
(JSC::RopeBuilder::createHasOtherOwner):
(JSC::jsSingleCharacterString):
(JSC::jsSingleCharacterSubstring):
(JSC::jsNontrivialString):
(JSC::jsString):
(JSC::jsSubstring):
(JSC::jsOwnedString): Lots of mechanical changes here. The two important
things are: (1) The fibers in JSString::m_fibers are JSStrings now, not
malloc objects; (2) I simplified the JSString constructor interface to
only accept PassRefPtr<StringImpl>, instead of variations on that like
UString, reducing refcount churn.

  • runtime/JSValue.h:
  • runtime/JSValue.cpp:

(JSC::JSValue::toPrimitiveString): Updated this function to return a
JSString instead of a UString, since that's what clients want now.

  • runtime/Operations.cpp:

(JSC::jsAddSlowCase):

  • runtime/Operations.h:

(JSC::jsString):

  • runtime/SmallStrings.cpp:

(JSC::SmallStrings::createEmptyString): Updated for interface changes above.

  • runtime/StringConstructor.cpp:

(JSC::constructWithStringConstructor):

  • runtime/StringObject.h:

(JSC::StringObject::create): Don't create a new JSString if we already
have a JSString.

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncConcat): Updated for interface changes above.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSValue.cpp

    r94996 r97827  
    205205}
    206206
     207JSString* JSValue::toPrimitiveString(ExecState* exec) const
     208{
     209    if (isString())
     210        return static_cast<JSString*>(asCell());
     211    if (isInt32())
     212        return jsString(&exec->globalData(), exec->globalData().numericStrings.add(asInt32()));
     213    if (isDouble())
     214        return jsString(&exec->globalData(), exec->globalData().numericStrings.add(asDouble()));
     215    if (isTrue())
     216        return jsNontrivialString(exec, exec->propertyNames().trueKeyword.ustring());
     217    if (isFalse())
     218        return jsNontrivialString(exec, exec->propertyNames().falseKeyword.ustring());
     219    if (isNull())
     220        return jsNontrivialString(exec, exec->propertyNames().nullKeyword.ustring());
     221    if (isUndefined())
     222        return jsNontrivialString(exec, exec->propertyNames().undefined.ustring());
     223
     224    ASSERT(isCell());
     225    JSValue v = asCell()->toPrimitive(exec, NoPreference);
     226    if (v.isString())
     227        return static_cast<JSString*>(v.asCell());
     228    return jsString(&exec->globalData(), v.toString(exec));
     229}
     230
    207231} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.