[Mono-dev] mono numerical performance

Jonathan Shore jonathan.shore at gmail.com
Sun Nov 20 13:48:02 EST 2011


Yes, the modern java JIT does not need final as does the analysis.   However, it is very nice to be able to specify constness, not only to help the JIT along, but also in terms of documenting intent.   Given that C# does not have such a construct (too bad) / const is too constrained, the next best thing would be an attribute of some sort.   It gets pretty ugly though.   

An analysis of the code tree through the loop body should allow one to observe local invariance for trivial cases without too much trouble (I would think).   This would get increasingly complex and murky within delegates and other situations.

On Nov 20, 2011, at 1:39 PM, Dawid Weiss wrote:

> 
> As far as I know the final on local variables is only a hint for the java compiler (javac), not jit (hotspot) engine. Detection of loop invariants is done at runtime (during code jitting) so there's really no difference between any of the following in modern Java jits:
> 
> 1) (final) int max = array.length;
> for (int i = 0; i < max; i++) {}
> 
> 2) for (int i = 0; i < array.length; i++) {}
> 
> Dawid
> 
> 
> 2011/11/20 Konrad M. <konrad.kruczynski at gmail.com>
> On the other hand, maybe it could be possible to add the final-like
> mechanism to Mono's compiler. Such mechanism would be beneficial if the
> CLR had some notion of local readonly variables. F# uses non-mutable
> variables a lot, so maybe CLR recognizes it. I am not sure what kind of
> transparent denotation could be used - maybe some kind of comment, like
> it was done in MS Java in the pre-annotations days.
> 
> Does Mono team see this as something worth considering? Probably proper
> analysis of assignments is a better idea.
> 
> --
> Regards,
>  Konrad
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20111120/751c0acc/attachment.html 


More information about the Mono-devel-list mailing list