[m-rev.] [dotnet-foreign] diff: use System.Array for mercury arrays
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Aug 2 21:35:11 AEST 2001
On 02-Aug-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 02-Aug-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > I think that the reliance on array covariance is a definite drawback
> > to this proposal. However, I suppose the advantages for interoperability
> > probably outweigh that. So, I'm (grudgingly ;-) willing to go along with
> > this approach.
>
> The interop is *very* good. If we could get the compiler to specialize
> array operations on type as well, we could avoid some of the castclasses
> and dynamic dispatch and get pretty good performance too.
Sure. One way to do that would be to recognize array options such as
array__lookup and array__set as builtins in ml_call_gen.m, and generate inline
code for them. We want this for the GCC back-end too.
ml_call_gen.m would compile them to MLDS `assign' statements,
either using the MLDS `field(..., offset(...), ...)' lval,
i.e. `field(no, Array, offset(Offset), ArrayType, ElemType)',
or possible creating a new MLDS lval `array_element(...)'
(I think the former is probably better).
Then mlds_to_il.m can generate appropriate code, using either ldelem/stelem
or calls to System.Array::GetValue and System.Array::SetValue,
depending on whether or not the array element type is known.
> > Note that for this scheme to work, the Mercury type_info will
> > need to contain a System.Type value, so that it can be passed to
> > Array.CreateInstance() in array__make_empty_array.
...
> Yep, we already considered this, and it seems putting System.Type into
> the type_info is the right thing to do.
To be more specific, it should go in the type_ctor_info.
Arrays need to be treated as a special case -- for them,
the System.Type can't go in the type_ctor_info, since it
differs for different array types. So the code which gets a
System.Type from a Mercury type_info would need to check for that case.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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