Perfect Hashing for Method Dispatch with Dynamic Typing and Dynamic Compilation
Résumé
In static typing, the receiver's static type is the key to efficient implementation of method invocation, and a recently proposed technique, based on perfect hashing of classes, cannot apply to dynamic typing because of the lack of static types. In this article, we propose a new application of perfect hashing to method dispatch in a dynamic typing, dynamic loading and single inheritance setting. The approach involves hashing method selectors instead of classes. However, as hashing all methods revealed itself to be space-inefficient, only overloaded methods, ie methods introduced by several classes, are hashed. The dispatch of non-overloaded methods is done as in single-subtyping, ie static typing and single inheritance. An adaptive-compilation protocol and an algorithm for hashing overloaded methods are proposed, and the approach is tested on Smalltalk benchmarks by simulating class loading at random.