I am implementing a virtual machine in x86, and I wonder what design will give the best results. What should I focus on to dry the juice? I will implement the entire virtual machine in the x86 assembly.
I have few instructions, and I can choose their form. The instructions are executed directly in the smalltalk syntax in blocks. I outline the design of the instruction I was thinking about:
^ ...
The kind of VM I was thinking about:
mov eax, [esi] add esi, 2 mov ecx, eax and eax, 0xff and ecx, 0xff00
Don't start asking why I need another virtual machine implementation. Interpretation routines are not stocks that you simply collect when you need them. Most virtual machines that you offer elsewhere are weighed toward portability with the cost of performance. My goal is not portability, my goal is productivity.
The reason this interpreter is needed at all is because smalltalk blocks cannot be interpreted the same way:
A := B subclass: [ def a:x [^ x*x] clmet b [...] def c [...] def d [...] ] [ 2 < x ] whileTrue: [...] (i isNeat) ifTrue: [...] ifFalse: [...] List fromBlock: [ "carrots" "apples" "oranges" toUpper ]
I need real benefit from interpretation procedures, that is, choosing the context where the program should be read. Of course, a good compiler should simply in most cases compile obvious cases, such as: ifTrue: ifFalse or 'whileTrue:' or an example list. The need for an interpreter does not just disappear, because you can always encounter a situation where you cannot be sure that the unit will receive the treatment that you expect.
source share