Hi. As the title says, the second part of the journey is over. This part consisted of 6 posts during 2 months and a half. I started explaining the most basic introduction to Smalltalk reflective model. For those readers just knowing the basis of Smalltalk but not its internal model, I’ve explained the basic classes involved in the internals such as Class, Metaclass, MethodDictionary, CompiledMethod, etc. I then talk a little about compiler’s role in the system.
Then I followed with an explanation of what is known as object (or class) format. This was necessary in order to really understand the uniqueness of CompiledMethod. I explained each format and also both sides of the game: what happens from image side and VM side. We saw how the format is encoded in objects, how the format is read, and how to create objects with different formats. We finally saw the special format of CompiledMethod.
Once we knew about object formats, we continue with an introduction to CompiledMethods. I explained how to understand the results of inspecting/exploring a CompiledMethod instance. It was necessary to explain the CompiledMethod header and trailer. Then I showed how we can decompile a CompiledMethod and using the bytecodes and literals, how to get a possible source code. Finally, it was funny to mention CompiledMethod equality 😉
After given an introduction to CompiledMethods, it followed an introduction to bytecodes (part of a CompiledMethod). Bytecodes are a fundamental part of Smalltalk and it is important to understand them. Of course, you needed to know what bytecodes are first, so that was the start. Then I explained how to understand/read/interpret the bytecodes that the system browser show us for a particular method. More interesting was to see how bytecodes are mapped to the VM code (what the VM does for each bytecode and how you can get such code). Then I showed the limitation of using one byte per bytecode and hence I presented the extended bytecodes. Finally, I mentioned the types/groups of bytecodes (they come even from the blue book) and showed them in the VMMaker code.
I then continued with a post that explained several things such as Primitives, Pragmas, Literals and their relation to CompiledMethods. Basically, the post started with a definition of method primitives and some examples. Then we saw what is a Pragma and how they are related/encoded in a CompiledMethod. Then it follows to see the impact of defining primitives in the CompiledMethod instances. Finally the post shows how primitives are mapped from image side to VM side.
The last post of this part was a pending explanation of the previous one: what are named primitives? We saw the difference between them and numbered primitives and explain the basic concepts. Then we saw that plugins can be compiled both internal or external, and then how named primitives impact CompiledMethod instances.
So…that was all. I hope you have enjoyed this part as much as I enjoyed by writing it. As always, any feedback is more than welcome. The future part? I am not sure about it 😉