Title: [196761] trunk/Source/_javascript_Core
Revision
196761
Author
akl...@apple.com
Date
2016-02-18 09:25:42 -0800 (Thu, 18 Feb 2016)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (196760 => 196761)


--- trunk/Source/_javascript_Core/ChangeLog	2016-02-18 17:19:33 UTC (rev 196760)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-02-18 17:25:42 UTC (rev 196761)
@@ -1,3 +1,26 @@
+2016-02-18  Andreas Kling  <akl...@apple.com>
+
+        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):
+
 2016-02-18  Chris Dumez  <cdu...@apple.com>
 
         Crash on SES selftest page when loading the page while WebInspector is open

Modified: trunk/Source/_javascript_Core/runtime/JSString.cpp (196760 => 196761)


--- trunk/Source/_javascript_Core/runtime/JSString.cpp	2016-02-18 17:19:33 UTC (rev 196760)
+++ trunk/Source/_javascript_Core/runtime/JSString.cpp	2016-02-18 17:25:42 UTC (rev 196761)
@@ -237,7 +237,7 @@
     
     if (isSubstring()) {
         ASSERT(!substringBase()->isRope());
-        m_value = substringBase()->m_value.substring(substringOffset(), m_length);
+        m_value = substringBase()->m_value.substringSharingImpl(substringOffset(), m_length);
         substringBase().clear();
         return;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to