a virtual machine with interpreter and just-in-time compilation for LLVM IR.
Machine Code: RV32I, running in ravel.
graph LR
A[src: .ll file]
B[ParseTree]
C[Running IR]
D[Compiling IR]
E[Interpreter]
F[JIT Compiler]
G[Profiler]
H[Machine]
I[Ravel]
J[CodeGenerator]
K[JITScheduler]
subgraph Parser
A ==Antlr v4==> B
B ==ModuleBuilder2==>D
B ==ModuleBuilder1==>C
end
C ==booting==> H
D ====> F
E ==Running On==>H
subgraph Core
F ==compiled assembly==> E
E ==compile request==> F
H ==ravel call==> I
I ==execute result==> H
E ==running info==>G
G ==hot select==> E
E ==compiled assembly==> J
J ==get code==> E
K ==signal of JIT==> E
end
This project is attached to Masterball Compiler.
- Drag the directory
darksword
into thesrc
directory in Masterball. and runDarkSwordVM
. - Build the artifact with
DarkSwordVM.java
as the main class. - Run
java -jar DarkSword.jar -h
to get the help doc.
If you want to try the JIT
part, a RISCV simulator ravel is required to execute the RISCV Assembly (machine code).
-
Get the library in
lib/ravel/libravel-sim.so
(which is a specially designed ravel for DSVM.) -
Run DarkSword with arguments:
-jit
-ravel <the absolute path of libravel-sim.so>
-
If the
connect
is OK when initialization, DarkSword will receive a ACK:
[ravel] Connecting to DarkSword... Success. Test Word: Hello, ravel
- Use Masterball to generate
.ll
file (unoptimized) - Use it as the input of DarkSword.
- Interpreter (
Masterball FrontEnd + DarkSword Interpreter
passed all codegen testcases.) - Simple JIT (method-based or BB-based...), context switch between JIT and Interpreter
- JIT Optimization (Reuse Static)
- Use runtime information
- Ravel will set
sp
to the end of the storage. (Fixed) - Ravel (x86) mem uses small-endian but DarkSword uses big-endian. (Fixed)
- Ravel can not link
builtin.s
therefore I can not JIT codes with libc call. (Fixed, but...) - Ravel can not pass Global Value (Fixed, but...)
- Ravel use
fopen('w')
and the filetest.out
will be cleared every timesimulate
is called. (Fixed)