[Mono-list] mcs compiles on linux. Now what?

Paolo Molaro lupus@ximian.com
Fri, 8 Mar 2002 15:44:48 +0100

On 03/08/02 Martin Baulig wrote:
> if we're talking about optimizations, won't it make more sense to
> do the optimization based on profiling data from mcs run with mono,
> not with mint ?

This is a good point, but we work with the data we have :-)
It would be excellent if someone contributed a profiler for the 
code generatd by the jit. I already posted some time ago profile data
for the JIT itself.

> If we start optimizing based on profiling data from mint, we may end
> up trying to "optimize away" small functions which are inlined by
> the runtime, but which need a function call in mint.
> If I understand this correctly, this'll result in one million function
> calls when run with mint, but will look more like
> ====
>         public static void TestIt ()
>         {
>                 long result = 0;
>                 for (long count = 0; count < 1000000; count++)
>                         result++;
>         }
> ====
> when run with mono, so it won't make much sense to optimize this.

There is hope this can result in the following code with an optimizing

         public static void TestIt ()

Note that the interpreter could start inlining some methods as well,
so I don't think there will be a huge difference in the profile data.

> Same in the Array.Copy implementation, the code currently does
> something like
>         for (int i = 0; i < count; i++)
>         {
>                 object value = array.GetValue (i);
>                 array.SetValue (value, i);
>         }
> which are 2*count function calls in mint, but the same than implementing
> this function in C when run in mono.

This is a perfect reason for avoiding internalcalls that do the checks:
if you have the check in C# code, the jit will use the generic code to
optimize them away, but if you hide the checks in the internalcall
the jit will either have to hand-craft the checks or suffer them even if
they are not needed.

> Btw. does mcs already run with mono, or what needs to be done to make
> it run with it ?

From my tests mono works with mcs just as well as mint, but it doesn't
work with garbage collection enabled and that prevents it's use in
compiling large programs.


lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better