Skip to content

Simulation Environment

Hernán Morales Durand edited this page Aug 21, 2023 · 3 revisions

The VM simulation environment, described in two decades of smalltalk vm development and Cross-ISA Testing of the Pharo VM: Lessons Learned While Porting to ARMv8 can be obtained in many different ways.

Dependencies

The current simulation environment and VM generator runs on top in Pharo 9 and Pharo 10. If you're not interested on working in JIT simulation, a standard Pharo development environment is enough.

If you're interested on JIT simulation, you will need to install the Unicorn machine code simulation library. To install this library, go to https://github.com/tesonep/unicorn and follow the build instructions (usually boiled down to a make install).

Building from the VM simulator git repository

If you're starting from a clone of this git repository, one possibility is to create a simulator environment by using our automated cmake process.

$ cmake -B /path/to/build/directory -S /path/to/git/repo
$ cmake --build /path/to/build/directory --target vmmaker

That will create an image with the simulation environment on /path/to/build/directory/build/vmmaker/image and download in /path/to/build/directory/build/vmmaker/vm a virtual machine with the corresponding version.

Starting from a normal Pharo image

An alternative approach, when starting from a standard Pharo image, is to load the vm git repository inside Pharo through Iceberg. This can be done either by cloning or by importing an already cloned repository. Then, the BaselineOfVMMaker should be installed through Metacello.

Launching the Simulator

The simulator can be launched through the following scripts. It can be parameterized with the word size, class to use as memory manager, set of bytecodes, and then the image to be launched.

Launching the Stack Interpreter Simulator

The following script launches the non-JIT simulation currently implemented by StackInterpreterSimulator.

| options stackInterpreterSimulator |

VMStackPages initialize.
options := {
    #ObjectMemory -> #Spur64BitCoMemoryManager.
    #BytesPerWord -> 8
} asDictionary.

stackInterpreterSimulator := StackInterpreterSimulator newWithOptions: options.
stackInterpreterSimulator openOn: Smalltalk imagePath extraMemory: 100000.
stackInterpreterSimulator run.

Launching the Cog VM Simulator

The followin script launches the JIT simulation implemented in CogVMSimulator.

| options cogVMSimulator |
VMStackPages initialize.
options := {
    #ObjectMemory -> #Spur64BitCoMemoryManager.
    #ISA -> #aarch64.
    #BytesPerWord -> 8
} asDictionary.

cogVMSimulator := CogVMSimulator newWithOptions: options.
cogVMSimulator openOn: Smalltalk imagePath extraMemory: 100000.
cogVMSimulator run.
Clone this wiki locally