[webkit-dev] JavaScript bindings changed to call scriptExecutionContext virtual function?
Darin Adler
darin at apple.com
Sun Aug 2 01:13:08 PDT 2009
I noticed that many JavaScript binding implementations are now calling
the virtual function scriptExecutionContext on DOM nodes. This should
never be done! That's a virtual function, so it's not as fast as
calling document(). The virtual Node::scriptExecutionContext()
function should be made private so that we can catch at least some
cases of this programming mistake at compile time.
When this change was made, this presumably slowed down DOM bindings,
since document() is an inline function that expands to a single memory
read and scriptExecutionContext() is a virtual function call.
When was this done? Can the person who did it fix it?
There are various techniques that can be used to fix this.
One is to only call scriptExecutionContext in generic code, and use
functions named document() in less generic code that's working with a
Node rather than an EventTarget.
Another is to break scriptExecutionContext into virtual and non-
virtual parts as we do with functions like Node::prefix and
Node::virtualPrefix.
-- Darin
More information about the webkit-dev
mailing list