Title: [165152] trunk/Source
Revision
165152
Author
[email protected]
Date
2014-03-05 17:46:21 -0800 (Wed, 05 Mar 2014)

Log Message

Source/_javascript_Core: https://bugs.webkit.org/show_bug.cgi?id=128625
Add fast mapping from StringImpl to JSString

Unreviewed roll-out.

Reverting r164347, r165054, r165066 - not clear the performance tradeoff was right.

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

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=128625
Add fast mapping from StringImpl to JSString

Unreviewed roll-out.

Reverting r164347, r165054, r165066 - not clear the performance tradeoff was right.

* bindings/js/DOMWrapperWorld.cpp:
(WebCore::DOMWrapperWorld::clearWrappers):
* bindings/js/DOMWrapperWorld.h:
* bindings/js/JSDOMBinding.h:
(WebCore::jsStringWithCache):
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::commonVM):
* bindings/scripts/StaticString.pm:
(GenerateStrings):

Source/WTF: [Win32][LLINT] Crash when running JSC stress tests.
https://bugs.webkit.org/show_bug.cgi?id=129429

Patch by [email protected] <[email protected]> on 2014-03-05
Reviewed by Geoffrey Garen.

* wtf/Platform.h: Enable LLINT on Win32.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (165151 => 165152)


--- trunk/Source/_javascript_Core/ChangeLog	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-03-06 01:46:21 UTC (rev 165152)
@@ -1,3 +1,18 @@
+2014-03-05  Gavin Barraclough  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=128625
+        Add fast mapping from StringImpl to JSString
+
+        Unreviewed roll-out.
+
+        Reverting r164347, r165054, r165066 - not clear the performance tradeoff was right.
+
+        * runtime/JSString.cpp:
+        * runtime/JSString.h:
+        * runtime/VM.cpp:
+        (JSC::VM::createLeaked):
+        * runtime/VM.h:
+
 2014-03-03  Oliver Hunt  <[email protected]>
 
         Support caching of custom setters

Modified: trunk/Source/_javascript_Core/runtime/JSString.cpp (165151 => 165152)


--- trunk/Source/_javascript_Core/runtime/JSString.cpp	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/_javascript_Core/runtime/JSString.cpp	2014-03-06 01:46:21 UTC (rev 165152)
@@ -298,11 +298,4 @@
     return false;
 }
 
-void JSString::WeakOwner::finalize(Handle<Unknown>, void* context)
-{
-    StringImpl* impl = static_cast<StringImpl*>(context);
-    WeakSet::deallocate(impl->weakJSString());
-    impl->setWeakJSString(nullptr);
-}
-
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSString.h (165151 => 165152)


--- trunk/Source/_javascript_Core/runtime/JSString.h	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/_javascript_Core/runtime/JSString.h	2014-03-06 01:46:21 UTC (rev 165152)
@@ -63,11 +63,6 @@
 
     class JSString : public JSCell {
     public:
-        class WeakOwner final : public WeakHandleOwner {
-        public:
-            virtual void finalize(Handle<Unknown>, void* context) override;
-        };
-
         friend class JIT;
         friend class VM;
         friend class SpecializedThunkJIT;
@@ -412,28 +407,6 @@
         return JSString::create(*vm, s.impl());
     }
 
-    inline JSString* jsStringWithWeakOwner(VM& vm, StringImpl& stringImpl)
-    {
-        WeakHandleOwner* jsStringWeakOwner = vm.jsStringWeakOwner.get();
-        ASSERT(stringImpl.length() > 0);
-
-        // If this VM is not allowed to weakly own strings just make a new JSString.
-        if (!jsStringWeakOwner)
-            return JSString::create(vm, &stringImpl);
-
-        // Check for an existing weakly owned JSString.
-        if (WeakImpl* weakImpl = stringImpl.weakJSString()) {
-            if (weakImpl->state() == WeakImpl::Live)
-                return asString(weakImpl->jsValue());
-            WeakSet::deallocate(weakImpl);
-            stringImpl.setWeakJSString(nullptr);
-        }
-
-        JSString* string = JSString::create(vm, &stringImpl);
-        stringImpl.setWeakJSString(WeakSet::allocate(string, jsStringWeakOwner, &stringImpl));
-        return string;
-    }
-
     inline JSString* jsSubstring(ExecState* exec, JSString* s, unsigned offset, unsigned length)
     {
         ASSERT(offset <= static_cast<unsigned>(s->length()));

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (165151 => 165152)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2014-03-06 01:46:21 UTC (rev 165152)
@@ -402,11 +402,9 @@
     return adoptRef(new VM(Default, heapType));
 }
 
-PassRefPtr<VM> VM::createLeakedForMainThread(HeapType heapType)
+PassRefPtr<VM> VM::createLeaked(HeapType heapType)
 {
-    VM* vm = new VM(Default, heapType);
-    vm->jsStringWeakOwner = adoptPtr(new JSString::WeakOwner);
-    return adoptRef(vm);
+    return create(heapType);
 }
 
 bool VM::sharedInstanceExists()

Modified: trunk/Source/_javascript_Core/runtime/VM.h (165151 => 165152)


--- trunk/Source/_javascript_Core/runtime/VM.h	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2014-03-06 01:46:21 UTC (rev 165152)
@@ -184,8 +184,8 @@
     class VM : public ThreadSafeRefCounted<VM> {
     public:
         // WebCore has a one-to-one mapping of threads to VMs;
-        // either create() or createLeakedForMainThread() should only be
-        // called once on a thread, this is the 'default' VM (it uses the
+        // either create() or createLeaked() should only be called once
+        // on a thread, this is the 'default' VM (it uses the
         // thread's default string uniquing table from wtfThreadData).
         // API contexts created using the new context group aware interface
         // create APIContextGroup objects which require less locking of JSC
@@ -203,7 +203,7 @@
         JS_EXPORT_PRIVATE static VM& sharedInstance();
 
         JS_EXPORT_PRIVATE static PassRefPtr<VM> create(HeapType = SmallHeap);
-        JS_EXPORT_PRIVATE static PassRefPtr<VM> createLeakedForMainThread(HeapType = SmallHeap);
+        JS_EXPORT_PRIVATE static PassRefPtr<VM> createLeaked(HeapType = SmallHeap);
         static PassRefPtr<VM> createContextGroup(HeapType = SmallHeap);
         JS_EXPORT_PRIVATE ~VM();
 
@@ -222,10 +222,7 @@
         // The heap should be just after executableAllocator and before other members to ensure that it's
         // destructed after all the objects that reference it.
         Heap heap;
-
-        // Used to manage weak references from StringImpls to JSStrings.
-        OwnPtr<WeakHandleOwner> jsStringWeakOwner;
-
+        
 #if ENABLE(DFG_JIT)
         OwnPtr<DFG::LongLivedState> dfgState;
 #endif // ENABLE(DFG_JIT)

Modified: trunk/Source/WTF/ChangeLog (165151 => 165152)


--- trunk/Source/WTF/ChangeLog	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WTF/ChangeLog	2014-03-06 01:46:21 UTC (rev 165152)
@@ -289,25 +289,6 @@
         * wtf/Platform.h: Changed to define WTF_PLATFORM_MAC only on when building for OS X (but
         still not when WTF_PLATFORM_GTK or WTF_PLATFORM_EFL are defined).
 
-2014-02-17  Gavin Barraclough  <[email protected]>
-
-        Add fast mapping from StringImpl to JSString
-        https://bugs.webkit.org/show_bug.cgi?id=128625
-
-        Reviewed by Geoff Garen & Andreas Kling.
-
-        Add weak pointer from StringImpl to JSString.
-
-        * wtf/text/StringImpl.cpp:
-        (WTF::StringImpl::~StringImpl):
-            - ASSERT m_weakJSString is null.
-        * wtf/text/StringImpl.h:
-        (WTF::StringImpl::StringImpl):
-            - initialize m_weakJSString.
-        (WTF::StringImpl::weakJSString):
-        (WTF::StringImpl::setWeakJSString):
-            - added acessors for m_weakJSString.
-
 2014-02-18  Joseph Pecoraro  <[email protected]>
 
         [iOS] Web Inspector: JSContext inspection crashes in isMainThread, uninitialized WebCoreWebThreadIsLockedOrDisabled

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (165151 => 165152)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2014-03-06 01:46:21 UTC (rev 165152)
@@ -44,7 +44,7 @@
 
 using namespace Unicode;
 
-COMPILE_ASSERT(sizeof(StringImpl) == 2 * sizeof(int) + 4 * sizeof(void*), StringImpl_should_stay_small);
+COMPILE_ASSERT(sizeof(StringImpl) == 2 * sizeof(int) + 3 * sizeof(void*), StringImpl_should_stay_small);
 
 #ifdef STRING_STATS
 StringStats StringImpl::m_stringStats;
@@ -110,7 +110,6 @@
 StringImpl::~StringImpl()
 {
     ASSERT(!isStatic());
-    ASSERT(!m_weakJSString);
 
     STRING_STATS_REMOVE_STRING(this);
 

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (165151 => 165152)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2014-03-06 01:46:21 UTC (rev 165152)
@@ -54,10 +54,6 @@
 struct IdentifierLCharFromUCharTranslator;
 }
 
-namespace JSC {
-    class WeakImpl;
-}
-
 namespace WTF {
 
 struct CStringTranslator;
@@ -166,7 +162,6 @@
         : m_refCount(s_refCountFlagIsStaticString)
         , m_length(length)
         , m_data16(characters)
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(s_hashFlagIsIdentifier | BufferOwned)
     {
         // Ensure that the hash is computed so that AtomicStringHash can call existingHash()
@@ -184,7 +179,6 @@
         : m_refCount(s_refCountFlagIsStaticString)
         , m_length(length)
         , m_data8(characters)
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(s_hashFlag8BitBuffer | s_hashFlagIsIdentifier | BufferOwned)
     {
         // Ensure that the hash is computed so that AtomicStringHash can call existingHash()
@@ -202,7 +196,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data8(tailPointer<LChar>())
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(s_hashFlag8BitBuffer | BufferInternal)
     {
         ASSERT(m_data8);
@@ -216,7 +209,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data16(tailPointer<UChar>())
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(BufferInternal)
     {
         ASSERT(m_data16);
@@ -230,7 +222,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data8(characters.leakPtr())
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(s_hashFlag8BitBuffer | BufferOwned)
     {
         ASSERT(m_data8);
@@ -244,7 +235,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data16(characters)
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(BufferInternal)
     {
         ASSERT(m_data16);
@@ -257,7 +247,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data8(characters)
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(s_hashFlag8BitBuffer | BufferInternal)
     {
         ASSERT(m_data8);
@@ -271,7 +260,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data16(characters.leakPtr())
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(BufferOwned)
     {
         ASSERT(m_data16);
@@ -285,7 +273,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data8(characters)
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(s_hashFlag8BitBuffer | BufferSubstring)
     {
         ASSERT(is8Bit());
@@ -303,7 +290,6 @@
         : m_refCount(s_refCountIncrement)
         , m_length(length)
         , m_data16(characters)
-        , m_weakJSString(nullptr)
         , m_hashAndFlags(BufferSubstring)
     {
         ASSERT(!is8Bit());
@@ -323,7 +309,6 @@
         // We expect m_length to be initialized to 0 as we use it
         // to represent a null terminated buffer.
         , m_data8(reinterpret_cast<const LChar*>(&m_length))
-        , m_weakJSString(nullptr)
     {
         ASSERT(m_data8);
         // Set the hash early, so that all empty unique StringImpls have a hash,
@@ -627,9 +612,6 @@
         m_refCount = tempRefCount;
     }
 
-    JSC::WeakImpl* weakJSString() { return m_weakJSString; }
-    void setWeakJSString(JSC::WeakImpl* weakJSString) { m_weakJSString = weakJSString; }
-
     WTF_EXPORT_PRIVATE static StringImpl* empty();
 
     // FIXME: Does this really belong in StringImpl?
@@ -869,7 +851,6 @@
         unsigned m_refCount;
         unsigned m_length;
         const LChar* m_data8;
-        JSC::WeakImpl* m_weakJSString;
         mutable UChar* m_copyData16;
         unsigned m_hashAndFlags;
 
@@ -895,7 +876,6 @@
         const LChar* m_data8;
         const UChar* m_data16;
     };
-    JSC::WeakImpl* m_weakJSString;
     mutable UChar* m_copyData16;
     mutable unsigned m_hashAndFlags;
 };

Modified: trunk/Source/WebCore/ChangeLog (165151 => 165152)


--- trunk/Source/WebCore/ChangeLog	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WebCore/ChangeLog	2014-03-06 01:46:21 UTC (rev 165152)
@@ -1,3 +1,22 @@
+2014-03-05  Gavin Barraclough  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=128625
+        Add fast mapping from StringImpl to JSString
+
+        Unreviewed roll-out.
+
+        Reverting r164347, r165054, r165066 - not clear the performance tradeoff was right.
+
+        * bindings/js/DOMWrapperWorld.cpp:
+        (WebCore::DOMWrapperWorld::clearWrappers):
+        * bindings/js/DOMWrapperWorld.h:
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::jsStringWithCache):
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::commonVM):
+        * bindings/scripts/StaticString.pm:
+        (GenerateStrings):
+
 2014-03-05  Daniel Bates  <[email protected]>
             And Alexey Proskuryakov  <[email protected]>
 

Modified: trunk/Source/WebCore/bindings/js/DOMWrapperWorld.cpp (165151 => 165152)


--- trunk/Source/WebCore/bindings/js/DOMWrapperWorld.cpp	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WebCore/bindings/js/DOMWrapperWorld.cpp	2014-03-06 01:46:21 UTC (rev 165152)
@@ -53,6 +53,7 @@
 void DOMWrapperWorld::clearWrappers()
 {
     m_wrappers.clear();
+    m_stringCache.clear();
 
     // These items are created lazily.
     while (!m_scriptControllersWithWindowShells.isEmpty())

Modified: trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h (165151 => 165152)


--- trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h	2014-03-06 01:46:21 UTC (rev 165152)
@@ -33,6 +33,7 @@
 class ScriptController;
 
 typedef HashMap<void*, JSC::Weak<JSC::JSObject>> DOMObjectWrapperMap;
+typedef JSC::WeakGCMap<StringImpl*, JSC::JSString, PtrHash<StringImpl*>> JSStringCache;
 
 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
 public:
@@ -50,6 +51,7 @@
 
     // FIXME: can we make this private?
     DOMObjectWrapperMap m_wrappers;
+    JSStringCache m_stringCache;
     HashMap<CSSValue*, void*> m_cssValueRoots;
 
     bool isNormal() const { return m_isNormal; }

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (165151 => 165152)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2014-03-06 01:46:21 UTC (rev 165152)
@@ -571,19 +571,23 @@
 
 inline JSC::JSValue jsStringWithCache(JSC::ExecState* exec, const String& s)
 {
-    JSC::VM& vm = exec->vm();
-
     StringImpl* stringImpl = s.impl();
     if (!stringImpl || !stringImpl->length())
-        return jsEmptyString(&vm);
+        return jsEmptyString(exec);
 
     if (stringImpl->length() == 1) {
         UChar singleCharacter = (*stringImpl)[0u];
-        if (singleCharacter <= JSC::maxSingleCharacterString)
-            return vm.smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
+        if (singleCharacter <= JSC::maxSingleCharacterString) {
+            JSC::VM* vm = &exec->vm();
+            return vm->smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
+        }
     }
 
-    return JSC::jsStringWithWeakOwner(vm, *stringImpl);
+    JSStringCache& stringCache = currentWorld(exec).m_stringCache;
+    JSStringCache::AddResult addResult = stringCache.add(stringImpl, nullptr);
+    if (addResult.isNewEntry)
+        addResult.iterator->value = JSC::jsString(exec, String(stringImpl));
+    return JSC::JSValue(addResult.iterator->value.get());
 }
 
 inline String propertyNameToString(JSC::PropertyName propertyName)

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (165151 => 165152)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2014-03-06 01:46:21 UTC (rev 165152)
@@ -215,7 +215,7 @@
 #endif
     if (!vm) {
         ScriptController::initializeThreading();
-        vm = VM::createLeakedForMainThread(LargeHeap).leakRef();
+        vm = VM::createLeaked(LargeHeap).leakRef();
 #if PLATFORM(IOS)
         PassOwnPtr<WebSafeGCActivityCallback> activityCallback = WebSafeGCActivityCallback::create(&vm->heap);
         vm->heap.setActivityCallback(activityCallback);

Modified: trunk/Source/WebCore/bindings/scripts/StaticString.pm (165151 => 165152)


--- trunk/Source/WebCore/bindings/scripts/StaticString.pm	2014-03-06 01:37:15 UTC (rev 165151)
+++ trunk/Source/WebCore/bindings/scripts/StaticString.pm	2014-03-06 01:46:21 UTC (rev 165152)
@@ -48,7 +48,6 @@
     $length,
     ${name}String8,
     0,
-    nullptr,
     StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift)
 };
 END
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to