Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
VM Simulation
Last updated at 8:23 am UTC on 13 February 2020
VMMaker comes with a built-in simulator for live testing and debugging of VM code in both little-endian or big-endian modes. The code may be found in:
The simulator works either in command line (aka reader) or in a Morphic Window. When running in a Morphic window, a tiny rectangle flashes at the top right corner to indicate that the simulation is on and waiting. The bottom left panel acts as a logger and the bottom right panel displays a synthetic timer tick. It also throws up the debugger menu on right click. This menu may be used to switch the log from bottom left panel to Transcript and vice versa, examine stack frames, methods and oop and so on.

Simulating a VM session

The Morphic mode is very slow but it allows high-level development of VM. There are many ways of coping with the slowness of simulation

Building Images for Simulation

The image/ subdirectory of opensmalltalk source distribution contains different build scripts to build a development image. The script will download the latest Squeak version (trunk), install VMMaker and associated packages and generate a development image. The reader image uses the command line as console while the vmmaker images using Morphic window and menus.

The Morphic development image contains a VM Simulation Workspace contains numerous examples of simulations of StackInterpreter or Cog VMs.

Working with Reader image

For testing the core classes, one can launch the reader image in headless mode. Input is read in chunk format. Results and debug logs are printed on the same console. Here are some examples:
Smalltalk quitPrimitive !
Smalltalk snapshot: true andQuit: true !
Smalltalk globals !
Symbol class superclass !
Smalltalk class methodDict keys !
Time millisecondsToRun: [Object allSubInstances size ] !
[Integer respondsTo: #factorial ] bench !

Constraints and Workaround

Cog can simuate 6505 images and some 6504 images, but it cannot simulate 6502 images. To workaround this constraint, one can open these images in Cog and save the image. The newly saved image will be in 6505 format and can be simulated in Cog.

See Also

  1. Sista VM Live Debugging in a Simulator
  2. Simulating the Cog VM