hg: valhalla/valhalla/jdk: Initial implementation of metacircular interpreter
brian.goetz at oracle.com
Sun Aug 23 16:53:19 UTC 2015
> very true, everyone should try to write such interpreter at least once, with lambdas and method handles it's exhilarating !
Yes. The MH runtime probably replaced what would otherwise be 1000
lines of code to handle all the peculiarities of method dispatch.
Instead, we just ask resolveOrFail to resolve the dispatch for us, and
then use revealDirect to determine if this is a call we can interpret
(and if not, just invoke() the resulting MH, and push the result on the
interpreter frame.) Even supporting indy was only about 15 LoC. The
overall result was impressive; most bytecodes took 1 LoC and even the
hardest ones took no more than 15.
It's not complete; we're missing a few opcodes (xxxSWITCH) and exception
handling is a total mess (actually, a partial mess, since some of it is
More information about the valhalla-dev