I’m trying to sort out how MMTk is linked with VMKit. MMTk is written in Java and VMKit is written in C++, and there are some java files and something seems to be garbage collection in c++ sources.
Could you tell me where exactly mark and sweep algorithm takes place in (java?) source code and how and where is it invoked in c++?
This part of the code is a little bit tricky So basically, during
the first stage of the compilation, we are compiling vmkit with a
pseudo collector, which uses malloc internally (you can find the C++
sources in lib/vmkit/MMTk). Then, during the second stage, we are
using the resulting vmkit to translate MMTk into a llvm bytecode. For
each Java function, we generate a corresponding llvm function (we are
using the mangling defined by the Java Native Interface, except that
we replace Java_ by JnJVM_). And during the third stage, we are
linking MMTk with vmkit (we remove lib/vmkit/MMTk and use the llvm
bytecode of MMTk instead).
We also have a small interface between MMTk and vmkit, you can find
the sources in mmtk. The tracing functions and the gcmalloc function
are in mmtk/mmtk-alloc/Selected.cpp. You will find the other functions
in mmtk/mmtk-j3. Finally, you will find a llvm pass used to replace
the MMTk magic functions by llvm bytecode in mmtk/magic and the
sources of mmtk in mmtk/java.
You also have a small set of Java functions in mmtk/java/src/org/j3/,
mainly in bindings/Binding.java, which are used to simplify the
interface between vmkit (in C++) and MMTk (in Java).
I hope that it helps you,