Runtime
The runtime is implemented in Rust.
Code Generation
Code is generated at runtime, just-in-time.
The backend is implemented specifically for Core and does not rely on the LLVM or other frameworks.
Supported architectures are AMD64 and ARM64. A backend for the RISC-V architecture (RV64G) is work-in-progress.
Garbage Collection
While the language encourages the use of immutable value types (keyword value),
reference-based types (keyword class) are available and managed by precise garbage collection.
Memory Layout
This is a design draft.
high addresses non-canonical addresses low addresses
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+
OS process: | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ |
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+
╰───────────────┬───────────────╯
available user-space virtual memory (128TiB address space)
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+
Core runtime: | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊XXX| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ x ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊x |
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+
╰─┬─╯ | |
1TiB: reserved object space ?MiB: reserved code space 1GiB: reserved vtable space
... allocators will then work with these reserved spaces, committing memory by placing data in those spaces.
Core alloc: ...
Core GC: ...
Object Layout
Values
Numbers
integer values (64 bit)
+---------------+---------------+
| ┊ ┊ ┊ | ┊ ┊ ┊ |
+---------------+---------------+
╰───────────────┬───────────────╯
64 bits: signed value
integer values (32 bit)
+---------------+
| ┊ ┊ ┊ |
+---------------+
╰───────┬───────╯
32 bits: signed value
floating-point values (64 bit)
11 bits: exponent
╭──┴─╮
+---------------+---------------+
| ┊ ┊ ┊ | ┊ ┊ ┊ |
+---------------+---------------+
│ ╰─────────────┬───────────╯
1 bit: sign 52 bits: mantissa
floating-point values (32 bit)
8 bits: exponent
╭─┴─╮
+---------------+
| ┊ ┊ ┊ |
+---------------+
│ ╰────────┬─╯
1 bit: sign 23 bits: mantissa
Unions
tag-based union values
+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | union value ...
+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰───────┬───────╯
32 bits: tag bits
References
There is ongoing work to reduce the size of the object headers (which contain a vtable pointer and forwarding pointer) from 16 bytes to 8 bytes.
This will decrease the size of everything reference-based – of regular class instances, array and string instances, trait-boxed instances and reference-based union instances.
regular class instances
37 bits: forwarding pointer
╭───────┴─────────╮
+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | instance fields ...
+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰─────┬─────╯ ╰─┤
24 bits: vtable pointer 3 bits: fwd/mark bits
array instances
37 bits: forwarding pointer 64 bits: array size
╭───────┴─────────╮ ╭───────────────┴───────────────╮
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | array elements ...
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰─────┬─────╯ ╰─┤
24 bits: vtable pointer 3 bits: fwd/mark bits
string instances
37 bits: forwarding pointer 36 bits: string size
╭───────┴─────────╮ ╭───────┴─────────╮
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | utf8 bytes ...
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰─────┬─────╯ ╰─┤ ╰───────┬───────╯
24 bits: vtable pointer 3 bits: fwd/mark bits 32 bits: hash code
trait-boxed instances
37 bits: forwarding pointer
╭───────┴─────────╮
+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | instance ...
+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰─────┬─────╯ ╰─┤
24 bits: vtable pointer 3 bits: fwd/mark bits
Classes
regular class instances
62 bits: vtable pointer 61 bits: forwarding pointer
╭───────────────┴──────────────╮╭───────────────┴─────────────╮
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ ┊ ┊ ┊ ┊ | instance fields ...
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰┤ ╰─┤
2 bits: forward bits 3 bits: mark bits
array instances
62 bits: vtable pointer 61 bits: forwarding pointer 64 bits: array size
╭───────────────┴──────────────╮╭───────────────┴─────────────╮ ╭───────────────┴───────────────╮
+---------------+---------------+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ ┊ ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | array elements ...
+---------------+---------------+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰┤ ╰─┤
2 bits: forward bits 3 bits: mark bits
string instances
62 bits: vtable pointer 61 bits: forwarding pointer 36 bits: string size
╭───────────────┴──────────────╮╭───────────────┴─────────────╮ ╭───────┴─────────╮
+---------------+---------------+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ ┊ ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ | utf8 bytes ...
+---------------+---------------+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰┤ ╰─┤ ╰───────┬───────╯
2 bits: forward bits 3 bits: mark bits 32 bits: hash code
Traits
trait-boxed instances
62 bits: vtable pointer 61 bits: forwarding pointer
╭───────────────┴──────────────╮╭───────────────┴─────────────╮
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
| ┊ ┊ ┊ | ┊ ┊ ┊ | ┊ ┊ ┊ ┊ ┊ ┊ ┊ | instance ...
+---------------+---------------+---------------+---------------+─ ─ ─ ─ ─ ─ ─ ─
╰┤ ╰─┤
2 bits: forward bits 3 bits: mark bits
Unions
trait-boxed union instances
...
reference-based union instances
+---------------+---------------+
| ┊ ┊ ┊ | ┊ ┊ ┊ |
+---------------+---------------+
╰───────────────┬───────────────╯
64 bits: reference or null-pointer