Status: New
Owner: ----
New issue 2245 by [email protected]: Handle<Value>() is slower than
Undefined(info.GetIsolate())
http://code.google.com/p/v8/issues/detail?id=2245
Summary: Handle<Value>() should be as fast as Undefined(info.GetIsolate()).
c.f. https://bugs.webkit.org/show_bug.cgi?id=84074#c15
c.f. https://bugs.webkit.org/show_bug.cgi?id=84074#c17
Details: Consider simple DOM binding code like this:
// 14.6 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
return v8::Undefined();
}
// 8.4 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
return v8::Undefined(info.GetIsolate());
}
// 9.1 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
return v8::Handle<v8::Value>();
}
However, the above result does not indicate that one Handle<Value>() is
slower than one Undefined(info.GetIsolate()). Look at this:
// [A] div.xxx = 9.1 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
return v8::Handle<v8::Value>();
}
// [B] div.xxx = 9.0 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
static v8::Handle<v8::Value> v = v8::Handle<v8::Value>();
return v;
}
// [C] div.xxx = 8.4 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
return v8::Undefined(info.GetIsolate());
}
// [D] div.xxx = 8.4 ns
v8::Handle<v8::Value> xxxAttrGetter(..., info) {
static v8::Handle<v8::Value> v = v8::Undefined(info.GetIsolate());
return v;
}
Comparing [A] and [B], Handle<Value>() itself is zero overhead. Comparing
[C] and [D], Undefined(info.GetIsolate()) itself is also zero overhead.
However, comparing [B] and [D], returning Handle<Value>() seems to require
more work in V8 than returning Undefined(info.GetIsolate()). Maybe V8 is
running some copy constructor when we return Handle<Value>()??
Why we want to fix this: If Handle<Value>() is as fast as
Undefined(info.GetIsolate()), WebKit can always use Handle<Value>()
regardless of isolate, which makes WebKit codebase much simpler.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev