VM::lastCachedString should be a Strong, not a Weak.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jul 2014 22:36:59 +0000 (22:36 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jul 2014 22:36:59 +0000 (22:36 +0000)
<https://webkit.org/b/134746>

Using Weak<JSString> for this regressed some of our bindings perf tests
due to Weak having to allocate a new WeakImpl every time the last cached
string changed. Make it a Strong instead should make that problem go away.

Reviewed by Geoffrey Garen.

* runtime/JSString.cpp:
(JSC::jsStringWithCacheSlowCase):
* runtime/VM.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170898 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSString.cpp
Source/JavaScriptCore/runtime/VM.h

index e09a949..655f6d9 100644 (file)
@@ -1,3 +1,18 @@
+2014-07-08  Andreas Kling  <akling@apple.com>
+
+        VM::lastCachedString should be a Strong, not a Weak.
+        <https://webkit.org/b/134746>
+
+        Using Weak<JSString> for this regressed some of our bindings perf tests
+        due to Weak having to allocate a new WeakImpl every time the last cached
+        string changed. Make it a Strong instead should make that problem go away.
+
+        Reviewed by Geoffrey Garen.
+
+        * runtime/JSString.cpp:
+        (JSC::jsStringWithCacheSlowCase):
+        * runtime/VM.h:
+
 2014-07-07  Benjamin Poulain  <bpoulain@apple.com>
 
         Fix the build after r170876
index cdc34d6..10a16d9 100644 (file)
@@ -29,6 +29,7 @@
 #include "JSCInlines.h"
 #include "StringObject.h"
 #include "StringPrototype.h"
+#include "StrongInlines.h"
 
 namespace JSC {
     
@@ -379,7 +380,7 @@ JSString* jsStringWithCacheSlowCase(VM& vm, StringImpl& stringImpl)
     auto addResult = vm.stringCache.add(&stringImpl, nullptr);
     if (addResult.isNewEntry)
         addResult.iterator->value = jsString(&vm, String(stringImpl));
-    vm.lastCachedString = addResult.iterator->value.get();
+    vm.lastCachedString.set(vm, addResult.iterator->value.get());
     return addResult.iterator->value.get();
 }
 
index 3251809..1f4d172 100644 (file)
@@ -297,7 +297,7 @@ namespace JSC {
         DateInstanceCache dateInstanceCache;
         WTF::SimpleStats machineCodeBytesPerBytecodeWordForBaselineJIT;
         WeakGCMap<StringImpl*, JSString, PtrHash<StringImpl*>> stringCache;
-        Weak<JSString> lastCachedString;
+        Strong<JSString> lastCachedString;
 
         AtomicStringTable* atomicStringTable() const { return m_atomicStringTable; }