Date of Completion


Embargo Period



Robert McCartney;Yufeng Wu;Zhijie Jerry Shi

Field of Study

Computer Science and Engineering


Master of Science

Open Access

Open Access


A continuation represents the future of an execution. It is often used as an intermediate representation(IR) to compile functional programming languages, make control flow explicit and full beta-reduction(function inlining) possible. Continuations are also a language feature that gives user the ability to completely control the execution control flow(first class continuation). Efficient implementation of first class continuation is important for languages that need non-determinism and backtracking(e.g., COMET). We present a prototype imperative programming language with first class continuation -- AMIBE. AMIBE uses the LLVM compiler infrastructure which is attractive for its optimizing tools and overall modern organization. However, LLVM does not support the implementation of continuation via a direct manipulation of the system stack. To move the execution state out of the system stack into a separate AMIBE stack, AMIBE adopts the Continuation Passing Style compilation technique(CPS). With CPS, states on the system stack are never reused since functions never return. Portable implementation for first class continuation becomes possible because the compiler only needs to save and restore the AMIBE stack which it fully controls. In CPS, function calls are tail calls. By exploiting the optimization for tail calls in LLVM, function calls are reduced to jumps, so that the system stack never grows on calls. AMIBE programs are first compiled into an AMIBE IR closely related to LLVM IR, then transformed into CPS form. Finally the AMIBE IR in CPS is translated into LLVM IR. The performance of the optimizing compiler based on LLVM and CPS is compared against a naive just-in-time compiler based on GNU lightning and currently used by COMET.

Major Advisor

Laurent Michel