Slide 1

Slide 1 text

Managed Runtime Systems Lecture 07: Meta-circular VMs Foivos Zakkak https://foivos.zakkak.net Except where otherwise noted, this presentation is licensed under the Creative Commons Attribution 4.0 International License. Third party marks and brands are the property of their respective holders.

Slide 2

Slide 2 text

Meta-circularity Using the language that the VM implements to write the VM itself! Managed Runtime Systems 1 of 9 https://foivos.zakkak.net

Slide 3

Slide 3 text

Why??? 1. All the advantages of managed and high-level languages 2. Consistent calling conventions (going from app to VM and back) 3. Consistent Types and sizes 4. Consistent memory model 5. Re-use the same compilers at compile-time and run-time 6. Maintainability Managed Runtime Systems 2 of 9 https://foivos.zakkak.net

Slide 4

Slide 4 text

But! 1. Slower product 2. Slower development cycles 3. Thinking in a meta-circular manner is not trivial (hard to find bugs) 4. More complex testing infrastructure Managed Runtime Systems 3 of 9 https://foivos.zakkak.net

Slide 5

Slide 5 text

Using a substrate VM Rely on C compilers to produce machine code C-based implementation of a minimal runtime Bootstraps the Java in Java VM and implements system handling JIT compilation with C compilers is too slow, LLVM aims to fix that Squawk VM is one such example Managed Runtime Systems 4 of 9 https://foivos.zakkak.net

Slide 6

Slide 6 text

Re-using the same compiler at compile-time and run-time Old VM javac MyCompiler.java MyCompiler.class MyCompiler.java MyVM.java Old VM My VM + Compiler HelloWorld.class Hello World!!! Managed Runtime Systems 5 of 9 https://foivos.zakkak.net

Slide 7

Slide 7 text

Re-using the same compiler at compile-time and run-time Old VM javac MyCompiler.java MyCompiler.class MyCompiler.java MyVM.java Old VM My VM + Compiler HelloWorld.class Hello World!!! Managed Runtime Systems 5 of 9 https://foivos.zakkak.net

Slide 8

Slide 8 text

Re-using the same compiler at compile-time and run-time Old VM javac MyCompiler.java MyCompiler.class MyCompiler.java MyVM.java Old VM My VM + Compiler HelloWorld.class Hello World!!! Managed Runtime Systems 5 of 9 https://foivos.zakkak.net

Slide 9

Slide 9 text

Re-using the same compiler at compile-time and run-time Old VM javac MyCompiler.java MyCompiler.class MyCompiler.java MyVM.java Old VM My VM + Compiler HelloWorld.class Hello World!!! Managed Runtime Systems 5 of 9 https://foivos.zakkak.net

Slide 10

Slide 10 text

Difficulties Needs access to unsafe parts of the language How to avoid GC being run during GC Managed Runtime Systems 6 of 9 https://foivos.zakkak.net

Slide 11

Slide 11 text

Examples of Java in Java VMs Jikes Research VM (aka JikesRVM) Maxine VM Managed Runtime Systems 7 of 9 https://foivos.zakkak.net

Slide 12

Slide 12 text

Jikes RVM Originally known as JalapeƱo Adopted by the academia Features the Memory Management Toolkit (MMTk) Relies on a magic layer for its implementation on different platforms 2 JIT compilers, no interpreter No 64bit port Managed Runtime Systems 8 of 9 https://foivos.zakkak.net

Slide 13

Slide 13 text

Maxine VM Predecessor of the Graal Compiler, a JIT compiler for Java written in Java Modular design (GC, Compilers, Memory layout, Monitors, etc.) Template based compilation More next time! Managed Runtime Systems 9 of 9 https://foivos.zakkak.net