Add fast mapping from StringImpl to JSString
https://bugs.webkit.org/show_bug.cgi?id=128625
Reviewed by Geoff Garen & Andreas Kling.
Source/JavaScriptCore:
(JSC::JSString::WeakOwner::finalize):
- once the JSString weakly owned by a StringImpl becomed unreachable remove the WeakImpl.
(JSC::jsStringWithWeakOwner):
- create a JSString wrapping a StringImpl, and weakly caches the JSString on the StringImpl.
(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):
- bindings/js/DOMWrapperWorld.h:
- 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::StringImpl::~StringImpl):
- ASSERT m_weakJSString is null.
(WTF::StringImpl::StringImpl):
- initialize m_weakJSString.
(WTF::StringImpl::weakJSString):
(WTF::StringImpl::setWeakJSString):
- added acessors for m_weakJSString.