Changeset 167605 in webkit


Ignore:
Timestamp:
Apr 21, 2014 12:17:14 PM (10 years ago)
Author:
akling@apple.com
Message:

Move the JSString cache from DOMWrapperWorld to VM.
<https://webkit.org/b/131940>

Source/JavaScriptCore:
Reviewed by Geoff Garen.

  • runtime/VM.h:

Source/WebCore:
Since there's no need for JSStrings to be world-specific, this patch
moves the string cache to JSC::VM. This makes jsStringWithCache()
a lot faster since it no longer has to jump through twenty-eleven
hoops to find the DOMWrapperWorld.

Reviewed by Geoff Garen.

  • bindings/js/DOMWrapperWorld.cpp:

(WebCore::DOMWrapperWorld::clearWrappers):

  • bindings/js/DOMWrapperWorld.h:
  • bindings/js/JSDOMBinding.cpp:

(WebCore::jsStringWithCache):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r167600 r167605  
     12014-04-21  Andreas Kling  <akling@apple.com>
     2
     3        Move the JSString cache from DOMWrapperWorld to VM.
     4        <https://webkit.org/b/131940>
     5
     6        Reviewed by Geoff Garen.
     7
     8        * runtime/VM.h:
     9
    1102014-04-19  Filip Pizlo  <fpizlo@apple.com>
    211
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r166192 r167605  
    296296        DateInstanceCache dateInstanceCache;
    297297        WTF::SimpleStats machineCodeBytesPerBytecodeWordForBaselineJIT;
     298        WeakGCMap<StringImpl*, JSString, PtrHash<StringImpl*>> stringCache;
    298299
    299300        AtomicStringTable* atomicStringTable() const { return m_atomicStringTable; }
  • trunk/Source/WebCore/ChangeLog

    r167602 r167605  
     12014-04-21  Andreas Kling  <akling@apple.com>
     2
     3        Move the JSString cache from DOMWrapperWorld to VM.
     4        <https://webkit.org/b/131940>
     5
     6        Since there's no need for JSStrings to be world-specific, this patch
     7        moves the string cache to JSC::VM. This makes jsStringWithCache()
     8        a lot faster since it no longer has to jump through twenty-eleven
     9        hoops to find the DOMWrapperWorld.
     10
     11        Reviewed by Geoff Garen.
     12
     13        * bindings/js/DOMWrapperWorld.cpp:
     14        (WebCore::DOMWrapperWorld::clearWrappers):
     15        * bindings/js/DOMWrapperWorld.h:
     16        * bindings/js/JSDOMBinding.cpp:
     17        (WebCore::jsStringWithCache):
     18
    1192014-04-21  David Hyatt  <hyatt@apple.com>
    220
  • trunk/Source/WebCore/bindings/js/DOMWrapperWorld.cpp

    r165152 r167605  
    5454{
    5555    m_wrappers.clear();
    56     m_stringCache.clear();
    5756
    5857    // These items are created lazily.
  • trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h

    r165152 r167605  
    2424
    2525#include "JSDOMGlobalObject.h"
    26 #include <runtime/WeakGCMap.h>
    2726#include <wtf/Forward.h>
    2827
     
    3433
    3534typedef HashMap<void*, JSC::Weak<JSC::JSObject>> DOMObjectWrapperMap;
    36 typedef JSC::WeakGCMap<StringImpl*, JSC::JSString, PtrHash<StringImpl*>> JSStringCache;
    3735
    3836class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
     
    5250    // FIXME: can we make this private?
    5351    DOMObjectWrapperMap m_wrappers;
    54     JSStringCache m_stringCache;
    5552    HashMap<CSSValue*, void*> m_cssValueRoots;
    5653
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r167577 r167605  
    6666JSC::JSValue jsStringWithCache(JSC::ExecState* exec, const String& s)
    6767{
     68    JSC::VM& vm = exec->vm();
    6869    StringImpl* stringImpl = s.impl();
    6970    if (!stringImpl || !stringImpl->length())
    70         return jsEmptyString(exec);
     71        return jsEmptyString(&vm);
    7172
    7273    if (stringImpl->length() == 1) {
    7374        UChar singleCharacter = (*stringImpl)[0u];
    74         if (singleCharacter <= JSC::maxSingleCharacterString) {
    75             JSC::VM* vm = &exec->vm();
    76             return vm->smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
    77         }
    78     }
    79 
    80     JSStringCache& stringCache = currentWorld(exec).m_stringCache;
    81     JSStringCache::AddResult addResult = stringCache.add(stringImpl, nullptr);
     75        if (singleCharacter <= JSC::maxSingleCharacterString)
     76            return vm.smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
     77    }
     78
     79    auto addResult = vm.stringCache.add(stringImpl, nullptr);
    8280    if (addResult.isNewEntry)
    83         addResult.iterator->value = JSC::jsString(exec, String(stringImpl));
     81        addResult.iterator->value = JSC::jsString(&vm, String(stringImpl));
    8482    return JSC::JSValue(addResult.iterator->value.get());
    8583}
Note: See TracChangeset for help on using the changeset viewer.