Title: [110347] trunk/Source/WebCore
- Revision
- 110347
- Author
- [email protected]
- Date
- 2012-03-09 16:13:13 -0800 (Fri, 09 Mar 2012)
Log Message
[V8][Performance] Inline hot methods in V8Bindings.h
https://bugs.webkit.org/show_bug.cgi?id=80685
Reviewed by Adam Barth.
This patch slightly improves DOM binding performance by inlining hot
methods in V8Binding.cpp, e.g. isUndefinedOrNull(), v8StringOrNull(), v8Boolean().
For example, this patch improves div.nodeName by 5.0%, and div.nodeValue by 4.1%.
Performance tests: https://bugs.webkit.org/attachment.cgi?id=131006
The performance test results in my Mac environment are as follows:
Chromium/V8 without this patch:
div.nodeName : 3417.4 ms
div.nodeValue : 2069.6 ms
Chromium/V8 with this patch:
div.nodeName : 3245.6 ms
div.nodeValue : 1983.1 ms
No tests. No change in behavior.
* bindings/v8/V8Binding.cpp:
* bindings/v8/V8Binding.h:
(WebCore::toWebCoreString):
(WebCore::isUndefinedOrNull):
(WebCore::isHostObject):
(WebCore::v8Boolean):
(WebCore::toWebCoreStringWithNullCheck):
(WebCore::toAtomicWebCoreStringWithNullCheck):
(WebCore::toWebCoreStringWithNullOrUndefinedCheck):
(WebCore::v8UndetectableString):
(WebCore::v8StringOrNull):
(WebCore::v8StringOrUndefined):
(WebCore::v8StringOrFalse):
(WebCore::toWebCoreDate):
(WebCore::v8DateOrNull):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (110346 => 110347)
--- trunk/Source/WebCore/ChangeLog 2012-03-09 23:49:12 UTC (rev 110346)
+++ trunk/Source/WebCore/ChangeLog 2012-03-10 00:13:13 UTC (rev 110347)
@@ -1,3 +1,44 @@
+2012-03-09 Kentaro Hara <[email protected]>
+
+ [V8][Performance] Inline hot methods in V8Bindings.h
+ https://bugs.webkit.org/show_bug.cgi?id=80685
+
+ Reviewed by Adam Barth.
+
+ This patch slightly improves DOM binding performance by inlining hot
+ methods in V8Binding.cpp, e.g. isUndefinedOrNull(), v8StringOrNull(), v8Boolean().
+ For example, this patch improves div.nodeName by 5.0%, and div.nodeValue by 4.1%.
+
+ Performance tests: https://bugs.webkit.org/attachment.cgi?id=131006
+
+ The performance test results in my Mac environment are as follows:
+
+ Chromium/V8 without this patch:
+ div.nodeName : 3417.4 ms
+ div.nodeValue : 2069.6 ms
+
+ Chromium/V8 with this patch:
+ div.nodeName : 3245.6 ms
+ div.nodeValue : 1983.1 ms
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8Binding.cpp:
+ * bindings/v8/V8Binding.h:
+ (WebCore::toWebCoreString):
+ (WebCore::isUndefinedOrNull):
+ (WebCore::isHostObject):
+ (WebCore::v8Boolean):
+ (WebCore::toWebCoreStringWithNullCheck):
+ (WebCore::toAtomicWebCoreStringWithNullCheck):
+ (WebCore::toWebCoreStringWithNullOrUndefinedCheck):
+ (WebCore::v8UndetectableString):
+ (WebCore::v8StringOrNull):
+ (WebCore::v8StringOrUndefined):
+ (WebCore::v8StringOrFalse):
+ (WebCore::toWebCoreDate):
+ (WebCore::v8DateOrNull):
+
2012-03-09 W. James MacLean <[email protected]>
[chromium] Implement scroll physics architecture for impl/main thread
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (110346 => 110347)
--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-03-09 23:49:12 UTC (rev 110346)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-03-10 00:13:13 UTC (rev 110347)
@@ -286,84 +286,6 @@
return static_cast<uint32_t>(intValue->Value());
}
-String toWebCoreString(const v8::Arguments& args, int index) {
- return v8ValueToWebCoreString(args[index]);
-}
-
-
-String toWebCoreStringWithNullCheck(v8::Handle<v8::Value> value)
-{
- if (value->IsNull())
- return String();
- return v8ValueToWebCoreString(value);
-}
-
-AtomicString toAtomicWebCoreStringWithNullCheck(v8::Handle<v8::Value> value)
-{
- if (value->IsNull())
- return AtomicString();
- return v8ValueToAtomicWebCoreString(value);
-}
-
-String toWebCoreStringWithNullOrUndefinedCheck(v8::Handle<v8::Value> value)
-{
- if (value->IsNull() || value->IsUndefined())
- return String();
- return toWebCoreString(value);
-}
-
-bool isUndefinedOrNull(v8::Handle<v8::Value> value)
-{
- return value->IsNull() || value->IsUndefined();
-}
-
-bool isHostObject(v8::Handle<v8::Object> object)
-{
- // If the object has any internal fields, then we won't be able to serialize or deserialize
- // them; conveniently, this is also a quick way to detect DOM wrapper objects, because
- // the mechanism for these relies on data stored in these fields. We should
- // catch external array data and external pixel data as a special case (noting that CanvasPixelArrays
- // can't be serialized without being wrapped by ImageData according to the standard).
- return object->InternalFieldCount() || object->HasIndexedPropertiesInPixelData() || object->HasIndexedPropertiesInExternalArrayData();
-}
-
-v8::Handle<v8::Boolean> v8Boolean(bool value)
-{
- return value ? v8::True() : v8::False();
-}
-
-v8::Handle<v8::String> v8UndetectableString(const String& str)
-{
- return v8::String::NewUndetectable(fromWebCoreString(str), str.length());
-}
-
-v8::Handle<v8::Value> v8StringOrNull(const String& str)
-{
- return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str));
-}
-
-v8::Handle<v8::Value> v8StringOrUndefined(const String& str)
-{
- return str.isNull() ? v8::Handle<v8::Value>(v8::Undefined()) : v8::Handle<v8::Value>(v8String(str));
-}
-
-v8::Handle<v8::Value> v8StringOrFalse(const String& str)
-{
- return str.isNull() ? v8::Handle<v8::Value>(v8::False()) : v8::Handle<v8::Value>(v8String(str));
-}
-
-double toWebCoreDate(v8::Handle<v8::Value> object)
-{
- return (object->IsDate() || object->IsNumber()) ? object->NumberValue() : std::numeric_limits<double>::quiet_NaN();
-}
-
-v8::Handle<v8::Value> v8DateOrNull(double value)
-{
- if (isfinite(value))
- return v8::Date::New(value);
- return v8::Null();
-}
-
template <class S> struct StringTraits
{
static S fromStringResource(WebCoreStringResource* resource);
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (110346 => 110347)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-03-09 23:49:12 UTC (rev 110346)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-03-10 00:13:13 UTC (rev 110347)
@@ -329,7 +329,10 @@
return v8ValueToWebCoreString(object);
}
- String toWebCoreString(const v8::Arguments&, int index);
+ inline String toWebCoreString(const v8::Arguments& args, int index)
+ {
+ return v8ValueToWebCoreString(args[index]);
+ }
// The string returned by this function is still owned by the argument
// and will be deallocated when the argument is deallocated.
@@ -338,27 +341,62 @@
return reinterpret_cast<const uint16_t*>(str.characters());
}
- bool isUndefinedOrNull(v8::Handle<v8::Value> value);
+ inline bool isUndefinedOrNull(v8::Handle<v8::Value> value)
+ {
+ return value->IsNull() || value->IsUndefined();
+ }
// Returns true if the provided object is to be considered a 'host object', as used in the
// HTML5 structured clone algorithm.
- bool isHostObject(v8::Handle<v8::Object>);
+ inline bool isHostObject(v8::Handle<v8::Object> object)
+ {
+ // If the object has any internal fields, then we won't be able to serialize or deserialize
+ // them; conveniently, this is also a quick way to detect DOM wrapper objects, because
+ // the mechanism for these relies on data stored in these fields. We should
+ // catch external array data and external pixel data as a special case (noting that CanvasPixelArrays
+ // can't be serialized without being wrapped by ImageData according to the standard).
+ return object->InternalFieldCount() || object->HasIndexedPropertiesInPixelData() || object->HasIndexedPropertiesInExternalArrayData();
+ }
- v8::Handle<v8::Boolean> v8Boolean(bool value);
+ inline v8::Handle<v8::Boolean> v8Boolean(bool value)
+ {
+ return value ? v8::True() : v8::False();
+ }
- String toWebCoreStringWithNullCheck(v8::Handle<v8::Value> value);
+ inline String toWebCoreStringWithNullCheck(v8::Handle<v8::Value> value)
+ {
+ return value->IsNull() ? String() : v8ValueToWebCoreString(value);
+ }
- AtomicString toAtomicWebCoreStringWithNullCheck(v8::Handle<v8::Value> value);
+ inline AtomicString toAtomicWebCoreStringWithNullCheck(v8::Handle<v8::Value> value)
+ {
+ return value->IsNull() ? AtomicString() : v8ValueToAtomicWebCoreString(value);
+ }
- String toWebCoreStringWithNullOrUndefinedCheck(v8::Handle<v8::Value> value);
+ inline String toWebCoreStringWithNullOrUndefinedCheck(v8::Handle<v8::Value> value)
+ {
+ return (value->IsNull() || value->IsUndefined()) ? String() : toWebCoreString(value);
+ }
- v8::Handle<v8::String> v8UndetectableString(const String& str);
+ inline v8::Handle<v8::String> v8UndetectableString(const String& str)
+ {
+ return v8::String::NewUndetectable(fromWebCoreString(str), str.length());
+ }
- v8::Handle<v8::Value> v8StringOrNull(const String& str);
+ inline v8::Handle<v8::Value> v8StringOrNull(const String& str)
+ {
+ return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str));
+ }
- v8::Handle<v8::Value> v8StringOrUndefined(const String& str);
+ inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str)
+ {
+ return str.isNull() ? v8::Handle<v8::Value>(v8::Undefined()) : v8::Handle<v8::Value>(v8String(str));
+ }
- v8::Handle<v8::Value> v8StringOrFalse(const String& str);
+ inline v8::Handle<v8::Value> v8StringOrFalse(const String& str)
+ {
+ return str.isNull() ? v8::Handle<v8::Value>(v8::False()) : v8::Handle<v8::Value>(v8String(str));
+ }
template <class T> v8::Handle<v8::Value> v8NumberArray(const Vector<T>& values)
{
@@ -369,9 +407,15 @@
return result;
}
- double toWebCoreDate(v8::Handle<v8::Value> object);
+ inline double toWebCoreDate(v8::Handle<v8::Value> object)
+ {
+ return (object->IsDate() || object->IsNumber()) ? object->NumberValue() : std::numeric_limits<double>::quiet_NaN();
+ }
- v8::Handle<v8::Value> v8DateOrNull(double value);
+ inline v8::Handle<v8::Value> v8DateOrNull(double value)
+ {
+ return isfinite(value) ? v8::Date::New(value) : v8::Handle<v8::Value>(v8::Null());
+ }
v8::Persistent<v8::FunctionTemplate> createRawTemplate();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes