Danny Yoo <firstname.lastname@example.org>
Warning: this is work in progress!
The GitHub source repository to Whalesong can be found at https://github.com/dyoo/whalesong.
At the time of this writing, Whalesong hasn’t been deployed to PLaneT yet, so getting it requires doing a little bit of manual work. The steps are:
Check Whalesong out of Github.
Set up the PLaneT development link to your local Whalesong instance.
Run raco setup over Whalesong to finish the installation
$ git clone git://github.com/dyoo/whalesong.git
$ planet link dyoo whalesong.plt 1 0 whalesong
$ raco setup -P dyoo whalesong.plt 1 0
Let’s try making a simple, standalone executable. At the moment, the program must be written in the base language of (planet dyoo/whalesong). This restriction currently prevents arbitrary racket/base programs from compiling, and the developers will be working to remove this restriction.
$ racket hello.rkt
$ whalesong build hello.rkt
$ ls -l hello.xhtml
-rw-rw-r-- 1 dyoo nogroup 692213 Jun 7 18:00 hello.xhtml
(This section should describe the whalesong language.)
(This section should describe the whalesong launcher and the options we can use.)
Please skip this section if you’re a regular user: this is really notes internal to Whalesong development, and is not relevant to most people.
parse-bytecode.rkt -----> compiler.rkt ----> assembler.rkt
(We try to insulate against changes in the bytecode structure by using the version-case library to choose a bytecode parser based on the Racket version number. Add more content here as necessary...)
This translates the AST to the intermediate language. The compiler has its origins in the register compiler in Structure and Interpretation of Computer Programs with some significant modifications.
Since this is a stack machine, we don’t need any of the register-saving infrastructure in the original compiler. We also need to support slightly different linkage structures, since we want to support multiple value contexts. We’re trying to generate code that works effectively on a machine like the one described in http://plt.eecs.northwestern.edu/racket-machine/.
The intermediate language is defined in "il-structs.rkt", and a simulator for the IL in "simulator/simulator.rkt". See "tests/test-simulator.rkt" to see the simulator in action, and "tests/test-compiler.rkt" to see how the output of the compiler can be fed into the simulator.
argcount: number of arguments
env: environment stack
control: control stack
Each basic block is translated to a function taking a MACHINE argument.
Every GOTO becomes a function call.
The head of each basic-blocked function checks to see if we should trampoline (http://en.wikipedia.org/wiki/Trampoline_(computers))
We support a limited form of computed jump by assigning an attribute to the function corresponding to a return point. See the code related to the LinkedLabel structure for details.
Otherwise, the assembler is fairly straightforward. It depends on library functions defined in "runtime-src/runtime.js". As soon as the compiler stabilizes, we will be pulling in the runtime library in Moby Scheme into this project. We are right in the middle of doing this, so expect a lot of flux here.
The assembled output distinguishes between Primitives and Closures. Primitives are only allowed to return single values back, and are not allowed to do any higher-order procedure calls. Closures, on the other hand, have full access to the machine, but they are responsible for calling the continuation and popping off their arguments when they’re finished.
(This section should describe what needs to get done next.)
big bang info
(I should catalog the bug list in GitHub, as well as the feature list, so I have a better idea of what’s needed to complete the project.)
(We also need a list of the primitives missing that prevent us from running racket/base; it’s actually a short list that I’ll be attacking once things stabilize.)