Title: RE: [Mono-list] Performance / array access

Yeah, Microsoft's JIT lifts invariant bounds-checks. But I believe it's pretty limited.

For example, the check is removed in the following case:

  for (int i = 0; i < array.Length; ++i)
    sum += array [i];

But not here:

  int len = array.Length;
  for (int i = 0; i < len; ++i)
    sum += array [i];

So the first case is (counter-intuitively) faster than the second.

I don't believe Mono's JIT makes this optimization. Maybe the new JIT will ;-)

Piers.

> -----Original Message-----
> From: Tom Fransen [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 12, 2003 10:12 AM
> To: [EMAIL PROTECTED]
> Subject: [Mono-list] Performance / array access
>
>
> Hi everybody,
>
> I am looking into the performance of both the Microsoft .NET
> Framework and Mono. What I found is that the Microsoft code
> for bubble sort runs a lot faster
> (3x)
> than the Mono code. Looking further into the problem I found
> that when compiling a assembly with the switch 'optimize for
> speed' (on
> Windows)
> the JIT optimization is enabled via some attribute in the
> assembly. Look at the assembly code that is generated I saw
> that in case of optimized code there is no longer a check (at
> least not within the for loop) that checks if the index used
> to store items in the array is within the required bounds.
>
> I case of Mono I see (if I interpret this correctly) that
> within the for loop each array index is checked to see if it
> is within bounds.
>
> Here are my questions
> a) Is my observation (for Mono) correct?
>
> b) Is this something that still needs to be implemented in
> the Mono JIT compiler or do I need to enable some setting for
> this optimization?
>
> Can anybody comment on this.
>
> regards,
> Tom
>
>
> _______________________________________________
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list
>

Reply via email to