2 ms·
This is a really cool system and has a lot of neat features. I used it for experimental Clojure VM. Here I have library that shows how to use it from Rust with
by nickik 7y ago
This is a really cool system and has a lot of neat features. I used it for experimental Clojure VM.
Here I have library that shows how to use it from Rust with one pre-defined memory layout for the objects.
For people that are interested, here is an example of how to use it for a Clojure like language:
https://github.com/clojit/clojit-cvm/blob/master/vm.c#L176 https://github.com/clojit/clojit-cvm/blob/master/vm.c#L176
It lays out the memory like this:
0 1 2 4 8
+---+---+-------+-------------+ <- 0
|mps| | class|size |
+-----------------------------+
| tagged reference |
+-----------------------------+
| tagged reference |
+-----------------------------+
| tagged reference |
+-----------------------------+
| tagged reference |
+-----------------------------+ <- size
mps here are a few bits you have to reserve to tell what MPS object it is. Padding and Forward you need to support in order for MPS to be able to move your objects.
const uint8_t OBJ_MPS_TYPE_PADDING = 0x00;
const uint8_t OBJ_MPS_TYPE_FORWARD = 0x01;
const uint8_t OBJ_MPS_TYPE_OBJECT = 0x02;