Direct implementation of shift and reset in the MinCaml compiler

  • Authors:
  • Moe Masuko;Kenichi Asai

  • Affiliations:
  • Ochanomizu University, Tokyo, Japan;Ochanomizu University, Tokyo, Japan

  • Venue:
  • Proceedings of the 2009 ACM SIGPLAN workshop on ML
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

Although delimited control operators are becoming one of the useful tools to manipulate flow of programs, their direct and compiled implementation in a low-level language has not been proposed so far. The only direct and low-level implementations available are Gasbichler and Sperber's implementation in the Scheme 48 virtual machine and Kiselyov's implementation in the OCaml bytecode. Even though these implementations do provide insight into how stack frames are composed, they are not directly portable to compiled implementation in assembly language. This paper presents a direct implementation of delimited control operators shift and reset in the MinCaml compiler. It shows all the details of how composable continuations can be implemented in the PowerPC microprocessor using a stack discipline. We also show an implementation that copies stack frames lazily. To our knowledge, this is the first implementation of shift/reset in assembly language. It makes clear at the assembly language level what we have informally described so far, such as "copying and composing stack frames" and "inserting a reset mark when captured continuations are called". We demonstrate various benchmarks to show the performance of our implementation and discuss its pros and cons.