I had an idea based on (or actually copied from) something Goswin mentioned earlier in our discussion. What if the bits can be used to indicate embedded values? An embedded value would have a header inside the body of the parent value, making it possible to get rid of all pointers within that parent. This would represent a potentially large saving for the GC, as well as reducing random jumps around memory which are very cache-stressing.
In the spirit of this idea, here is my latest version:
+ For 16-bit and 32-bit architectures:
+---------------+-------------+-----+-------+------+
| wosize |pfbits type |noptr| color | tag |
+---------------+-------------+-----+-------+------+
bits 31 19 18 17 16 15 14 13 12 0
pfbits type:
- 000: no pfbits
- 001: pfbits indicate embedded header
- 010: pfbits indicate float
- 011: pfbits indicate untagged type
- 100: pfbits indicate int64
- 101: pfbits indicate float/embdedded header/untagged type, 2 bits per field
- 110: pfbits indicate float/untagged type/int64, 2 bits per field
- 111: pfbits indicate embedded header/untagged type/int64, 2 bits per field
- noptr: no pointers present
- if wosize = 0, the extension word is used for wosize
- if both wosize = 0 and the pfbits are used, the wosize_large is first in memory
wosize_large word (if wosize is 0 in the header)
+---------------------------------------------+
| wosize |
+---------------------------------------------+
bits 31 0
32 bit pfbits word (present only if called for by pfbits type in header)
+---------------------------------------------+
| pfbits |
+---------------------------------------------+
bits 31 30 0
- pfbits:
- If working in 1 bit mode, each bit represents whatever is signaled in the pfbits type field.
- If working in 2 bit mode, 00 always represents a regular word, and 01, 10, 11 represent their type as signaled in the pfbit type field.
+ For 64-bit architectures:
+-------------+--------+----------+---+------+-------+------+
| pfbits | wosize |pfbit type|exp| noptr| color | tag |
+-------------+--------+----------+---+------+-------+------+
bits 63 40 39 20 19 17 16 15 14 13 12 0
- noptr: a structure with no pointers.
- pfbits: a small pfbits field for smaller objects
- pfbits type: (slightly different than 32-bit architecture)
- 000: no pfbits, wosize includes pfbits as its upper bits
- 001: pfbits indicate embedded header
- 010: pfbits indicate float
- 011: pfbits indicate untagged type
- 100: pfbits indicate int64
- 101: pfbits indicate float/untagged type/embedded header, 2 bits per field
- 110: pfbits indicate float/untagged type/int64, 2 bits per field
- 111: pfbits indicate int64/untagged type/embedded header, 2 bits per field
- exp: use pfbits_expanded for signaling pfbits. Pfbits in header become top bits of wosize.
+--------------------------------------------------------+
| pfbits_expanded |
+--------------------------------------------------------+
bits 63 0
- pfbits_expanded: if exp is set, pfbits_expanded takes the place of the pfbits. wo_size is joined with the pfbits in the header.
+ Tags:
- 0: Array, record, tuple tag
- 1: Infix tag (must be 1 mod 4)
- 2: Closure tag
- 3: Lazy tag
- 4: Object tag
- 5: Forward tag
- 6: Abstract tag
- 7: String tag
- 8: Double tag
- 9: Custom tag
- 10: Double_array tag
- 11: Proposed: Int32_array tag
- 12: Proposed: Int64_array tag
- 13: Proposed: Cptr_array tag
- 14: Proposed: float32_array tag
- 1000: first user tag
-Yotam