Ignore:
Timestamp:
Feb 18, 2014, 7:21:47 PM (11 years ago)
Author:
[email protected]
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r163844 r164347  
    299299}
    300300
     301void JSString::WeakOwner::finalize(Handle<Unknown>, void* context)
     302{
     303    StringImpl* impl = static_cast<StringImpl*>(context);
     304    WeakSet::deallocate(impl->weakJSString());
     305    impl->setWeakJSString(nullptr);
     306}
     307
    301308} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.