[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
mjs at apple.com
mjs at apple.com
Fri Feb 26 22:26:59 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 6ab3c68c6430c6345c829bda95a395d6b8c03f99
Author: mjs at apple.com <mjs at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Feb 22 09:28:30 2010 +0000
2010-02-21 Maciej Stachowiak <mjs at apple.com>
Reviewed by Darin Adler.
Cache JavaScript wrappers inline in DOM nodes
https://bugs.webkit.org/show_bug.cgi?id=35226
<rdar://problem/7664202>
8.8% speedup on Dromaeo DOM Core tests.
3.3% speedup on Hixie DOM Core tests.
* bindings/js/JSDOMBinding.cpp:
(WebCore::forgetDOMNode): Clear wrapper pointer.
(WebCore::cacheDOMNodeWrapper): Cache inline too if caching for normal world.
* bindings/js/JSDOMBinding.h:
(WebCore::DOMObjectWrapperMapFor):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::toJS): Remove unneeded argument from getCachedDOMNodeWrapper.
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline): Renamed version of original createWrapper.
(WebCore::createWrapper): Call createWrapperInline. Out-of-line version.
(WebCore::toJSNewlyCreated): Call createWrapperInline instead of createWrapper.
* bindings/js/JSNodeCustom.h: Added.
(WebCore::getCachedDOMNodeWrapper): Moved here so it can be inlined.
(WebCore::toJS): Moved here so it can be inlined.
* bindings/js/ScriptWrappable.h:
(WebCore::ScriptWrappable::ScriptWrappable): Implement this in the obvious
way for JavaScriptCore.
(WebCore::ScriptWrappable::wrapper):
(WebCore::ScriptWrappable::setWrapper):
(WebCore::ScriptWrappable::clearWrapper):
* bindings/scripts/CodeGeneratorJS.pm: Include CustomHeader heaaders
in the header, not just the impl file, so they can add inlining.
* dom/Node.idl: Add CustomHeader directive.
Add new files to build.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55074 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fe87ec6..de8055f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-02-21 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by Darin Adler.
+
+ Cache JavaScript wrappers inline in DOM nodes
+ https://bugs.webkit.org/show_bug.cgi?id=35226
+ <rdar://problem/7664202>
+
+ 8.8% speedup on Dromaeo DOM Core tests.
+ 3.3% speedup on Hixie DOM Core tests.
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::forgetDOMNode): Clear wrapper pointer.
+ (WebCore::cacheDOMNodeWrapper): Cache inline too if caching for normal world.
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::DOMObjectWrapperMapFor):
+ * bindings/js/JSDocumentCustom.cpp:
+ (WebCore::toJS): Remove unneeded argument from getCachedDOMNodeWrapper.
+ * bindings/js/JSNodeCustom.cpp:
+ (WebCore::createWrapperInline): Renamed version of original createWrapper.
+ (WebCore::createWrapper): Call createWrapperInline. Out-of-line version.
+ (WebCore::toJSNewlyCreated): Call createWrapperInline instead of createWrapper.
+ * bindings/js/JSNodeCustom.h: Added.
+ (WebCore::getCachedDOMNodeWrapper): Moved here so it can be inlined.
+ (WebCore::toJS): Moved here so it can be inlined.
+ * bindings/js/ScriptWrappable.h:
+ (WebCore::ScriptWrappable::ScriptWrappable): Implement this in the obvious
+ way for JavaScriptCore.
+ (WebCore::ScriptWrappable::wrapper):
+ (WebCore::ScriptWrappable::setWrapper):
+ (WebCore::ScriptWrappable::clearWrapper):
+ * bindings/scripts/CodeGeneratorJS.pm: Include CustomHeader heaaders
+ in the header, not just the impl file, so they can add inlining.
+ * dom/Node.idl: Add CustomHeader directive.
+
+ Add new files to build.
+
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+
2010-02-22 Pavel Feldman <pfeldman at chromium.org>
Not reviewed: windows build fix.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 3aecf9b..e28e348 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -437,6 +437,7 @@ webcore_sources += \
WebCore/bindings/js/JSNamedNodeMapCustom.cpp \
WebCore/bindings/js/JSNavigatorCustom.cpp \
WebCore/bindings/js/JSNodeCustom.cpp \
+ WebCore/bindings/js/JSNodeCustom.h \
WebCore/bindings/js/JSNodeFilterCondition.cpp \
WebCore/bindings/js/JSNodeFilterCondition.h \
WebCore/bindings/js/JSNodeFilterCustom.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 6fe815c..d6f2f5e 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -568,6 +568,7 @@
'bindings/js/JSNamedNodesCollection.h',
'bindings/js/JSNavigatorCustom.cpp',
'bindings/js/JSNodeCustom.cpp',
+ 'bindings/js/JSNodeCustom.h',
'bindings/js/JSNodeFilterCondition.cpp',
'bindings/js/JSNodeFilterCondition.h',
'bindings/js/JSNodeFilterCustom.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 2e8e47e..badef2e 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1018,6 +1018,7 @@ HEADERS += \
bindings/js/JSLazyEventListener.h \
bindings/js/JSLocationCustom.h \
bindings/js/JSMessageChannelConstructor.h \
+ bindings/js/JSNodeCustom.h \
bindings/js/JSNodeFilterCondition.h \
bindings/js/JSOptionConstructor.h \
bindings/js/JSPluginElementFunctions.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 44ea351..20eaa75 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -38080,6 +38080,10 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\bindings\js\JSNodeCustom.h"
+ >
+ </File>
+ <File
RelativePath="..\bindings\js\JSNodeFilterCondition.cpp"
>
<FileConfiguration
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index abba405..0efee81 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -221,11 +221,6 @@ const JSC::HashTable* getHashTableForGlobalData(JSGlobalData& globalData, const
return DOMObjectHashTableMap::mapFor(globalData).get(staticTable);
}
-static inline DOMObjectWrapperMap& DOMObjectWrapperMapFor(JSC::ExecState* exec)
-{
- return currentWorld(exec)->m_wrappers;
-}
-
bool hasCachedDOMObjectWrapperUnchecked(JSGlobalData* globalData, void* objectHandle)
{
for (JSGlobalDataWorldIterator worldIter(globalData); worldIter; ++worldIter) {
@@ -246,13 +241,13 @@ bool hasCachedDOMObjectWrapper(JSGlobalData* globalData, void* objectHandle)
DOMObject* getCachedDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle)
{
- return DOMObjectWrapperMapFor(exec).get(objectHandle);
+ return domObjectWrapperMapFor(exec).get(objectHandle);
}
void cacheDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle, DOMObject* wrapper)
{
willCacheWrapper(wrapper);
- DOMObjectWrapperMapFor(exec).set(objectHandle, wrapper);
+ domObjectWrapperMapFor(exec).set(objectHandle, wrapper);
}
bool hasCachedDOMNodeWrapperUnchecked(Document* document, Node* node)
@@ -268,13 +263,6 @@ bool hasCachedDOMNodeWrapperUnchecked(Document* document, Node* node)
return false;
}
-JSNode* getCachedDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node)
-{
- if (document)
- return document->getWrapperCache(currentWorld(exec))->get(node);
- return static_cast<JSNode*>(DOMObjectWrapperMapFor(exec).get(node));
-}
-
void forgetDOMObject(DOMObject* wrapper, void* objectHandle)
{
JSC::JSGlobalData* globalData = Heap::heap(wrapper)->globalData();
@@ -303,6 +291,9 @@ void forgetDOMNode(JSNode* wrapper, Node* node, Document* document)
forgetDOMObject(wrapper, node);
return;
}
+
+ if (node->wrapper() == wrapper)
+ node->clearWrapper();
// We can't guarantee that a wrapper is in the cache when it uncaches itself,
// since a new wrapper may be cached before the old wrapper's destructor runs.
@@ -316,13 +307,15 @@ void forgetDOMNode(JSNode* wrapper, Node* node, Document* document)
void cacheDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node, JSNode* wrapper)
{
- if (!document) {
- willCacheWrapper(wrapper);
- DOMObjectWrapperMapFor(exec).set(node, wrapper);
- return;
- }
willCacheWrapper(wrapper);
- document->getWrapperCache(currentWorld(exec))->set(node, wrapper);
+
+ if (!document)
+ domObjectWrapperMapFor(exec).set(node, wrapper);
+ else
+ document->getWrapperCache(currentWorld(exec))->set(node, wrapper);
+
+ if (currentWorld(exec)->isNormal())
+ node->setWrapper(wrapper);
}
void forgetAllDOMNodesForDocument(Document* document)
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 807bf82..720888d 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -235,7 +235,7 @@ namespace WebCore {
void forgetDOMNode(JSNode* wrapper, Node* node, Document* document);
void forgetDOMObject(DOMObject* wrapper, void* objectHandle);
- JSNode* getCachedDOMNodeWrapper(JSC::ExecState*, Document*, Node*);
+ JSNode* getCachedDOMNodeWrapper(JSC::ExecState*, Node*);
void cacheDOMNodeWrapper(JSC::ExecState*, Document*, Node*, JSNode* wrapper);
void forgetAllDOMNodesForDocument(Document*);
void forgetWorldOfDOMNodesForDocument(Document*, DOMWrapperWorld*);
@@ -446,6 +446,11 @@ namespace WebCore {
return jsStringSlowCase(exec, stringCache, stringImpl);
}
+ inline DOMObjectWrapperMap& domObjectWrapperMapFor(JSC::ExecState* exec)
+ {
+ return currentWorld(exec)->m_wrappers;
+ }
+
} // namespace WebCore
#endif // JSDOMBinding_h
diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp
index eda153e..6942f03 100644
--- a/WebCore/bindings/js/JSDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSDocumentCustom.cpp
@@ -96,7 +96,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* documen
if (!document)
return jsNull();
- DOMObject* wrapper = getCachedDOMNodeWrapper(exec, document, document);
+ DOMObject* wrapper = getCachedDOMNodeWrapper(exec, document);
if (wrapper)
return wrapper;
diff --git a/WebCore/bindings/js/JSNodeCustom.cpp b/WebCore/bindings/js/JSNodeCustom.cpp
index 46a30a4..134c581 100644
--- a/WebCore/bindings/js/JSNodeCustom.cpp
+++ b/WebCore/bindings/js/JSNodeCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -172,7 +172,7 @@ void JSNode::markChildren(MarkStack& markStack)
markDOMNodeWrapper(markStack, m_impl->document(), nodeToMark);
}
-static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+static ALWAYS_INLINE JSValue createWrapperInline(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
ASSERT(node);
ASSERT(!getCachedDOMNodeWrapper(exec, node->document(), node));
@@ -228,25 +228,18 @@ static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* g
return wrapper;
}
-
-JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+
+JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
- if (!node)
- return jsNull();
-
- return createWrapper(exec, globalObject, node);
+ return createWrapperInline(exec, globalObject, node);
}
-JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
{
if (!node)
return jsNull();
-
- JSNode* wrapper = getCachedDOMNodeWrapper(exec, node->document(), node);
- if (wrapper)
- return wrapper;
-
- return createWrapper(exec, globalObject, node);
+
+ return createWrapperInline(exec, globalObject, node);
}
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSNodeCustom.h b/WebCore/bindings/js/JSNodeCustom.h
new file mode 100644
index 0000000..2534692
--- /dev/null
+++ b/WebCore/bindings/js/JSNodeCustom.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSNodeCustom_h
+#define JSNodeCustom_h
+
+#include "JSDOMBinding.h"
+#include <wtf/AlwaysInline.h>
+
+namespace WebCore {
+
+inline JSNode* getCachedDOMNodeWrapper(JSC::ExecState* exec, Node* node)
+{
+ if (currentWorld(exec)->isNormal())
+ return static_cast<JSNode*>(node->wrapper());
+ return static_cast<JSNode*>(domObjectWrapperMapFor(exec).get(node));
+}
+
+JSC::JSValue createWrapper(JSC::ExecState*, JSDOMGlobalObject*, Node*);
+
+inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
+{
+ if (!node)
+ return JSC::jsNull();
+
+ JSNode* wrapper = getCachedDOMNodeWrapper(exec, node);
+ if (wrapper)
+ return wrapper;
+
+ return createWrapper(exec, globalObject, node);
+}
+
+}
+
+#endif // JSDOMNodeCustom_h
diff --git a/WebCore/bindings/js/ScriptWrappable.h b/WebCore/bindings/js/ScriptWrappable.h
index d70cab7..7950cf3 100644
--- a/WebCore/bindings/js/ScriptWrappable.h
+++ b/WebCore/bindings/js/ScriptWrappable.h
@@ -33,9 +33,27 @@
namespace WebCore {
+class DOMObject;
+
class ScriptWrappable {
public:
- ScriptWrappable() { }
+ ScriptWrappable() : m_wrapper() { }
+
+ DOMObject* wrapper() const
+ {
+ return m_wrapper;
+ }
+
+ void setWrapper(DOMObject* wrapper)
+ {
+ ASSERT(wrapper);
+ m_wrapper = wrapper;
+ }
+
+ void clearWrapper() { m_wrapper = 0; }
+
+private:
+ DOMObject* m_wrapper;
};
} // namespace WebCore
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 94fc2b8..ece6df2 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -32,6 +32,7 @@ my $writeDependencies = 0;
my @headerContentHeader = ();
my @headerContent = ();
my %headerIncludes = ();
+my %headerTrailingIncludes = ();
my @implContentHeader = ();
my @implContent = ();
@@ -551,7 +552,9 @@ sub GenerateHeader
# Prototype
push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"});
- $implIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"} || $dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"};
+ $headerTrailingIncludes{"${className}Custom.h"} = 1 if $dataNode->extendedAttributes->{"CustomHeader"};
+
+ $implIncludes{"${className}Custom.h"} = 1 if !$dataNode->extendedAttributes->{"CustomHeader"} && ($dataNode->extendedAttributes->{"CustomPutFunction"} || $dataNode->extendedAttributes->{"DelegatingPutFunction"});
my $hasGetter = $numAttributes > 0
|| !($dataNode->extendedAttributes->{"OmitConstructor"}
@@ -2246,12 +2249,23 @@ sub WriteData
}
print $HEADER @headerContent;
+
+ @includes = ();
+ foreach my $include (keys %headerTrailingIncludes) {
+ $include = "\"$include\"" unless $include =~ /^["<]/; # "
+ push @includes, $include;
+ }
+ foreach my $include (sort @includes) {
+ print $HEADER "#include $include\n";
+ }
+
close($HEADER);
undef($HEADER);
@headerContentHeader = ();
@headerContent = ();
%headerIncludes = ();
+ %headerTrailingIncludes = ();
}
if (defined($DEPS)) {
diff --git a/WebCore/dom/Node.idl b/WebCore/dom/Node.idl
index c6cd4b9..a2b2455 100644
--- a/WebCore/dom/Node.idl
+++ b/WebCore/dom/Node.idl
@@ -21,6 +21,7 @@
module core {
interface [
+ CustomHeader,
CustomMarkFunction,
CustomPushEventHandlerScope,
CustomToJS,
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list