Title: [151864] branches/dfgFourthTier
Revision
151864
Author
[email protected]
Date
2013-06-21 16:05:28 -0700 (Fri, 21 Jun 2013)

Log Message

fourthTier: Small strings shouldn't get GC'd
https://bugs.webkit.org/show_bug.cgi?id=117897

Source/_javascript_Core: 

Reviewed by Mark Hahnenberg.
        
Kill off the code needed to allocate them lazily and finalize them.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileGetByValOnString):
* heap/Heap.cpp:
(JSC::Heap::collect):
* runtime/JSString.h:
(JSC::jsSingleCharacterString):
(JSC::jsSingleCharacterSubstring):
(JSC::jsString):
(JSC::jsSubstring8):
(JSC::jsSubstring):
(JSC::jsOwnedString):
* runtime/NumberPrototype.cpp:
(JSC::integerValueToString):
* runtime/SmallStrings.cpp:
(JSC):
(JSC::SmallStrings::initializeCommonStrings):
(JSC::SmallStrings::visitStrongReferences):
* runtime/SmallStrings.h:
(JSC::SmallStrings::singleCharacterString):
(SmallStrings):

LayoutTests: 

Reviewed by Mark Hahnenberg.
        
This test speeds up by 5%.

* fast/js/regress/script-tests/string-get-by-val.js: Added.
(foo):
* fast/js/regress/string-get-by-val-expected.txt: Added.
* fast/js/regress/string-get-by-val.html: Added.

Modified Paths

Added Paths

Diff

Modified: branches/dfgFourthTier/LayoutTests/ChangeLog (151863 => 151864)


--- branches/dfgFourthTier/LayoutTests/ChangeLog	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/LayoutTests/ChangeLog	2013-06-21 23:05:28 UTC (rev 151864)
@@ -1,3 +1,17 @@
+2013-06-21  Filip Pizlo  <[email protected]>
+
+        fourthTier: Small strings shouldn't get GC'd
+        https://bugs.webkit.org/show_bug.cgi?id=117897
+
+        Reviewed by Mark Hahnenberg.
+        
+        This test speeds up by 5%.
+
+        * fast/js/regress/script-tests/string-get-by-val.js: Added.
+        (foo):
+        * fast/js/regress/string-get-by-val-expected.txt: Added.
+        * fast/js/regress/string-get-by-val.html: Added.
+
 2013-06-18  Filip Pizlo  <[email protected]>
 
         fourthTier: DFG should have switch_char

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/string-get-by-val.js (0 => 151864)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/string-get-by-val.js	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/string-get-by-val.js	2013-06-21 23:05:28 UTC (rev 151864)
@@ -0,0 +1,10 @@
+function foo(string) {
+    var result;
+    for (var i = 0; i < 1000000; ++i)
+        result = string[0];
+    return result;
+}
+
+var result = foo("x");
+if (result != "x")
+    throw "Bad result: " + result;

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/string-get-by-val-expected.txt (0 => 151864)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/string-get-by-val-expected.txt	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/string-get-by-val-expected.txt	2013-06-21 23:05:28 UTC (rev 151864)
@@ -0,0 +1,10 @@
+JSRegress/string-get-by-val
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/string-get-by-val.html (0 => 151864)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/string-get-by-val.html	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/string-get-by-val.html	2013-06-21 23:05:28 UTC (rev 151864)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-06-21 23:05:28 UTC (rev 151864)
@@ -1,5 +1,35 @@
 2013-06-21  Filip Pizlo  <[email protected]>
 
+        fourthTier: Small strings shouldn't get GC'd
+        https://bugs.webkit.org/show_bug.cgi?id=117897
+
+        Reviewed by Mark Hahnenberg.
+        
+        Kill off the code needed to allocate them lazily and finalize them.
+
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileGetByValOnString):
+        * heap/Heap.cpp:
+        (JSC::Heap::collect):
+        * runtime/JSString.h:
+        (JSC::jsSingleCharacterString):
+        (JSC::jsSingleCharacterSubstring):
+        (JSC::jsString):
+        (JSC::jsSubstring8):
+        (JSC::jsSubstring):
+        (JSC::jsOwnedString):
+        * runtime/NumberPrototype.cpp:
+        (JSC::integerValueToString):
+        * runtime/SmallStrings.cpp:
+        (JSC):
+        (JSC::SmallStrings::initializeCommonStrings):
+        (JSC::SmallStrings::visitStrongReferences):
+        * runtime/SmallStrings.h:
+        (JSC::SmallStrings::singleCharacterString):
+        (SmallStrings):
+
+2013-06-21  Filip Pizlo  <[email protected]>
+
         fourthTier: Merge r146932 and 146933 so that we can profile from DumpRenderTree
         https://bugs.webkit.org/show_bug.cgi?id=117891
 

Modified: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2013-06-21 23:05:28 UTC (rev 151864)
@@ -2072,7 +2072,6 @@
     GPRReg smallStringsReg = smallStrings.gpr();
     m_jit.move(MacroAssembler::TrustedImmPtr(m_jit.vm()->smallStrings.singleCharacterStrings()), smallStringsReg);
     m_jit.loadPtr(MacroAssembler::BaseIndex(smallStringsReg, scratchReg, MacroAssembler::ScalePtr, 0), scratchReg);
-    speculationCheck(Uncountable, JSValueRegs(), 0, m_jit.branchTest32(MacroAssembler::Zero, scratchReg));
     cellResult(scratchReg, m_currentNode);
 }
 

Modified: branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.cpp (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.cpp	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/heap/Heap.cpp	2013-06-21 23:05:28 UTC (rev 151864)
@@ -752,11 +752,6 @@
     }
 
     {
-        GCPHASE(finalizeSmallStrings);
-        m_vm->smallStrings.finalizeSmallStrings();
-    }
-
-    {
         GCPHASE(DeleteCodeBlocks);
         deleteUnmarkedCompiledCode();
     }

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/JSString.h (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/JSString.h	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/JSString.h	2013-06-21 23:05:28 UTC (rev 151864)
@@ -345,7 +345,7 @@
     ALWAYS_INLINE JSString* jsSingleCharacterString(VM* vm, UChar c)
     {
         if (c <= maxSingleCharacterString)
-            return vm->smallStrings.singleCharacterString(vm, c);
+            return vm->smallStrings.singleCharacterString(c);
         return JSString::create(*vm, String(&c, 1).impl());
     }
 
@@ -355,7 +355,7 @@
         ASSERT(offset < static_cast<unsigned>(s.length()));
         UChar c = s.characterAt(offset);
         if (c <= maxSingleCharacterString)
-            return vm->smallStrings.singleCharacterString(vm, c);
+            return vm->smallStrings.singleCharacterString(c);
         return JSString::create(*vm, StringImpl::create(s.impl(), offset, 1));
     }
 
@@ -401,7 +401,7 @@
         if (size == 1) {
             UChar c = s.characterAt(0);
             if (c <= maxSingleCharacterString)
-                return vm->smallStrings.singleCharacterString(vm, c);
+                return vm->smallStrings.singleCharacterString(c);
         }
         return JSString::create(*vm, s.impl());
     }
@@ -427,7 +427,7 @@
         if (length == 1) {
             UChar c = s.characterAt(offset);
             if (c <= maxSingleCharacterString)
-                return vm->smallStrings.singleCharacterString(vm, c);
+                return vm->smallStrings.singleCharacterString(c);
         }
         return JSString::createHasOtherOwner(*vm, StringImpl::create8(s.impl(), offset, length));
     }
@@ -442,7 +442,7 @@
         if (length == 1) {
             UChar c = s.characterAt(offset);
             if (c <= maxSingleCharacterString)
-                return vm->smallStrings.singleCharacterString(vm, c);
+                return vm->smallStrings.singleCharacterString(c);
         }
         return JSString::createHasOtherOwner(*vm, StringImpl::create(s.impl(), offset, length));
     }
@@ -455,7 +455,7 @@
         if (size == 1) {
             UChar c = s.characterAt(0);
             if (c <= maxSingleCharacterString)
-                return vm->smallStrings.singleCharacterString(vm, c);
+                return vm->smallStrings.singleCharacterString(c);
         }
         return JSString::createHasOtherOwner(*vm, s.impl());
     }

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/NumberPrototype.cpp (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/NumberPrototype.cpp	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/NumberPrototype.cpp	2013-06-21 23:05:28 UTC (rev 151864)
@@ -476,7 +476,7 @@
         ASSERT(value <= 36);
         ASSERT(value >= 0);
         VM* vm = &exec->vm();
-        return JSValue::encode(vm->smallStrings.singleCharacterString(vm, radixDigits[value]));
+        return JSValue::encode(vm->smallStrings.singleCharacterString(radixDigits[value]));
     }
 
     if (radix == 10) {

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/SmallStrings.cpp (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/SmallStrings.cpp	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/SmallStrings.cpp	2013-06-21 23:05:28 UTC (rev 151864)
@@ -36,13 +36,6 @@
 
 namespace JSC {
 
-static inline void finalize(JSString*& string)
-{
-    if (!string || Heap::isMarked(string))
-        return;
-    string = 0;
-}
-
 class SmallStringsStorage {
     WTF_MAKE_NONCOPYABLE(SmallStringsStorage); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -84,6 +77,8 @@
 void SmallStrings::initializeCommonStrings(VM& vm)
 {
     createEmptyString(&vm);
+    for (unsigned i = 0; i <= maxSingleCharacterString; ++i)
+        createSingleCharacterString(&vm, i);
 #define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) initialize(&vm, m_##name, #name);
     JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE)
 #undef JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE
@@ -92,6 +87,8 @@
 void SmallStrings::visitStrongReferences(SlotVisitor& visitor)
 {
     visitor.appendUnbarrieredPointer(&m_emptyString);
+    for (unsigned i = 0; i <= maxSingleCharacterString; ++i)
+        visitor.appendUnbarrieredPointer(m_singleCharacterStrings + i);
 #define JSC_COMMON_STRINGS_ATTRIBUTE_VISIT(name) visitor.appendUnbarrieredPointer(&m_##name);
     JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_VISIT)
 #undef JSC_COMMON_STRINGS_ATTRIBUTE_VISIT
@@ -101,13 +98,6 @@
 {
 }
 
-void SmallStrings::finalizeSmallStrings()
-{
-    finalize(m_emptyString);
-    for (unsigned i = 0; i < singleCharacterStringCount; ++i)
-        finalize(m_singleCharacterStrings[i]);
-}
-
 void SmallStrings::createEmptyString(VM* vm)
 {
     ASSERT(!m_emptyString);

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/SmallStrings.h (151863 => 151864)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/SmallStrings.h	2013-06-21 22:50:01 UTC (rev 151863)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/SmallStrings.h	2013-06-21 23:05:28 UTC (rev 151864)
@@ -68,17 +68,13 @@
             return m_emptyString;
         }
 
-        JSString* singleCharacterString(VM* vm, unsigned char character)
+        JSString* singleCharacterString(unsigned char character)
         {
-            if (!m_singleCharacterStrings[character])
-                createSingleCharacterString(vm, character);
             return m_singleCharacterStrings[character];
         }
 
         JS_EXPORT_PRIVATE WTF::StringImpl* singleCharacterStringRep(unsigned char character);
 
-        void finalizeSmallStrings();
-
         JSString** singleCharacterStrings() { return &m_singleCharacterStrings[0]; }
 
         void initializeCommonStrings(VM&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to