So I've been doing my damnedest to avoid the whole MEGA SOFTWARE PROBLEM and have been working on a few projects in a sort of back to basics fashion. My recent projects include:
- a new Virtual Machine for NewScript - ~168 statements of C in 164 lines
- a full compiler for the new NewScript VM - ~52 statements of Perl in 90 lines
What is incredible about all of this is not what you can do with these systems, but with how incredibly independent of the underlying operating system they could be. The amount of change required to run the NewScript VM on bare hardware consists of using a boot loader, writing to video memory rather than my faked up one, and handling a keyboard interrupt. The compiler itself is easy to rewrite in NewScript, and will be the project for next week. I'm estimating the native Intel compiler for the NewScript VM at 96 lines of NewScript. 32 lines for the opcodes, and 64 lines to do everything else. I'll be happy as long as it weighs in under 200 lines though, which is pretty slick for an native optimizing compiler.
Some preliminary tests on some of the code generation tricks and VM layout puts the performance of the generated code at that of GCC -O2 optimizations, with all of the functions inlined. That happens to be exactly what the current C code base compiles with, but not for debugging because GDB goes into convulsions, (and because -O3 optimizations occasionally break things). Compared to its own C version, the native version will be at least 20-30% faster, as the code will be direct rather than indirect threaded.