Add fast mapping from StringImpl to JSString
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Feb 2014 03:21:47 +0000 (03:21 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Feb 2014 03:21:47 +0000 (03:21 +0000)
commit7ba8a790e28884c477e60d5d75d4a26f48f70642
tree154c0d17b0511e86afc097e7def23c6eb863e3ca
parentd297af1bcd84f0d4d362b4a48e5aab627f3d8320
Add fast mapping from StringImpl to JSString
https://bugs.webkit.org/show_bug.cgi?id=128625

Reviewed by Geoff Garen & Andreas Kling.

Source/JavaScriptCore:

* runtime/JSString.cpp:
(JSC::JSString::WeakOwner::finalize):
    - once the JSString weakly owned by a StringImpl becomed unreachable remove the WeakImpl.
* runtime/JSString.h:
(JSC::jsStringWithWeakOwner):
    - create a JSString wrapping a StringImpl, and weakly caches the JSString on the StringImpl.
* runtime/VM.cpp:
(JSC::VM::VM):
    - initialize jsStringWeakOwner.
(JSC::VM::createLeakedForMainThread):
    - initialize jsStringWeakOwner - the main thread gets to use the weak pointer
      on StringImpl to cache a JSString wrapper.
* runtime/VM.h:
    - renamed createLeaked -> createLeakedForMainThread to make it clear this
      should only be used to cretae the main thread VM.

Source/WebCore:

Removed JSStringCache from WebCore; call JSC::jsStringWithWeakOwner instead.

* bindings/js/DOMWrapperWorld.cpp:
(WebCore::DOMWrapperWorld::clearWrappers):
    - removed JSStringCache.
* bindings/js/DOMWrapperWorld.h:
    - removed JSStringCache.
* bindings/js/JSDOMBinding.h:
(WebCore::jsStringWithCache):
    - call jsStringWithWeakOwner insead of using JSStringCache.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::commonVM):
    - renamed createLeaked -> createLeakedForMainThread.
* bindings/scripts/StaticString.pm:
(GenerateStrings):
    - StringImpl has an additional field.

Source/WTF:

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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164347 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSString.cpp
Source/JavaScriptCore/runtime/JSString.h
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/DOMWrapperWorld.cpp
Source/WebCore/bindings/js/DOMWrapperWorld.h
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/scripts/StaticString.pm