Virtual Machine (Overview)
Last updated at 10:20 pm UTC on 21 June 2020
The virtual machine (VM) is an executable program you need to run the Squeak .image file.
- It has a Squeak mouse icon in your visual filer or directory viewer
- It is included in the base release
- It constitutes the platform dependent part of a Squeak system (even though most of the different VMs code is the same on all platforms)
- It is the binary executable for Squeak (on Windows platforms, it is the .exe file)
- see The Squeak Virtual Machine for info relating to the application aspects of the VM
Different types of Virtual Machines
- Interpreter VM (Linux), but available for all platforms.
- StackInterpreter VM An improved version of the Interpreter introduced in Squeak 3.10 that uses stack instead of heap for Context objects.
- Cog VM Introduced in Squeak 4.0. It adds a JIT compiler (Cogit), CoInterpreter (a variant of StackInterpreter that coexists with Cogit) and 64-bit executables.
- Spur VM Improves on Cog with new object representations for both 32-bit and 64-bit words. Released in Squeak 5.0
- SistaV1 VM (under development)
Experimental Virtual Machines
Currently, the VM executables share the same name but are not backward compatible for images. Each image type needs a matching VM. The utility ckformat prints the image format code for a given image. On Linux ports, VM run utility script, uses this utility to launch a compatible VM.
History of the Squeak Virtual Machine
(Source : http://fast.org.ar/uploads/2016/11/Friday_16h00_Eliot_Miranda_Cog_in_Motion.pdf )
A two decade history of Squeak VM is described in this paper 
The first Squeak VM Object Engine, as described in the Back To The Future paper , was simply called the Squeak VM and is now known as Context Interpreter or V3 Interpreter. Its bytecode set very close to the blue book . This virtual machine allocated objects, including Contexts, from a single linear heap wtih a slow pointer reversal garbage collect. Context objects from the heap for each non-primitive send. Its blocks were non-reentrant blocks and the object memory was a single linear heap with a slow pointer-reversal GC. As images grew larger, the performance suffered . We now use the name V3 to refer to its bytecode set and object representation. This source code was maintained in squeakvm.org and used SVN for version control.
Around 2008, Andreas Raab and Eliot Miranda, started working on speeding up this virtual machine under a new initiative known as Open Smalltalk. The source code moved to Github for version control. The VM was used not just for Squeak but also for other projects like Cuis, Pharo and Newspeak.
Open Smalltalk improved upon Squeak V3 VM in two stages. In V3 VM, Context objects were one of the most frequently allocated, but extremely short-lived objects. In the first stage, the original Deutsch & Schiffman  lazy context creation scheme was modified to eliminate context overheads by allocating them from the stack. New bytecodes werre added (V3PlusClosures or Stack bytecode set) to improve context-to-stack mapping and support re-entrant blocks . This version came to be known as StackInterpreter and given the triplet, squeak.stack.v3 in source code. The image format code also changed. Squeak 3.10 shipped image files in both V3 (6502) and stack (6504) formats but subsequent releases shipped in 6504 format only.
In the next stage, a JIT (Just-in-Time) compiler (Cog) was integrated into the Interpreter (CoInterpreter) retaining the same V3PlusClosures bytecode set and object representation . A new tweak for floating point was introduced under a new image format (6505). It was given the triplet, squeak.cog.v3. The StackInterpreter VMs continued to be used for platforms like iPhone where JIT-ing is forbidden for non-Apple applications. Cog VM was introduced in Squeak 4.x series under two image formats (6504 and 6505).
Around 2012/13, the object memory manager was redesigned with a better garbage collector and object representation. It introduced comprehensive support for 64-bit words and replaced the single heap with a segmented heap that could grow and shrink, support for pinning and read-only objects and a much faster become: primitive. An incremental compactor was also added. This design was known as Spur with both 32-bit and 64-bit image variants under the triplet code, squeak.cog.spur. Spur takes only 60% of the time that Cog took to interpret bytecodes. Squeak 5.x series used this VM to run both 32-bit (6521) and 64-bit (68021) image formats.
Currently, work is in progress on an adaptive optimizer to further improve performance. This has two parts - one in the VM and the other in the image. The optimizer in the VM is called Sista (Speculative Inlining Smalltalk Architecture)  and image-level optimizer is called Scorch . Sista was the topic of Clément Bera’s PhD . This is tagged with the triplet squeak.sista.spur.
- Two Decades of Smalltalk VM Development: Live VM Development Through Simulation Tools, https://doi.acm.org/10.1145/3281287.3281295
- Back to The Future: The Story of Squeak, A Practical Smalltalk Written in Itself, https://doi.org/10.1145/263698.263754
- Part 4 of Smalltalk-80 - The Language and its Implementation, http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf
- Efficient implementation of the smalltalk-80 system, https://doi.org/10.1145/800017.800542
- Lazy Pointer Update for Low Heap compaction Pause Times, https://doi.org/10.1145/3359619.3359741
- Sista: Saving Optimized Code in Snapshots for Fast Start-Up, https://doi.acm.org/10.1145/3132190.3132201
- Sista: a Metacircular Architecture for Runtime Optimisation Persistence, https://hal.inria.fr/tel-01634137/file/FinalThesis.pdf