Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
Programming GNU is Not Unix

GNU Guile Scheme Gets a Register VM and CPS-Based IL 42

In late November, Andy Wingo pushed a new register VM to Guile's (the GNU implementation of the Scheme language) master branch. It brought a number of performance improvements, but led to a bit of a conceptual mismatch between the compiler's direct-style intermediate language and the virtual machine. Earlier this week Andy Wingo announced a new continuation-passing style intermediate language for Guile. From the article: "To recap, we switched from a stack machine to a register machine because, among other reasons, register machines can consume and produce named intermediate results in fewer instructions than stack machines, and that makes things faster. To take full advantage of this new capability, it is appropriate to switch at the same time from the direct-style intermediate language (IL) that we had to an IL that names all intermediate values. ... In Guile I chose a continuation-passing style language. ... Guile's CPS language is composed of terms, expressions, and continuations. It was heavily inspired by Andrew Kennedy's 'Compiling with Continuations, Continued' paper. ... The optimizations I have currently implemented for CPS are fairly basic. Contification was tricky. One thing I did recently was to make all non-tail $call nodes require $kreceive continuations; if, as in the common case, extra values were unused, that was reflected in an unused rest argument. This required a number of optimizations to clean up and remove the extra rest arguments for other kinds of source expressions: dead-code elimination, the typical beta/eta reduction, and some code generation changes." The article describes the CPS language provided by Guile and explains the reasons behind choosing CPS over SSA or A-Normal Form. The Guile manual contains draft documentation. The new VM and Intermediate Language will be released with Guile 2.2, which should be out later this year.
This discussion has been archived. No new comments can be posted.

GNU Guile Scheme Gets a Register VM and CPS-Based IL

Comments Filter:
  • by Elf Sternberg ( 3499985 ) on Wednesday January 15, 2014 @04:32PM (#45969085)
    The frightening thing is, a year ago, I wouldn't have understood this post. Now I'm reading the paper on Contifications and nodding my head, going "Yeah, yeah... huh... uh... yeah, okay..." It's been that kind of year. This is the kind of stuff that's starting to show up on webdevs' radars. With the release of ECMA-6 and the precompiler suites, the essential core scheme-ness of even Javascript is starting to infect us all.
  • by Anonymous Coward on Wednesday January 15, 2014 @09:41PM (#45971895)

    Register VMs began to come back into vogue at least since the Dis VM in Plan 9. The Bell Labs developers wrote a paper about Dis which effectively stated that, "yo, yo, register VMs are faster out-of-the-box, easier to optimize, and easier to translate to native code".

    By the time Dalvik came along (10 years after the Dis paper) it was already conventional wisdom that register-based VMs were the obvious choice for performance. But most projects still use stack-based VMs because they're easier to implement and easier to generate code for.

    Lua 5.0 (of almost 10 years ago) was register-based and the developers wrote a paper about it: http://www.lua.org/doc/jucs05.pdf
    Note that Lua (not just LuaJIT) blows the pants off of Python and Ruby in terms of performance, and it's largely because of their efficient VM. Lua has full lexical closures, coroutines, GC, tail calls, extensible metatypes, etc, yet it's ridiculously fast for a purely interpreted language.

    Here's the Plan 9 Dis paper: http://doc.cat-v.org/inferno/4th_edition/dis_VM_design

"I never let my schooling get in the way of my education." -- Mark Twain