Efficient Implementation of Java Interfaces: Invokeinterface Considered Harmless

Copyright [©] (2001) by Association for Computing Machinery, Inc. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distrubuted for profit or commericial advantage. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee.

Single superclass inheritance enables simple and efficient table-driven virtual method dispatch. However, virtual method table dispatch does not handle multiple inheritance and inter-faces. This complication has led to a widespread misimpression that interface method dispatch is inherently inefficient. This paper argues that with proper implementation techniques, interface method calls need not introduce significant performance degradation as compared to virtual method calls. We present an efficient interface method dispatch mechanism, associating a fixed-sized interface method table (IMT) with each class. Interface method signatures hash to an IMT slot, with any hashing collisions handled by custom-generated conflict resolution stubs. The dispatch mechanism is efficient in both time and space. Furthermore, with static analysis and online profile data, m optimizing compiler can inline the dominant target(s) of any frequently executed interface call. Micro-benchmark results demonstrate that the expected cost of an interface method call dispatched via an IMT is comparable to the cost of a virtual method call. Experimental evaluation of the techniques on a suite of larger applications demonstrates that, even for applications that make only moderate use of interface methods, these techniques can significantly impact bottom

By: Bowen Alpern, Anthony Cocchi, Stephen J. Fink, David P. Grove, Derek Lieber

Published in: ACM SIGPLAN Notices, volume 36, (no 11), pages 108-24 in 2001

LIMITED DISTRIBUTION NOTICE:

This Research Report is available. This report has been submitted for publication outside of IBM and will probably be copyrighted if accepted for publication. It has been issued as a Research Report for early dissemination of its contents. In view of the transfer of copyright to the outside publisher, its distribution outside of IBM prior to publication should be limited to peer communications and specific requests. After outside publication, requests should be filled only by reprints or legally obtained copies of the article (e.g., payment of royalties). I have read and understand this notice and am a member of the scientific community outside or inside of IBM seeking a single copy only.

RC22261.pdf

Questions about this service can be mailed to reports@us.ibm.com .