[m-dev.] arg packing of structured values

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu Jul 26 13:40:42 AEST 2018


Given the types

:- type t1
    --->    t1f1(bool, bool).

:- type t2
    --->    t2f1(bool, bool, bool).

that the compiler will soon be able to represent in less than
one word each (I am working on that now), consider this type:

:- type t
    --->    tf(t1, int8, t2).

With our current type representation, this will occupy three words
on the heap even if argument packing is turned on, because we can
now pack two or more arguments into a word only if the arguments
are either enums or sub-word-sized integers. While types t1 and t2
fall into neither category, their representations *do* occupy a known,
small number of bits. It should therefore be possible to represent
values of type t in less than one word, *without* any heap allocation,
by giving them the same representation as we would give to

:- type t'
    --->    tf'(bool, bool, int8, bool, bool, bool).

Something similar should also be possible if t1 and t2 have
more than one function symbol, as long as *all* of them
are representable in less than a word.

My question for you guys is: would this be a useful thing to implement?
Do you know of any set of types in programs you know of to which
this optimization is applicable? Or should I try to find such type sets
by implementing the applicability test for this optimization, and
getting the compiler to spit out informational messages about
any types for which the test succeeds?

Zoltan.


More information about the developers mailing list