Learning ILAsm, the backbone of .NET

added by bjames
8/9/2012 8:46:44 AM


An tutorial on http://www.refactorthis.net on ILasm.


8/9/2012 5:41:30 PM
Sometimes, in very specific cases, you can squeak more performance out of a C program by using inline assembly. I wonder if there are similar cases when it comes to .Net? I have on occasion made use of the unsafe keywords to handle pointers and memory management myself for better performance, but I've never bypassed the compiler and used ilasm.

8/9/2012 5:58:03 PM
That's a very interesting question. I would take an instance in which you have used unsafe code and bypassed memory management and then use ILDasm.exe to disassemble the code to see what the IL looks like. That will give you a chance to see how IL handles such instances. IL has support for objects and I would imagine that objects are larger memory wise than their simple data type counter parts. You could disassemble an application and find instances in which the compiler uses a class in IL but you can accomplish the same thing utilizing a smaller data type. It seems to me that this would in theory run faster. Also, you could always look at how certain methods in the FCL are represented in IL and then see if you can accomplish the same task more efficiently. I any event you've inspired me to create a new post on http://www.refactorthis.net on executing inline IL to boost performance. Excellent question!! Thanks for reading!!