Mercury Bugs - mercury
View Issue Details
0000447mercuryFeature Requestpublic2018-02-06 18:162018-02-06 18:16
Assigned Tozs 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000447: direct_arg_switch type representation
DescriptionSome types, such as item and pragma_type in the Mercury compiler,
consist of many functors of arity 1, each of whose arguments is a structure
represented by an aligned pointer to the heap.

At the moment, on 64 bit machines, we represent the first 7 functors
as tagged pointers to those structures, and the remaining functors
as two-word cells on the heap, with the first word being a secondary tag
and the second being the structure pointer to the argument.

This is probably the best representation we can get *if* the first 7 functors
are the ones that occur most often. However, this may not be the case.
Programmers can reorder the functors to *make* it the case, but this may
not be desirable on software engineering grounds; for example, it may
require that related functors not be put next to each other.

It would be nice to have a pragma that tells the compiler the order of
frequency of occurrence of the functors, so it can optimize the representation
of the most frequently occurring functors. (Specifying the complete order
would make this work regardless of the number of primary tag bits available.)

It would be even better if a profiler generated that information automatically.
This could be done by instrumenting e.g. every complete switch on the type
to record which branch was taken.
TagsNo tags attached.
Attached Files

There are no notes attached to this issue.

Issue History
2018-02-06 18:16zsNew Issue
2018-02-06 18:16zsStatusnew => assigned
2018-02-06 18:16zsAssigned To => zs