Title: [241117] trunk/Source/_javascript_Core
Revision
241117
Author
ysuz...@apple.com
Date
2019-02-06 21:51:46 -0800 (Wed, 06 Feb 2019)

Log Message

[JSC] Use BufferInternal single character StringImpl for SmallStrings
https://bugs.webkit.org/show_bug.cgi?id=194374

Reviewed by Geoffrey Garen.

Currently, we first create a large StringImpl, and create bunch of substrings with length = 1.
But pointer is larger than single character. BufferInternal StringImpl with single character
is more memory efficient.

* runtime/SmallStrings.cpp:
(JSC::SmallStringsStorage::SmallStringsStorage):
(JSC::SmallStrings::SmallStrings):
* runtime/SmallStrings.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (241116 => 241117)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-07 05:39:12 UTC (rev 241116)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-07 05:51:46 UTC (rev 241117)
@@ -1,5 +1,21 @@
 2019-02-06  Yusuke Suzuki  <ysuz...@apple.com>
 
+        [JSC] Use BufferInternal single character StringImpl for SmallStrings
+        https://bugs.webkit.org/show_bug.cgi?id=194374
+
+        Reviewed by Geoffrey Garen.
+
+        Currently, we first create a large StringImpl, and create bunch of substrings with length = 1.
+        But pointer is larger than single character. BufferInternal StringImpl with single character
+        is more memory efficient.
+
+        * runtime/SmallStrings.cpp:
+        (JSC::SmallStringsStorage::SmallStringsStorage):
+        (JSC::SmallStrings::SmallStrings):
+        * runtime/SmallStrings.h:
+
+2019-02-06  Yusuke Suzuki  <ysuz...@apple.com>
+
         [JSC] InitializeEntrypointArguments should produce SpecCellCheck if FlushFormat is FlushedCell
         https://bugs.webkit.org/show_bug.cgi?id=194369
         <rdar://problem/47813087>

Modified: trunk/Source/_javascript_Core/runtime/SmallStrings.cpp (241116 => 241117)


--- trunk/Source/_javascript_Core/runtime/SmallStrings.cpp	2019-02-07 05:39:12 UTC (rev 241116)
+++ trunk/Source/_javascript_Core/runtime/SmallStrings.cpp	2019-02-07 05:51:46 UTC (rev 241117)
@@ -52,28 +52,18 @@
 
 SmallStringsStorage::SmallStringsStorage()
 {
-    LChar* characterBuffer = 0;
-    auto baseString = StringImpl::createUninitialized(singleCharacterStringCount, characterBuffer);
     for (unsigned i = 0; i < singleCharacterStringCount; ++i) {
-        characterBuffer[i] = i;
-        m_reps[i] = AtomicStringImpl::add(StringImpl::createSubstringSharingImpl(baseString.get(), i, 1).ptr());
+        const LChar string[] = { static_cast<LChar>(i) };
+        m_reps[i] = AtomicStringImpl::add(StringImpl::create(string, 1).ptr());
     }
 }
 
 SmallStrings::SmallStrings()
-    : m_emptyString(0)
-#define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) , m_##name(0)
-    JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE)
-#undef JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE
-    , m_objectStringStart(nullptr)
-    , m_nullObjectString(nullptr)
-    , m_undefinedObjectString(nullptr)
-    , m_needsToBeVisited(true)
 {
     COMPILE_ASSERT(singleCharacterStringCount == sizeof(m_singleCharacterStrings) / sizeof(m_singleCharacterStrings[0]), IsNumCharactersConstInSyncWithClassUsage);
 
     for (unsigned i = 0; i < singleCharacterStringCount; ++i)
-        m_singleCharacterStrings[i] = 0;
+        m_singleCharacterStrings[i] = nullptr;
 }
 
 void SmallStrings::initializeCommonStrings(VM& vm)

Modified: trunk/Source/_javascript_Core/runtime/SmallStrings.h (241116 => 241117)


--- trunk/Source/_javascript_Core/runtime/SmallStrings.h	2019-02-07 05:39:12 UTC (rev 241116)
+++ trunk/Source/_javascript_Core/runtime/SmallStrings.h	2019-02-07 05:51:46 UTC (rev 241117)
@@ -131,16 +131,16 @@
 
     void initialize(VM*, JSString*&, const char* value);
 
-    JSString* m_emptyString;
-#define JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION(name) JSString* m_##name;
+    JSString* m_emptyString { nullptr };
+#define JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION(name) JSString* m_##name { nullptr };
     JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION)
 #undef JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION
-    JSString* m_objectStringStart;
-    JSString* m_nullObjectString;
-    JSString* m_undefinedObjectString;
-    JSString* m_singleCharacterStrings[singleCharacterStringCount];
+    JSString* m_objectStringStart { nullptr };
+    JSString* m_nullObjectString { nullptr };
+    JSString* m_undefinedObjectString { nullptr };
+    JSString* m_singleCharacterStrings[singleCharacterStringCount] { nullptr };
     std::unique_ptr<SmallStringsStorage> m_storage;
-    bool m_needsToBeVisited;
+    bool m_needsToBeVisited { true };
 };
 
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to