Title: [241242] trunk/Source
Revision
241242
Author
[email protected]
Date
2019-02-09 11:44:06 -0800 (Sat, 09 Feb 2019)

Log Message

Unreviewed, rolling in r241237 again
https://bugs.webkit.org/show_bug.cgi?id=194469

Source/_javascript_Core:

* runtime/JSString.h:
(JSC::jsSubstring):

Source/WTF:

After the measurement, this patch was unrelated to recent regression.

* wtf/text/StringImpl.h:
(WTF::StringImpl::isSubString const):
(WTF::StringImpl::createSubstringSharingImpl):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (241241 => 241242)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-09 17:52:38 UTC (rev 241241)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-09 19:44:06 UTC (rev 241242)
@@ -1,3 +1,11 @@
+2019-02-09  Yusuke Suzuki  <[email protected]>
+
+        Unreviewed, rolling in r241237 again
+        https://bugs.webkit.org/show_bug.cgi?id=194469
+
+        * runtime/JSString.h:
+        (JSC::jsSubstring):
+
 2019-02-09  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r241237.

Modified: trunk/Source/_javascript_Core/runtime/JSString.h (241241 => 241242)


--- trunk/Source/_javascript_Core/runtime/JSString.h	2019-02-09 17:52:38 UTC (rev 241241)
+++ trunk/Source/_javascript_Core/runtime/JSString.h	2019-02-09 19:44:06 UTC (rev 241242)
@@ -636,7 +636,10 @@
         if (c <= maxSingleCharacterString)
             return vm->smallStrings.singleCharacterString(c);
     }
-    return JSString::createHasOtherOwner(*vm, StringImpl::createSubstringSharingImpl(*s.impl(), offset, length));
+    auto impl = StringImpl::createSubstringSharingImpl(*s.impl(), offset, length);
+    if (impl->isSubString())
+        return JSString::createHasOtherOwner(*vm, WTFMove(impl));
+    return JSString::create(*vm, WTFMove(impl));
 }
 
 inline JSString* jsOwnedString(VM* vm, const String& s)

Modified: trunk/Source/WTF/ChangeLog (241241 => 241242)


--- trunk/Source/WTF/ChangeLog	2019-02-09 17:52:38 UTC (rev 241241)
+++ trunk/Source/WTF/ChangeLog	2019-02-09 19:44:06 UTC (rev 241242)
@@ -1,3 +1,14 @@
+2019-02-09  Yusuke Suzuki  <[email protected]>
+
+        Unreviewed, rolling in r241237 again
+        https://bugs.webkit.org/show_bug.cgi?id=194469
+
+        After the measurement, this patch was unrelated to recent regression.
+
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::isSubString const):
+        (WTF::StringImpl::createSubstringSharingImpl):
+
 2019-02-09  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r241237.

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (241241 => 241242)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2019-02-09 17:52:38 UTC (rev 241241)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2019-02-09 19:44:06 UTC (rev 241242)
@@ -297,9 +297,7 @@
     
     bool isExternal() const { return bufferOwnership() == BufferExternal; }
 
-#if STRING_STATS
     bool isSubString() const { return bufferOwnership() == BufferSubstring; }
-#endif
 
     static WTF_EXPORT_PRIVATE Expected<CString, UTF8ConversionError> utf8ForCharacters(const LChar* characters, unsigned length);
     static WTF_EXPORT_PRIVATE Expected<CString, UTF8ConversionError> utf8ForCharacters(const UChar* characters, unsigned length, ConversionMode = LenientConversion);
@@ -937,10 +935,20 @@
     if (!length)
         return *empty();
 
+    // Coyping the thing would save more memory sometimes, largely due to the size of pointer.
+    size_t substringSize = allocationSize<StringImpl*>(1);
+    if (rep.is8Bit()) {
+        if (substringSize >= allocationSize<LChar>(length))
+            return create(rep.m_data8 + offset, length);
+    } else {
+        if (substringSize >= allocationSize<UChar>(length))
+            return create(rep.m_data16 + offset, length);
+    }
+
     auto* ownerRep = ((rep.bufferOwnership() == BufferSubstring) ? rep.substringBuffer() : &rep);
 
     // We allocate a buffer that contains both the StringImpl struct as well as the pointer to the owner string.
-    auto* stringImpl = static_cast<StringImpl*>(fastMalloc(allocationSize<StringImpl*>(1)));
+    auto* stringImpl = static_cast<StringImpl*>(fastMalloc(substringSize));
     if (rep.is8Bit())
         return adoptRef(*new (NotNull, stringImpl) StringImpl(rep.m_data8 + offset, length, *ownerRep));
     return adoptRef(*new (NotNull, stringImpl) StringImpl(rep.m_data16 + offset, length, *ownerRep));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to