This project is a binary translator, inspired by Apple's Rosetta technology [cite: 1128, 1131-1132, 1138]. It implements a function rosettax that translates bytecode from one virtual machine (SM5) to another (Sonata) [cite: 1143-1144, 1173-1174].
- Course: 4190.310 Programming Languages (Spring 2025)
- Institution: Seoul National University
- Tech Stack: OCaml
The core challenge of this project lies in the architectural difference between the two VMs:
- SM5 (Source): A 5-component machine
(S, M, E, C, K)that includes a dedicatedK(Continuation) stack to manage function calls and returns[cite: 1149]. - Sonata (Target): A 4-component machine
(S, M, E, C)that has noKstack[cite: 1150].
This translator, rosettax: Sm5.command -> Sonata.command [cite: 1173-1174], re-implements the K (Continuation) stack in software.
- Continuation Management: It translates SM5's
callandreturn(emptyC) instructions [cite: 1151-1165] into a series of Sonata instructions. - Manual Stack Handling: The translator generates Sonata bytecode that manually saves and restores continuations (the "what to do next" code and environment) onto Sonata's main
S(Stack) orM(Memory) [cite: 1166-1172]. - Transparency: This allows SM5 programs, which rely on the
Kstack, to run "transparently to users" [cite: 1135] on the Sonata machine, which has no such feature.