[m-rev.] diff: disable closure layouts for non-C targets

Peter Ross peter.ross at miscrit.be
Wed Mar 6 20:27:38 AEDT 2002


fjh wrote:

> Estimated hours taken: 0.5
> Branches: main
>
> compiler/ml_closure_gen.m:
> Disable generation of closure layouts for non-C targets, since
> apparently this causes some problems with the IL back-end.
>
The problem can quite easily be seen with the following program

:- module closure.

:- interface.

:- import_module list.

:- func p(T, list(T)) = list(T).

:- implementation.

:- pred unify(T::in, T::in) is semidet.
unify(X, X).

p(X, List) = Result :-
 list__filter(closure__unify(X), List, Result).

You will end up with the following ldsfld

ldsfld int32& 'closure'.'mercury_code'::'const_0_0_1_typevar_vector'

However int32& is not the type of const_0_0_1_typevar_vector, as can be
seen by its definition.

.field private static initonly
   int32[]
    'const_0_0_1_typevar_vector'

This happens because the type of const_0_0_1_typevar_vector is a pointer
to int according to the MLDS, this is untrue on the typed IL backend.
What I suspect should be fixed is the outputing of references to arrays
in mlds_to_c.m, which is I assume why we needed to use the pointer type.
After all an array an int array is also a pointer to int in C if output
correctly.

I hope this helps.


--------------------------------------------------------------------------
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