Title: [107367] trunk/Source/WebCore
- Revision
- 107367
- Author
- [email protected]
- Date
- 2012-02-09 23:09:50 -0800 (Thu, 09 Feb 2012)
Log Message
Dromaeo/dom-traverse.html should go fast
https://bugs.webkit.org/show_bug.cgi?id=78307
Reviewed by Eric Seidel.
This patch improves Dromaeo/dom-traverse.html by roughly 2.5% by
removing a branch. Previously, we null-checked the result of
V8DOMWrapper::getWrapper in a hot code path, but the only case where we
return a non-empty wrapper comes from a cold code path. By pushing the
null check into the cold codepath, we eliminate the branch from the
hot code path.
This patch also annotates the branches in the hot code path with their
likely outcome. I didn't measure a statistically significant
improvement with that aspect of the change, but it seems worthwhile.
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::getExistingWrapperInline):
(WebCore):
(WebCore::V8DOMWrapper::getExistingWrapperSlow):
(WebCore::V8DOMWrapper::getWrapperSlow):
* bindings/v8/V8DOMWrapper.h:
(WebCore::V8DOMWrapper::getExistingWrapper):
(V8DOMWrapper):
(WebCore::V8DOMWrapper::getWrapper):
* bindings/v8/custom/V8NodeCustom.cpp:
(WebCore::toV8Slow):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (107366 => 107367)
--- trunk/Source/WebCore/ChangeLog 2012-02-10 07:07:21 UTC (rev 107366)
+++ trunk/Source/WebCore/ChangeLog 2012-02-10 07:09:50 UTC (rev 107367)
@@ -1,3 +1,35 @@
+2012-02-09 Adam Barth <[email protected]>
+
+ Dromaeo/dom-traverse.html should go fast
+ https://bugs.webkit.org/show_bug.cgi?id=78307
+
+ Reviewed by Eric Seidel.
+
+ This patch improves Dromaeo/dom-traverse.html by roughly 2.5% by
+ removing a branch. Previously, we null-checked the result of
+ V8DOMWrapper::getWrapper in a hot code path, but the only case where we
+ return a non-empty wrapper comes from a cold code path. By pushing the
+ null check into the cold codepath, we eliminate the branch from the
+ hot code path.
+
+ This patch also annotates the branches in the hot code path with their
+ likely outcome. I didn't measure a statistically significant
+ improvement with that aspect of the change, but it seems worthwhile.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateHeader):
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::getExistingWrapperInline):
+ (WebCore):
+ (WebCore::V8DOMWrapper::getExistingWrapperSlow):
+ (WebCore::V8DOMWrapper::getWrapperSlow):
+ * bindings/v8/V8DOMWrapper.h:
+ (WebCore::V8DOMWrapper::getExistingWrapper):
+ (V8DOMWrapper):
+ (WebCore::V8DOMWrapper::getWrapper):
+ * bindings/v8/custom/V8NodeCustom.cpp:
+ (WebCore::toV8Slow):
+
2012-02-09 Emil A Eklund <[email protected]>
Convert Frame/FrameView to LayoutUnits in preparation for turning on subpixel layout
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (107366 => 107367)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-02-10 07:07:21 UTC (rev 107366)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-02-10 07:09:50 UTC (rev 107367)
@@ -427,7 +427,7 @@
ALWAYS_INLINE v8::Handle<v8::Object> ${className}::existingWrapper(${nativeType}* impl)
{
END
- my $getWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getWrapper(impl)" : "${domMapFunction}.get(impl)";
+ my $getWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getExistingWrapper(impl)" : "${domMapFunction}.get(impl)";
push(@headerContent, <<END);
return ${getWrapper};
}
@@ -469,14 +469,11 @@
inline v8::Handle<v8::Value> toV8(Node* impl, bool forceNewObject = false)
{
- if (!impl)
+ if (UNLIKELY(!impl))
return v8::Null();
- if (!forceNewObject) {
- v8::Handle<v8::Value> wrapper = V8DOMWrapper::getWrapper(impl);
- if (!wrapper.IsEmpty())
- return wrapper;
- }
- return toV8Slow(impl, forceNewObject);
+ if (UNLIKELY(forceNewObject))
+ return toV8Slow(impl, forceNewObject);
+ return V8DOMWrapper::getWrapper(impl);
}
END
}
Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp (107366 => 107367)
--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp 2012-02-10 07:07:21 UTC (rev 107366)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp 2012-02-10 07:09:50 UTC (rev 107367)
@@ -72,6 +72,20 @@
typedef HashMap<Node*, v8::Object*> DOMNodeMap;
typedef HashMap<void*, v8::Object*> DOMObjectMap;
+static ALWAYS_INLINE v8::Handle<v8::Object> getExistingWrapperInline(Node* node)
+{
+ V8IsolatedContext* context = V8IsolatedContext::getEntered();
+ if (LIKELY(!context)) {
+ v8::Persistent<v8::Object>* wrapper = node->wrapper();
+ if (!wrapper)
+ return v8::Handle<v8::Object>();
+ return *wrapper;
+ }
+ DOMDataStore* store = context->world()->domDataStore();
+ DOMNodeMapping& domNodeMap = node->isActiveNode() ? store->activeDomNodeMap() : store->domNodeMap();
+ return domNodeMap.get(node);
+}
+
// The caller must have increased obj's ref count.
void V8DOMWrapper::setJSWrapperForDOMObject(void* object, v8::Persistent<v8::Object> wrapper)
{
@@ -292,20 +306,19 @@
return typeInfo == type;
}
-v8::Handle<v8::Object> V8DOMWrapper::getWrapperSlow(Node* node)
+v8::Handle<v8::Object> V8DOMWrapper::getExistingWrapperSlow(Node* node)
{
- V8IsolatedContext* context = V8IsolatedContext::getEntered();
- if (LIKELY(!context)) {
- v8::Persistent<v8::Object>* wrapper = node->wrapper();
- if (!wrapper)
- return v8::Handle<v8::Object>();
- return *wrapper;
- }
- DOMDataStore* store = context->world()->domDataStore();
- DOMNodeMapping& domNodeMap = node->isActiveNode() ? store->activeDomNodeMap() : store->domNodeMap();
- return domNodeMap.get(node);
+ return getExistingWrapperInline(node);
}
+v8::Handle<v8::Value> V8DOMWrapper::getWrapperSlow(Node* node)
+{
+ v8::Handle<v8::Object> wrapper = getExistingWrapperInline(node);
+ if (!wrapper.IsEmpty())
+ return wrapper;
+ return toV8Slow(node, false);
+}
+
#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
if (eventNames().interfaceFor##interfaceName == desiredInterface) \
return toV8(static_cast<interfaceName*>(target));
Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h (107366 => 107367)
--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h 2012-02-10 07:07:21 UTC (rev 107366)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h 2012-02-10 07:09:50 UTC (rev 107367)
@@ -124,19 +124,31 @@
static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, WrapperTypeInfo*, void* impl);
- static v8::Handle<v8::Object> getWrapper(Node* node)
+ static v8::Handle<v8::Object> getExistingWrapper(Node* node)
{
ASSERT(isMainThread());
if (LIKELY(!IsolatedWorld::count())) {
v8::Persistent<v8::Object>* wrapper = node->wrapper();
- if (wrapper)
+ if (LIKELY(!!wrapper))
return *wrapper;
}
+ return getExistingWrapperSlow(node);
+ }
+
+ static v8::Handle<v8::Value> getWrapper(Node* node)
+ {
+ ASSERT(isMainThread());
+ if (LIKELY(!IsolatedWorld::count())) {
+ v8::Persistent<v8::Object>* wrapper = node->wrapper();
+ if (LIKELY(!!wrapper))
+ return *wrapper;
+ }
return getWrapperSlow(node);
}
private:
- static v8::Handle<v8::Object> getWrapperSlow(Node*);
+ static v8::Handle<v8::Object> getExistingWrapperSlow(Node*);
+ static v8::Handle<v8::Value> getWrapperSlow(Node*);
};
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp (107366 => 107367)
--- trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp 2012-02-10 07:07:21 UTC (rev 107366)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp 2012-02-10 07:09:50 UTC (rev 107367)
@@ -137,7 +137,7 @@
return v8::Null();
if (!forceNewObject) {
- v8::Handle<v8::Value> wrapper = V8DOMWrapper::getWrapper(impl);
+ v8::Handle<v8::Value> wrapper = V8DOMWrapper::getExistingWrapper(impl);
if (!wrapper.IsEmpty())
return wrapper;
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes