[m-rev.] for review: new calling convention for exported procedures to java

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Nov 27 20:28:14 AEDT 2009


Hi,

On Thu, 26 Nov 2009, Peter Wang wrote:

> Branches: main
>
> Add a new calling convention for Mercury procedures exported to Java with
> `:- pragma foreign_export'.  When the procedure has multiple output arguments,
> require the caller to pass instances of a `Ref<T>' class which contain a field
> to hold the output value.  This is more verbose than return an `Object[]'
> array, and requires extra memory allocations, but is more type-safe.  Another
> advantage is that the Ref arguments will appear at the same positions as the
> output arguments in the Mercury procedure.
>
> The new convention must be enabled with `--java-export-ref-out'.  The plan is
> to enable it by default in the future.
>
> compiler/options.m:
> doc/reference_manual.texi:
>        Add the option.
>
> compiler/ml_proc_gen.m:
>        When the option is set, disable `--det-copy-out' and generate the
>        function parameters assuming pass-by-reference for outputs.
>        Only use the new convention when necessary.
>
> compiler/mlds_to_java.m:
>        Make the code to generate the exported forwarding methods account for
>        `mlds_ptr_type' parameters.  These are converted to `Ref<T>' arguments.
>
> java/runtime/Ref.java:
>        Add the reference class.

I've had a quick look over this.  The new scheme is a definite
improvment over the old way of doing things so I would be quite happy
for it to become the default now.  I've had a quick glance over the code
and it seem okay; I'll take a closer look next week - feel free to
commit it in the meantime

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list