Ignore:
Timestamp:
Feb 18, 2016, 9:25:42 AM (9 years ago)
Author:
[email protected]
Message:

JSString resolution of substrings should use StringImpl sharing optimization.
<https://webkit.org/b/154068>
<rdar://problem/24629358>

Reviewed by Antti Koivisto.

When resolving a JSString that's actually a substring of another JSString,
use the StringImpl sharing optimization to create a new string pointing into
the parent one, instead of copying out the bytes of the string.

This dramatically reduces peak memory usage on Gerrit diff viewer pages.

Another approach to this would be to induce GC far more frequently due to
the added cost of copying out these substrings. It would reduce the risk
of prolonging the life of strings only kept alive by substrings.

This patch chooses to trade that risk for less GC and lower peak memory.

  • runtime/JSString.cpp:

(JSC::JSRopeString::resolveRope):

File:
1 edited

Legend:

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

    r194310 r196761  
    238238    if (isSubstring()) {
    239239        ASSERT(!substringBase()->isRope());
    240         m_value = substringBase()->m_value.substring(substringOffset(), m_length);
     240        m_value = substringBase()->m_value.substringSharingImpl(substringOffset(), m_length);
    241241        substringBase().clear();
    242242        return;
Note: See TracChangeset for help on using the changeset viewer.