Subtype tests are an important issue in the implementation of object-oriented programming languages. Many techniques have been proposed, but none of them perfectly fulfills the five requirements that we have identified: constant-time, linear-space, multiple inheritance, dynamic loading and inlining. In this paper, we propose a subtyping test implementation which involves a combination of usual hashtables and Cohen's display, which is a well known technique for single inheritance hierarchies. This novel approach is based on perfect hashing, i.e. an optimized and truly constant-time variant of hashing which applies to immutable hashtables. We show that the resulting technique closely meets all five requirements. Furthermore, in the framework of Java-like languages-characterized by single inheritance of classes and multiple subtyping of interfacesperfect hashing also applies to method invocation when the receiver is typed by an interface. The proposed technique is compared to some alternatives, including the proposal by Palacz and Vitek [2003]. Time-efficiency is assessed at the cycle level in the framework of Driesen's pseudo-code and the linear-space criterion is validated by statistical simulation on benchmarks consisting of large-scale class hierarchies.
Object-oriented languages involve a threefold tradeoff between runtime efficiency, expressiveness (multiple inheritance), and modularity, i.e. open-world assumption (OWA). Runtime efficiency is conditioned by both the implementation technique and compilation scheme. The former specifies the data structures that support method invocation, attribute access and subtype testing. The latter consists of the production line of an executable from the source code. Many implementation techniques have been proposed and several compilation schemes can be considered from fully global compilation under the closed-world assumption (CWA) to separate compilation with dynamic loading under the OWA, with midway solutions. This article reviews a significant subset of possible combinations and presents a systematic, empirical comparison of their respective efficiencies with all other things being equal. The testbed consists of the PRM compiler that has been designed for this purpose. The considered techniques include C++ subobjects, coloring, perfect hashing, binary tree dispatch and caching. A variety of processors were considered. Qualitatively, these first results confirm the intuitive or theoretical abstract assessments of the tested approaches. As expected, efficiency increases as CWA strengthens. From a quantitative standpoint, the results are the first to precisely compare the efficiency of techniques that are closely associated with specific languages like C++ and EIFFEL. They also confirm that perfect hashing should be considered for implementing JAVA and .NET interfaces.
In statically typed object-oriented languages, message sending, or late binding, is implemented with tables often called virtual functions tables (VFT). Those tables reduce method calls to function calls, with a small fixed number of extra indirections. The overhead is more or less important, whether inheritance and subtyping are single or multiple.In this paper, we survey the various implementation schemes available in separate compilation, in the three cases of single inheritance, multiple inheritance, and single inheritance but multiple subtyping, e.g. Java. Many works have been done recently in the framework of global compilation, mostly for dynamically typed languages but also applied to the Eiffel language in the Small Eiffel compiler. We examine how global compilation can improve the implementation and propose to use global techniques-coloring and type analysis-in a separate compilation framework.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.
hi@scite.ai
10624 S. Eastern Ave., Ste. A-614
Henderson, NV 89052, USA
Copyright © 2024 scite LLC. All rights reserved.
Made with 💙 for researchers
Part of the Research Solutions Family.