[m-rev.] for review: Make subtypes share low-level data representation with base type.

Peter Wang novalazy at gmail.com
Fri Apr 9 14:31:45 AEST 2021


On Thu, 08 Apr 2021 20:57:58 +1000 Julien Fischer <jfischer at opturion.com> wrote:
> 
> Hi Peter,
> 
> On Thu, 25 Mar 2021, Peter Wang wrote:
> 
> > Make subtypes share data representation with base type when using
> > low-level data. High-level data grades are unchanged, so subtypes
> > are still represented with distinct classes from their base types.
> 
> ...
> 
> > runtime/mercury_type_info.h:
> >    Add a flag in MR_TypeCtorInfo to indicate if the enum/du layout
> >    array may be indexed by an enum value or du ptag value.
> >    Subtypes break the invariant that the layout array contains entries
> >    for every enum/ptag value from 0 up to the maximum value.
> >    The presence of the flag MR_TYPE_CTOR_FLAG_LAYOUT_INDEXABLE tells
> >    the runtime that it can directly index the layout array instead of
> >    searching through it (which is the common case, for non-subtypes).
> >
> >    Add a field MR_du_ptag to MR_DuPtagLayout. This is necessary to find
> >    an entry for a given primary tag value in a MR_DuPtagLayout array.
> >
> >    Add a field MR_du_ptag_flags to MR_DuPtagLayout, currently with one
> >    possible flag MR_DU_PTAG_FLAG_SECTAG_ALTERATIVES_INDEXABLE.
> 
> s/ALTERATIVES/ALTERNATIVES/  (and also in the code).

Oops, fixed.

> 
> > diff --git a/compiler/decide_type_repn.m b/compiler/decide_type_repn.m
> > index b21828251..6a1a8e90c 100644
> > --- a/compiler/decide_type_repn.m
> > +++ b/compiler/decide_type_repn.m
> 
> > @@ -393,8 +453,13 @@ decide_type_repns_stage_1_du_not_all_plain_constants(TypeCtor, DuDefn,
> >             )
> >         ;
> >             TailCtors = [_ | _]
> > -        % The type has exactly two or more data constructors.
> > +            % The type has two or more data constructors.
> >             % This means that it need not be word aligned.
> 
> Has the indentation gone funny there or is that just a diff artifact?
> 

I think I sent this patch with diff -b and forgot to mention it.
There's no problem in the file.

> That looks fine otherwise.

Thanks for the reviews.

Peter


More information about the reviews mailing list