# Thursday, 07 October 2004
« Compiling javac into an executable with ... | Main | Stack Traces & Line Numbers »
Generic Algorithms Revisited

OSNews has an article about using generics to do calculations on Whidbey. When I originally wrote about this, my trick was much slower than the virtual dispatch one that Anders suggested, but it's nice to see that the CLR perf team paid attention, because on the current Whidbey beta it's really fast.

Thursday, 07 October 2004 11:10:03 (W. Europe Daylight Time, UTC+02:00)  #    Comments [3] Tracked by:
"prescription diet pill canada" (prescription diet pill canada) [Trackback]

Thursday, 07 October 2004 17:16:45 (W. Europe Daylight Time, UTC+02:00)
I guess that means they've reversed their stance on inlining methods with struct arguments? The Mono discussion linked to by the article was interesting - it turns out that inlining struct method calls can give a major boost when intermediate structs can be eliminated in certain operations:

http://lists.ximian.com/archives/public/mono-list/2004-August/022801.html

I'd be interested in seeing how much of your code is now inlined by the JIT. There's really no reason why a method with a zero-length struct even needs to set up a stack (or even instantiate the struct at all).

I personally wish that the compiler could automatically generate operator requirements for the template type arguments. For instance, adding a T Sum() to a List<T> object with a + operator used between two T object would create the automatic requirements for a static operator +(T,T). Of course, there's no way you could reliably infer the return type from an operation such as this. *sigh*

I often wish they went with the more powerful C++-style templates. I don't know how you'd represent the "half-compiled" state of the templates in IL, but it would make developer's lives much easier.

Anyways, I'm glad to see that your method is pretty fast. It's the most preferable method I've seen so far.

Thursday, 07 October 2004 17:35:33 (W. Europe Daylight Time, UTC+02:00)
Everything I've read so far indicates that they (Microsoft) don't intend to fix method inlining for value types for .NET 2.0.

However, I just checked with the debugger and in some cases value type instance methods are most definitely inlined, so I guess that's good news.
Tuesday, 12 October 2004 03:29:06 (W. Europe Daylight Time, UTC+02:00)
The .NET JIT will not inline methods that have one or more explicit struct parameters. But when calling a method on the zero-size IntCalculator, the struct is an implicit parameter so inlining does indeed happen.

If .NET would inline all methods with struct parameters, wrapping a primitive in a struct should have no effect on performance. Unfortunately this is not the case.

This is an area where mono could easily beat the microsoft VM in performance. The problem is that just inlining the method using structs does not do you that much good. The important thing are the subsequent optimizations.
Name
E-mail
Home page

I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.

Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)

Answer:  
Comment (HTML not allowed)  

Live Comment Preview