2014-08-28 18:12:46 +02:00
|
|
|
### Virtual OO Machine
|
|
|
|
|
|
|
|
This is really an OV (object value) not object oriented machine.
|
|
|
|
|
|
|
|
Integers and References are Values. We make them look like objects, sure, but they are not.
|
|
|
|
Symbols have similar properties and those are:
|
|
|
|
|
2014-08-28 21:32:53 +02:00
|
|
|
- equality means identity
|
|
|
|
- no change over lifetime
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
It's like with Atoms: they used to be the smallest possible physical unit. Now we have electrons,
|
|
|
|
proton and neutrons. And so objects are made up of Values (not objects), integers, floats ,
|
|
|
|
references and possibly more.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
Values have type in the same way objects have a class. We keep track of the type of a value at runtime,
|
|
|
|
also in an similar way that objects have their classes at runtime.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-05-24 12:42:29 +02:00
|
|
|
### Layers
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-05-24 12:42:29 +02:00
|
|
|
*Ast* instances get created by the [salama-reader](https://github.com/salama/salama-reader) gem from
|
|
|
|
source. Here we add compile functions to ast classes and compile the AST layer into
|
|
|
|
Virtual::Objects and Parfait::Values
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-05-24 12:42:29 +02:00
|
|
|
The main objects are Space (lots of objects), BootClass (represents a class),
|
2014-08-28 18:12:46 +02:00
|
|
|
CompiledMethod (with Blocks and Instruction).
|
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
**Virtual** Instructions get further transformed into **register** instructions.
|
|
|
|
This is done by an abstractly defined Register Machine with basic Intructions.
|
|
|
|
A concrete implementation (like Arm) derives and creates derived Instructions.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
The transformation is implemented as **passes** to make it easier to understand what is going on.
|
2015-05-24 12:42:29 +02:00
|
|
|
Also this makes it easier to add functionality and optimisations from external (to the gem) sources.
|
2014-08-28 21:32:53 +02:00
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
The final transformation assigns Positions to all boot objects (Linker) and assembles them into a
|
|
|
|
binary representation. The data- part is then a representation of classes in the **parfait** runtime.
|
|
|
|
And the instrucions make up the funtions.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
|
|
|
### Accessible Objects
|
|
|
|
|
|
|
|
Object oriented systems have data hiding. So we have access to the inner state of only four objects:
|
|
|
|
|
|
|
|
- Self
|
|
|
|
- Message (arguments, method name, self)
|
|
|
|
- Frame (local and tmp variables)
|
|
|
|
- NewMessage ( to build the next message sent)
|
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
A single instructions (Set) allows movement of data between these.
|
|
|
|
There are compare, branch and call intructions too.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
|
|
|
### Micro
|
|
|
|
|
|
|
|
The micro-kernel idea is well stated by: If you can leave it out, do.
|
|
|
|
|
|
|
|
|
2015-05-24 12:42:29 +02:00
|
|
|
As such we are aiming for integer and reference (type) support, and a minimal class system
|
2014-08-28 21:32:53 +02:00
|
|
|
(object/class/aray/hash/string). It is possible to add types to the system in a similar way as we add classes,
|
|
|
|
and also implement very machine dependent functionality which nevertheless is fully wrapped as OO.
|
2014-08-28 18:12:46 +02:00
|
|
|
|
2015-03-25 16:29:39 +01:00
|
|
|
**Parfait** is that part of the runtime that can be coded in ruby.
|
|
|
|
It is parsed, like any other code and always included in the resulting binary.
|
|
|
|
**Builtin** is the part of the runtime that can not be coded in ruby (but is still needed).
|
|
|
|
This is coded by construction CompiledMethods in code and neccesarily machine dependant.
|