[m-rev.] for review: no native code for java

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Aug 14 15:51:11 AEST 2009


On Fri, 14 Aug 2009, Peter Wang wrote:

> Branches: main
>
> Make the Java backend not use native code to implement any standard library
> procedures.  The only such procedures were related to benchmarking and timing,
> which aren't very important so I just make a best effort using methods that
> the Java standard library provides.

The original justification for doing it via native code was so that the
standard library behaves identically in all grades.  In this case, I
agree that is more useful not to have to rely on native code.

> library/benchmarking.m:
>        Implement `benchmarking.report_stats' for Java as closely as possible
>        without native code.  Add real time output.
>
>        Add `benchmarking.ML_initialise' to remember the time when the
>        program starts up.
>
> compiler/mlds_to_java.m:
>        Make the main wrapper call `benchmarking.ML_initialise' at startup.
>
> library/time.m:
>        Implement `time.clock', `time.times', `time.clocks_per_sec',
>        `time.clk_tck' as closely as possible without native code.
>
> library/Mmakefile:
>        Comment out commands to build and install Native.so.
>
> java/runtime/Native.c:
>        Even though this is not used any more, update the function names for
>        the "jmercury" package prefix.
>
> diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
> index 4622db5..58b892a 100644
> --- a/compiler/mlds_to_java.m
> +++ b/compiler/mlds_to_java.m
> @@ -1673,6 +1673,7 @@ write_main_driver(Indent, ClassName, !IO) :-
>         "jmercury.runtime.JavaInternal.progname = """ ++ ClassName ++ """;",
>         "jmercury.runtime.JavaInternal.args = args;",
>         "jmercury.runtime.JavaInternal.exit_status = 0;",
> +        "benchmarking.ML_initialise();",
>         "try {",
>         "   " ++ ClassName ++ ".main_2_p_0();",

...

> diff --git a/library/benchmarking.m b/library/benchmarking.m
> index ac9b7fd..d4d1ad9 100644
> --- a/library/benchmarking.m
> +++ b/library/benchmarking.m
> @@ -27,6 +27,10 @@
>     % some memory and time usage statistics about the time period since
>     % the last call to report_stats to stderr.
>     %
> +    % Note: in Java, this reports usage of the calling thread.  You will get
> +    % non-sensical results if the previous call to `report_stats' was from a

s/non-sensical/nonsensical/

That looks okay.

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