Building a Cog Development Image

The Cog VM source is in a Squeak Smalltalk Monticello package at http://source.squeak.org/VMMaker.  Load the newest version of  VMMaker.oscog, e.g. VMMaker.oscog-eem.2345 (*).

Building the image manually is tedious.  Fortunately an automated build using the current Squeak release is provided in the image subdirectory of http://www.github.com/OpenSmalltalk/opensmalltalk-vm.

$ git clone http://www.github.com/OpenSmalltalk/opensmalltalk-vm
$ cd opensmalltalk-vm/image
$ cat README # this may be more up-to-date than this blog page
$ ./buildspurtrunkvmmakerimage.sh    # or buildspurtrunkvmmaker64image.sh

 

This almost works perfectly; but…
  • on Windows you’ll need to use Cygwin and install wget, e.g. from from http://gnuwin32.sourceforge.net/packages/wget.htm, probably as http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe
  • the second part of the build loads VMMaker.oscog and the support packages.  During this you’ll get prompted for your initials.  Supply some to proceed.
Once you’ve built a VMMaker image, read the class comments of StackInterpreterSimulator and CogVMSimulator for running the simulator.  Alternatively use the example expressions in VM Simulation Workspace.text.  Slang test expressions are provided in Slang Test Workspace.text.   Test expressions that run the JIT to produce machine code disassembly from methods in the image are provided in In-image Compilation Workspace.
Clément has done a lovely screen cast showing how the simulator is used to develop the VM.  In this case he debugs a code generation error in the speculative inlining JIT. https://www.youtube.com/watch?v=hctMBGAXVSs.  And here’s his accompanying blog post.

The VM source is generated from as VMMaker.oscog image whenever required.  For the official source tree, which resides on github (see http://www.mirandabanda.org/cogblog/compiling-the-vm/) this is done by core developers on an as-needed basis.  For one’s own development, generate the source as and when you see fit.  For much of the time one can develop a VM using there simulator, but soon enough one will want to generate a real VM or have to debug the real VM because while the simulator is powerful, it is slow and of necessity incomplete (for example, the simulator cannot yet simulate FFI calls).

(*) The VMMaker package is for the Interpreter VM and the VMMaker-oscog package is an obsolete version of the Pharo version of Cog.

   Send article as PDF