Skip to content
Permalink
Browse files
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):

Canonical link: https://commits.webkit.org/150025@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167605 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Apr 21, 2014
1 parent d650c16 commit 07c8968fc48d75c2b6596ebc01f57e53ba0ff7e3
@@ -1,3 +1,12 @@
2014-04-21 Andreas Kling <akling@apple.com>

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

Reviewed by Geoff Garen.

* runtime/VM.h:

2014-04-19 Filip Pizlo <fpizlo@apple.com>

Take block execution count estimates into account when voting double
@@ -295,6 +295,7 @@ namespace JSC {
NumericStrings numericStrings;
DateInstanceCache dateInstanceCache;
WTF::SimpleStats machineCodeBytesPerBytecodeWordForBaselineJIT;
WeakGCMap<StringImpl*, JSString, PtrHash<StringImpl*>> stringCache;

AtomicStringTable* atomicStringTable() const { return m_atomicStringTable; }

@@ -1,3 +1,21 @@
2014-04-21 Andreas Kling <akling@apple.com>

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

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):

2014-04-21 David Hyatt <hyatt@apple.com>

[New Multicolumn] Column balancing is slow on float-multicol.html
@@ -53,7 +53,6 @@ DOMWrapperWorld::~DOMWrapperWorld()
void DOMWrapperWorld::clearWrappers()
{
m_wrappers.clear();
m_stringCache.clear();

// These items are created lazily.
while (!m_scriptControllersWithWindowShells.isEmpty())
@@ -23,7 +23,6 @@
#define DOMWrapperWorld_h

#include "JSDOMGlobalObject.h"
#include <runtime/WeakGCMap.h>
#include <wtf/Forward.h>

namespace WebCore {
@@ -33,7 +32,6 @@ class JSDOMWrapper;
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:
@@ -51,7 +49,6 @@ class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {

// FIXME: can we make this private?
DOMObjectWrapperMap m_wrappers;
JSStringCache m_stringCache;
HashMap<CSSValue*, void*> m_cssValueRoots;

bool isNormal() const { return m_isNormal; }
@@ -65,22 +65,20 @@ const JSC::HashTable& getHashTableForGlobalData(VM& vm, const JSC::HashTable& st

JSC::JSValue jsStringWithCache(JSC::ExecState* exec, const String& s)
{
JSC::VM& vm = exec->vm();
StringImpl* stringImpl = s.impl();
if (!stringImpl || !stringImpl->length())
return jsEmptyString(exec);
return jsEmptyString(&vm);

if (stringImpl->length() == 1) {
UChar singleCharacter = (*stringImpl)[0u];
if (singleCharacter <= JSC::maxSingleCharacterString) {
JSC::VM* vm = &exec->vm();
return vm->smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
}
if (singleCharacter <= JSC::maxSingleCharacterString)
return vm.smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
}

JSStringCache& stringCache = currentWorld(exec).m_stringCache;
JSStringCache::AddResult addResult = stringCache.add(stringImpl, nullptr);
auto addResult = vm.stringCache.add(stringImpl, nullptr);
if (addResult.isNewEntry)
addResult.iterator->value = JSC::jsString(exec, String(stringImpl));
addResult.iterator->value = JSC::jsString(&vm, String(stringImpl));
return JSC::JSValue(addResult.iterator->value.get());
}

0 comments on commit 07c8968

Please sign in to comment.