[m-rev.] [m-dev.] Fwd: Re: arg packing of structured values
Zoltan Somogyi
zoltan.somogyi at runbox.com
Thu Aug 30 23:26:35 AEST 2018
On Fri, 27 Jul 2018 13:23:26 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
> > Packing chars is fragile in the possible presence of such extensions.
> > I have also seen no need; in my experience, bare chars (on their own,
> > NOT inside strings) inside structures are pretty rare.
>
> FWIW, here's some examples from my CSV library:
>
> :- type comments
> ---> no_comments
> ; allow_comments(char).
>
> :- type reader_params
> ---> reader_params(
> blank_lines :: blank_lines,
> trailing_fields :: trailing_fields,
> comments :: comments,
> field_delimiter :: char
> ).
>
> Julien.
The attached diff enables the packing of chars, along the lines discussed on m-dev.
It is for post-commit review and tryout on his CSV library by Julien.
Note that the reader_params type would be packed better if comments was
the last field, since it would allow the field_delimiter to be packed into the same
word as the first two flags. This is because the comments type cannot be packed
*yet*. It should be packable later, since its representation should fit into 25 bits
on 64 bit machines (3 bits for the primary tag, which would be zero for both
function symbols, 1 bit for the local secondary tag to distinguish them, and
21 bits for the char field). The diff adds an option for packing "mini-types",
which is a piece of terminology I am proposing for du types which should be
representable in less than a word. (Given that these types are sub-word-sized,
sub-word-sized types would be another possible name, but it is clumsy, and
the obvious short version sub-types already has a different meaning.)
The implementation of packing mini types would require significantly more work,
mainly on making sure that the modules defining and importing a type agree
on which types are mini types and which are not, even in the presence of abstract
type exports.
Before someone asks: we *could* store values of the comment type in 22 bits,
but losing the fixed-zero primary tag would prevent us from using values
of the comment as direct args in other types, since this would require
being able to override the ptag.
By the way, a bootcheck with the right options found only 11 occurrences
of packable char arguments in the stage2 directory. All of these were
in representations of char constants, reading in chars, or writing out chars.
Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.pc
Type: application/octet-stream
Size: 2194 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20180830/a204373a/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.pc
Type: application/octet-stream
Size: 19768 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20180830/a204373a/attachment-0003.obj>
More information about the reviews
mailing list