Last week I have looked at VMMaker.
VMMaker is a tool that let you write the interpreter of Squeak.
VMMaker is written in Squeak. So you can read slang(a subset of smalltalk) to understand how the VM work.
Slang are translated to C that is part of the VM code source.
I have implemented some primitive to make BlockClosure faster.
In Squeak primitives are special methods that are built inside the VM.
To specify a primitive you have to use the pragma #primitive:
Take a look at SmallInteger>>+
If you have VMMaker loaded inside the image you can see what the VM dose.
The corresponding method of SmallInteger>>+ is Interpreter>>primitiveAdd.
So when the message #+ is sent to an integer the VM call the subroutine primitiveAdd.
Most of the time Slang only call ObjectMemmory and Interprete methods.
The both classes represent the internal state of the VM. They also manipulate reify contexts.
For optimizing the BlockClosure I have implemented 2 primitive one for #value and one for either #value: or #value:value:…
Now the performance of the closure are closed to the old block.
I have also discussed with Marcus Denker to know which bytecodes should be implemented. We finally agreed on 3 bytecodes:
- creating the ClosureEnvironment(CE)
- store in the CE
- push in the CE
A part from VMMaker I also contnue fixing the decompiler for closure.
Especially for scope and captured variable.
Still, the decompiler for old block is finish and ready to use