Metascala: a tiny DIY JVM

A session at Scala eXchange 2013

  • Haoyi Li

Monday 2nd December, 2013

11:15am to 12:00pm (GMT)

Metascala is a tiny metacircular Java Virtual Machine (JVM) written in the Scala programming language. Metascala is barely 3000 lines of Scala, and is complete enough that it is able to interpret itself metacircularly. Being written in Scala and compiled to Java bytecode, the Metascala JVM requires a host JVM in order to run.

The goal of Metascala is to create a platform to experiment with the JVM: a 3000 line JVM written in Scala is probably much more approachable than the 1,000,000 lines of C/C++ which make up HotSpot, the standard implementation, and more amenable to implementing fun features like continuations, isolates or value classes. The 3000 lines of code gives you:

*The bytecode interpreter, together with all the run-time data structures
*A stack-machine to SSA register-machine bytecode translator
*A custom heap, complete with a stop-the-world, copying garbage collector
*Implementations of parts of the JVM's native interface

Although it is far from a complete implementation, Metascala already provides the ability to run untrusted bytecode securely (albeit slowly), since every operation which could potentially cause harm (including memory allocations and CPU usage) is virtualized and can be controlled. Ongoing work includes tightening of the security guarantees, improving compatibility and increasing performance.

About the speaker

This person is speaking at this event.
Haoyi Li

Sign in to add slides, notes or videos to this session

Scala eXchange 2013

England England, London

2nd3rd December 2013

Tell your friends!


Time 11:15am12:00pm GMT

Date Mon 2nd December 2013

Short URL


View the schedule


See something wrong?

Report an issue with this session