Direct Implementation of Shift and Reset
in the MinCaml Compiler
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 an insight into how stack frames are
composed, they are not directly portable to compiled implementation at
the 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 the stack strategy.
We also show an implementation that copies the stack frames lazily.
To our knowledge, this is the first implementation of shift/reset in
the 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 the direct implementation and discuss its pros and