[m-dev.] lcmc for high-level data

Peter Hawkins hawkinsp at cs.stanford.edu
Tue Sep 8 12:48:54 AEST 2009


Hi...

Not knowing the specifics of the transformation in question, rather
than using reflection, couldn't you do add a method to the object
whose field is to be updated along the lines of:

void updateField(int field_number, Object o) {
  switch (field_number) {
    case 0: this.a = (TypeA)o; break;
    case 1: this.b = (TypeB)o; break;
    ...
  }
}

The transformation needs to ensure that the appropriate field number
is passed from caller to callee together with the object base pointer,
and the callee should call the updateField method to write to the
field.

It's disgusting code, but it might work for compiler output...

Peter

On Mon, Sep 7, 2009 at 7:33 PM, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> On 07-Sep-2009, Peter Wang <novalazy at gmail.com> wrote:
>> How difficult would it be to change the transformation so that instead
>> of passing the address of a field, pass the address of the entire cell,
>> and rely on the variant procedure to know which field needs to be
>> assigned?
>
> It would mean that instead of one specialized variant per set of outputs
> returned in memory, you would need one specialized variant per the cross
> product of the set of outputs AND the identity of the structures and fields
> in which they are to be returned. This would probably make exporting the
> specialized versions to other modules unfeasibly difficult. It would also
> lower cache effectiveness.
>
> Beyond that, I don't know.
>
>> [1] That could possibly be emulated using the Java reflection API, but
>> that would probably be slow.
>
> Agreed. The overhead would probably be sufficient rob the optimization
> of its raison d'etre.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list