[m-rev.] for review: fix expand equivalence type for special preds bug

Peter Ross pro at missioncriticalit.com
Sat Nov 9 03:28:11 AEDT 2002


fjh wrote:
> On 08-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > Fix a bug highlighted by the .NET backend where the comparison,
> > unification and index predicates for types defined as equivalence
> > types were being generated refering to the original types instead of
> > the expanded out equivalent type.
>
> It occurred to me just now that an alternative way of solving this
> problem would be to just not emit type_ctor_infos, unification predicates
> or comparison predicates for equivalence types in the .NET and Java
> back-ends.  These back-ends require all equivalence types to be fully
> expanded, so the type_ctor_infos and unify/compare predicates for those
> types will never be referenced, I'm pretty sure.
>
Only way to find out is to try.

> > compiler/rtti.m:
> > Record the the actual argument types for a special predicate
> > in the rtti_proc_label type.
>
> What was the rationale for this bit of the change?
>
Because the expanded types are needed in ml_gen_proc_params_from_rtti.
They are cached for the same reason that is_special_pred is cached: to free
the pred_info for GC.

> > compiler/ml_call_gen.m:
> > compiler/ml_closure_gen.m:
> > compiler/ml_code_gen.m:
> > compiler/ml_code_util.m:
> > Use the types where all the equivalence types have been
> > eliminated.
> >
> > compiler/type_util.m:
> > Add a utility predicate to expand out equivalence types.
>
> Hmm.  Expanding these on the fly all the time seems like it could be
> a bit inefficient (as far as compile time is concerned).
>
The results of the expansion could be cached in pred_info and proc_info
structures, I would prefer to do this in a separate change though.

> > Index: compiler/typecheck.m
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
> > retrieving revision 1.325
> > diff -u -r1.325 typecheck.m
> > --- compiler/typecheck.m 25 Sep 2002 06:49:13 -0000 1.325
> > +++ compiler/typecheck.m 8 Nov 2002 15:10:32 -0000
> > @@ -791,6 +791,8 @@
> >  pred_info_arg_types(PredInfo, ArgTypes),
> >  special_pred_get_type(PredName, ArgTypes, Type),
> >  type_to_ctor_and_args(Type, TypeCtor, _TypeArgs),
> > + classify_type_ctor(ModuleInfo, TypeCtor, BuiltinType),
> > + BuiltinType = user_type,
> >  module_info_types(ModuleInfo, TypeTable),
> >  map__lookup(TypeTable, TypeCtor, TypeDefn),
> >  hlds_data__get_type_defn_body(TypeDefn, Body),
>
> I think this change to special_pred_needs_typecheck is wrong.
> This predicate will only work if it is using the unexpanded types.
> The unexpanded type should always be present in the type table.
>
> If the map lookup is failing, it indicates a bug somewhere,
> and I think this change will just suppress the symptom without
> fixing the bug.
>
Actually I left this in from a previous problem that I had.  It should no
longer be needed, so I will remove it.

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list