- https://github.com/lihaoyi/Metascala
Interpreting code in Metascala is about 100x slower than just running it, and interpreting code in Metascala interpreted by Metascala is about 10,000x slower than just running it. Not going to win any performance benchmarks, but it's a cool demonstration of how a JVM works.
All the runtime data structures, memory allocation and garbage collection, method dispatch logic, stack trace management, exceptions, inheritance, object layouts, etc. are all implemented in a relatively small amount of relatively simple code.
For example, here is the implementation of the heap, which allocates the VM's objects inside a big byte array and has a simple copying semispace garbage collector to clean them up:
- https://github.com/lihaoyi/Metascala/blob/master/src/main/sc...
Need to find some time to look more and actually try and work thru it.