Introduction
This book contains documentation for the yk metatracing system. A preformatted version of this book can be found at https://ykjit.github.io/yk/.
This book is written in mdbook format. If
you want to edit this book, mdbook serve --open
runs a local server, opens a
formatted version of this book in your browser, and automatically refreshes the
browser when you save a markdown file after editing.
Major components
yk is a meta-tracing system that turns existing C interpreters into JIT-compiling VMs. It is comprised of two major components:
-
ykllvm
is a fork of LLVM that must be used to: compile C interpreters with the necessary extra information for yk; link in theyk
Rust library. -
The
yk
Rust library is the core of the run-time JIT system.
Terminology
yk utilises two different Intermediate Representations (IRs):
-
AOT IR is the Ahead-Of-Time IR generated by ykllvm and embedded in the binary of a C interpreter. AOT IR is similar to LLVM IR, though customised and simplified for yk.
-
JIT IR is the IR generated (from AOT IR) at run-time by yk and which is dynamically converted into machine code.
There are three styles of "trace" in yk:
-
When a hot loop in a program is detected, the actions of the interpreter are recorded to make an AOT IR trace.
-
The AOT IR trace is combined with AOT IR and then compiled into JIT IR to make a JIT IR trace.
-
The JIT IR trace is compiled into machine code to make an executable trace.