Skip to content

Simulation Environment

Guille Polito edited this page Sep 22, 2021 · 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. The simulator can be parameterized with the word size, class to use as memory manager, set of bytecodes, and then the image to be launched. The class StackInterpreterSimulator launches the non-JIT simulation while CogVMSimulator launches the JIT simulation.

InterpreterStackPages initialize.
options := {
    #ObjectMemory -> #Spur64BitCoMemoryManager.
    #BytesPerWord -> 8.
    #MULTIPLEBYTECODESETS -> true.
    #bytecodeTableInitializer -> #initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid.
} asDictionary.

c := StackInterpreterSimulator newWithOptions: options.
c openOn: Smalltalk imagePath extraMemory: 100000.
c run.
InterpreterStackPages initialize.
options := {
    #ObjectMemory -> #Spur64BitCoMemoryManager.
    #ISA -> #aarch64.
    #BytesPerWord -> 8.
    #MULTIPLEBYTECODESETS -> true.
    #bytecodeTableInitializer -> #initializeBytecodeTableForSqueakV3PlusClosuresSistaV1Hybrid.
} asDictionary.

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