Efficient dynamic dispatch without virtual function tables: the SmallEiffel compiler
Craig Black
cblack at ara.com
Fri Mar 7 09:39:34 PST 2008
BTW, I am VERY interested in this stuff. I am already kludging my C++ code
to improve performance by reducing the number of virtual function calls
performed. (The most common functions get called non-virtually, and the
rest are called virtually.) If this feature was built into a compiler that
would greatly simplify things. I would allow me to use virtual functions
more freely without worrying so much about the overhead involved.
Another idea: a feature like this would probably require each function in
the virtual hiearchy to be assigned a precedence. The precedence would
represent how often the function is expected to be called. Functions with a
higher precedence could be called optimized to be called directly, whereas
lower precedence functions could be called via a vtable. The precedence
could be determined by profiling the code or by specifying a precedence
explicitly. Perhaps something like:
class A
{
public:
void func() { ... }
}
class B : A
{
public:
precedence(1) void func() { .. }
}
class C : A
{
precedence(2) void func() { ... }
}
-Craig
More information about the Digitalmars-d
mailing list