3 ms·
Wouldn't the different layout of these packed bits result in the code which would never have to clear some bits in the second byte? Is that layout fully interna
by acqq 9y ago
Wouldn't the different layout of these packed bits result in the code which would never have to clear some bits in the second byte? Is that layout fully internal to the Ocaml gc?
- jorisgio 9y agoI'm not really qualified to explain why such a layout was chosen, my understanding of ocaml internal is limited. The header layout is described here : https://github.com/ocaml/ocaml/blob/4.04.2/byterun/caml/mlvalues.h#L82 https://github.com/ocaml/ocaml/blob/4.04.2/byterun/caml/mlva... I believe it's internal to the compiler/runtime/C interface (but hidden under abstraction), unless Marshal (an unsafe low level binary serialization format for ocaml values depends on it) The lowest byte is filled with the tag. I guess it should be possible to swap the color and the tag, or put the color at the beginning before the size, but that probably would have a different tradeoff. The tag is used for instance in pattern matching and in a lot of code. With this layout it can be accessed easily, which might be the reason the color is put in the second byte