[Vm-dev] VM Maker: VMMaker.oscog-eem.1522.mcz
eliot.miranda at gmail.com
Fri Nov 20 16:46:58 UTC 2015
Hi Bert, Ben,
> On Nov 19, 2015, at 1:56 AM, Bert Freudenberg <bert at freudenbergs.de> wrote:
>> On 19.11.2015, at 00:05, Ben Coman <btc at openinworld.com> wrote:
>> How does Slang related to the interpreter?
>> i.e. Is it Slang that the interpreter interprets?
> Slang is the language the interpreter and Cog / Spur etc. are written in.
> It looks like Smalltalk, but has C semantics. There are no classes or objects, it pretty much only operates on integers and pointers. It can be run directly as Smalltalk (which is what the VM simulator does) but its main purpose is to be transcribed 1-to-1 to C to be compiled by a C compiler into a VM binary.
I view things a bit differently. Yes, there are three components here:
1. the subset of Smalltalk, called Slang, in which the VM is written
2. the subclasses of the interpreters and memory managers that flesh-out the VM into a VM simulator. For example these subclasses provide code to model C integer semantics using Smalltalk's infinite precision integers. They add to the code in 1 to make the simulation run.
3. The Slang-to-C compiler that translates #1 into C code that is compiled to produce the final VM.
I use the term to describe both 1 & 3 because I see the Slang-to-C because I'm confused. But bear with me.
Slang isn't a well-defined language. Bert is right in that the original system didn't support objects or classes, just two hierarchies of ObjectMemory, it's subclass Interpreter, and it's subclass InterpreterSimulator, and InterpreterPlugin and all the plugins as subclasses, many with their own plugin simulator subclass.
But to implement Cog I have extended Slang significantly:
- one can pass literal blocks as arguments provided these will be inlined. This is typically used for collecting multiple return values, but is also used to implement iteration
- there are many more singleton classes, the interpreter is no longer a subclass of the memory manager, the spur memory manager has the scavenger and segment manager as singletons, the Cogit (the JIT compiler) contains object representation and method zone manager singletons
- simple objects are now supported. These are objects that can be mapped to C structs. They are used to implement
• individual instructions and stack entries in the cogit
• stack pages in the stack zone
• machine code methods in the method zone
- there is support for more types than simply integers (the above structs, pointers) and there's a fair bit of type inference machinery to deal with this, including the need to accurately infer 32-bit and 64-bit integers in 32-bit Spur because an object header is 64-bits
So personally I find it a bit misleading to say that the VM is written in Slang, a subset of C. Instead I think of it that the VM is written in an expanding subset of Smalltalk that is whatever the Smalltalk-to-C translator is capable of translating. And since that's a mouthful I use Slang to refer to the pair, the expanding subset and it's translator.
> - Bert -
More information about the Vm-dev