An Unboxed Operational Semantics for ML Polymorphism

  • Authors:
  • Atsushi Ohori;Tomonobu Takamizawa

  • Affiliations:
  • Research Institute for Mathematical Sciences, Kyoto University, Sakyo-ku, Kyoto 606 Japan. E-mail: e27362@yamato.ibm.co.jp;Research Institute for Mathematical Sciences, Kyoto University, Sakyo-ku, Kyoto 606 Japan. E-mail: e27362@yamato.ibm.co.jp

  • Venue:
  • Lisp and Symbolic Computation
  • Year:
  • 1997

Quantified Score

Hi-index 0.00

Visualization

Abstract

We present an unboxed operational semantics foran ML-style polymorphic language. Different from the conventional formalisms, theproposed semantics accounts for actual representations of run-timeobjects of various types, and supports a refined notion ofpolymorphism that allows polymorphic functions to be applied directlyto values of various different representations. In particular,polymorphic functions can receive multi-word constants such asfloating-point numbers without requiring them to be“boxed” (i.e., heap allocated.) This semantics will serveas an alternative basis for implementing polymorphic languages. The development of thesemantics is based on the technique of the type-inference-basedcompilation for polymorphic record operations [20]. Wefirst develop a lower-level calculus, called a polymorphic unboxed calculus, that accounts for directmanipulation of unboxed values in a polymorphic language. This unboxed calculus supportsefficient value binding through integer representation ofvariables. Different from de Bruijn indexes, our integerrepresentation of a variable corresponds to the actual offset to thevalue in a run-time environment consisting of objects of varioussizes. Polymorphism is supported through an abstraction mechanismover argument sizes. We then develop an algorithm that translates MLinto the polymorphic unboxed calculus by using type informationobtained through type inference. At the time of polymorphic let binding, the necessary size abstractions are inserted so that apolymorphic function is translated into a function that ispolymorphic not only in the type of the argument but also in itssize. The ML type system is shown to be sound with respect to theoperational semantics realized by the translation.