Someone recently published a blog article about the sizes of values in the Ruby and OCaml programming languages.
This is also interesting in the context of HLVM because our high performance goals also require an efficient memory representation but our solution is quite different to OCaml's because HLVM is designed for numerical performance whereas OCaml was designed for symbolic performance.
The following table lists the sizes of values of several different types in OCaml and HLVM on 32-bit architectures:
|unit||32 bits||32 bits|
|bool||32 bits||8 bits|
|int32||96 bits||32 bits|
|int64||128 bits||64 bits|
|float64||128 bits||64 bits|
|float * float||320 bits||128 bits|
|Enumeration||32 bits||96 bits|
|float64 array||64+64n bits||96+64n bits|
Note how HLVM uses the most memory efficient representations possible for ints, floating point numbers and tuples but uses less efficient representations for reference types such as arrays and variant types. A side-effect is that heaps in HLVM contain far fewer pointers than heaps in OCaml and this greatly reduces the stress on the garbage collector.