We describe two generic optimization techniques to improve run-time performance of C++ virtual function calls: type specification and type prediction. Both involve program analysis that results in a set of call sites to be optimized, and code transformations that replace the original dispatching mechanism in these sites by more efficient call expressions. We implement two special cases. The first is a type-specification optimization, called unique name, that requires static global view of the whole program in order to substitute indirect virtual function call sites by direct calls. The other is a type-prediction kind of optimization, referred to as single type prediction, that uses type-profiling information to replace virtual function calls by conditional expressions which involve direct function calls.
These optimizations were implemented in IBM's compiler, the C Set ++ for AIX/6000, and evaluated on a set of C++ standard benchmarks. We received encouraging run-time results with improvements in order of 20% that demonstrate the vitality of these techniques.
[1]
Urs Hölzle,et al.
Optimizing dynamically-dispatched calls with run-time type feedback
,
1994,
PLDI '94.
[2]
Andrew A. Chien,et al.
Type Directed Cloning for Object-Oriented Programs
,
1995,
LCPC.
[3]
Dirk Grunwald,et al.
Reducing indirect function call overhead in C++ programs
,
1994,
POPL '94.
[4]
Urs Hölzle,et al.
Type feedback vs. concrete type inference: a comparison of optimization techniques for object-oriented languages
,
1995,
OOPSLA.
[5]
David Grove,et al.
Profile-guided receiver class prediction
,
1995,
OOPSLA.
[6]
Urs Hölzle,et al.
Eliminating Virtual Function Calls in C++ Programs
,
1996,
ECOOP.
[7]
Barbara G. Ryder,et al.
Static Type Determination for C++
,
1994,
C++ Conference.
[8]
William Berg,et al.
Lessons learned from the OS/400 OO project
,
1995,
CACM.
[9]
Dirk Grunwald,et al.
Quantifying Behavioral Differences Between C and C++ Programs
,
1994
.