|
Mainstream object-oriented languages, such as C++ and Java, provide only a restricted form of polymorphic methods, namely uni-receiver dispatch (e.g., virtual functions). In common programming situations (e.g., GUIs and event-based applications) developers must work around the limitation of dynamic dispatch on only one type. It is desirable to support dynamic dispatch on the run-time types of the receiver and all the method arguments without the programmer having to write explicit and error-prone double-dispatch code. We describe how to extend the Java Virtual Machine to support multi-dispatch and examine the complications that Java imposes on multi-dispatch in practice. Our technique avoids changes to the Java programming language itself, maintains source code and library compatibility, and isolates the performance penalty and semantic changes of multi-method dispatch to the program sections which use it. We have also experimented with multi-dispatch and just-in-time compilation. We have micro-benchmark and application-level performance results for a dynamic Most Specific Applicable (MSA) dispatcher, a framework-based Single Receiver Projections (SRP) dispatcher, and a tuned SRP dispatcher. Our general-purpose technique provides smaller dispatch latency than programmer-written double-dispatch code with equivalent functionality. Joint work with: C. Dutchyn, D. Szafron, S. Bromling, W. Holst. A paper on this work was presented at the USENIX Conference on Object-Oriented Technologies and Systems, San Antonio, Texas, January 29 to February 2, 2001. Paul Lu is an Assistant Professor at the University of Alberta. |