Suppose you want to be able to execute the Visitor pattern as quickly
as possible on some tree structure. You could compile your tree
structure into executable code, each node a subroutine which invokes a
method of the visitor object — traditionally each node type invokes a
different method — and then passes the visitor object to each child
node.
My knee-jerk response is that waiting for i-cache misses is probably
not much faster than waiting for d-cache misses, and so it's probably
better to spend effort massaging your tree into a serialized form
suitable for traditional loops; I'd guess that the increased
instruction count is easily outweighed by the better prediction and
streaming. What kinds of results have you seen?
-Dave
(although if you squint at it properly, doing this kind of thing in
general is almost exactly what distinguishes compilers from
interpreters)
--
To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-discuss