Runtime code generation (by )

Spurred by a thread on comp.os.research, I've been reading up on the Synthesis OS design.

Wiki page about Synthesis

The original thesis

This looks like good work, insipring for ARGON; with HYDROGEN explicitly exposing runtime code generation primitives, like any good FORTH system, and the CHROME metaprogramming stuff is based around run time code generation.

I'd hoped to look at how to optimise the system using runtime generation for common stuff - but I expected to have to experiment later; luckily, this fine fellow has blazed a trail for me!

However, I can't help but feel this is more of a programming language issue than an operating systems issue. The author has written an OS in assembly language, and implemented much of it by generating specialised code on the fly rather than jumping to the general code that then has to analyse its dynamic context every time it's executed to decide which control path to take, and having to load data indirectly rather than having it as an immedate value. Surely this stuff should be generalised into a way of optimising all code, rather than just being used in an operating system? I don't see the fundamental technique as being particularly bound to operating systems - lots of applications could benefit from it.

For ARGON, I'd like to use the metaprogramming facilities I've already planned for CHROME to build a toolkit that makes runtime specialisation optimisation easier. Maybe even look into making it happen automatically, although I suspect that the tradeoff involved may require human intervention at heart. A lot of the benefits could be had anyway by just compiling the code in a custom environment containing the constants, which will be constant-propogated and constant-folded and the used as immediate values - but I think those cunning executable data structures need more thinking about...


  • By Derek, Fri 1st Oct 2004 @ 8:06 am

    I think this is the difference between commercial smalltalk environments and free ones, the commercial ones have specialization and optimization of execution. I think this kind of thing shows up in some Lisp engines as well.

  • By alaric, Fri 1st Oct 2004 @ 8:25 am

    I was always impressed by Self.

    The runtime system (amongst other optimisations) would dynamically generate method invocation code that used a cache of common method implementations it would end up dispatching to. So wherever "foo.someMethod()" is called, the generated machine code goes "is foo an instance of Car? If so, jump to this address. Is it an instance of Lorry? If so, jump to this address. ... Otherwise, call the generic inheritance-graph-walker, which also happens to gather statistics on how often it is called in order to decide if a cached invocation somewhere needs recompiling"

Other Links to this Post

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes

Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales