PC Review


Reply
Thread Tools Rate Thread

C# Compiler Optimization Info, e.g., White Paper

 
 
=?Utf-8?B?QW5kcmV3?=
Guest
Posts: n/a
 
      14th Feb 2004
Where can one find a discussion of the current and future optimizations that the C# compilers do? When I see things like the following I question my faith in csc being good at optimizing. The same kind of thing shows up in cordbg when looking at the JIT code for a similar example

% cat y.c

using System

class A
bool On { get { return true; }
public void Print()
if (On)
Console.WriteLine("On")




class ConditionalTest
static void Main(

A a = new A()
a.Print()



% csc /optimize+ y.c

Microsoft (R) Visual C# .NET Compiler version 7.10.3052.
for Microsoft (R) .NET Framework version 1.1.432
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved

% ildasm y.ex

..method public hidebysig instance void Print() cil manage

// Code size 19 (0x13
..maxstack
IL_0000: ldarg.
IL_0001: call instance bool A::get_On(
IL_0006: brfalse.s IL_001
IL_0008: ldstr "On
IL_000d: call void [mscorlib]System.Console::WriteLine(string
IL_0012: re
} // end of method A::Prin



At least the compiler eliminates the "if" test when "On" is replaced with "true" in the test

 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      15th Feb 2004
Andrew,

>Where can one find a discussion of the current and future optimizations that the C# compilers do?


http://msdn.microsoft.com/vcsharp/te...aspx#optimizer

The short answer is that it doesn't do much. Most optimizations are
left to the JIT compiler.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
=?Utf-8?B?QW5kcmV3?=
Guest
Posts: n/a
 
      16th Feb 2004
Thanks. I'd seen that link before; it doesn't look very authoritative and it certainly doesn't provide much insight for current or future plans with the optimizer. It just lists a few optimizations without comment

As I said, the JIT compiler didn't seem to be doing so well either, at least for a very similar example that I looked at. That is why I am looking for information about what is actually done, and what's planned in the future. Without this information I have no reason to think that much of anything is being optimized, and some reason to think that it's not.
 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      20th Feb 2004

>I'd seen that link before; it doesn't look very authoritative


It's a FAQ on Microsoft's developer website, written by C# team
members. In what way could it be any more authoritative?


>and it certainly doesn't provide much insight for current or future plans with the optimizer. It just lists a few optimizations without comment.


What kind of comments are you looking for? There isn't much to say
about the current optimizations because there simply are so few of
them.

I don't know what the plans for the future are. You may have to wait
for a public beta to find out.


>As I said, the JIT compiler didn't seem to be doing so well either, at least for a very similar example that I looked at.


How did you check that. Many people that don't use the debugger
correctly end up looking at unoptimized debug code and make incorrect
conclusions about the JIT abilities.

If you want more details on JIT optimizations, I suggest you visit the
group microsoft.public.dotnet.framework.performance. There are also
some good articles on this up on MSDN.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler optimization question Lloyd Dupont Microsoft Dot NET Framework 2 7th Sep 2005 12:26 AM
Negative optimization in C# compiler? Gianluca Microsoft C# .NET 7 24th May 2005 01:01 AM
Compiler optimization? Tomer Microsoft Dot NET Compact Framework 1 23rd Dec 2004 07:19 PM
JIT compiler global optimization ? =?Utf-8?B?Q2FybA==?= Microsoft Dot NET 3 24th Aug 2004 11:47 AM
Re: Compiler optimization of enum... Cody Manix Microsoft C# .NET 0 15th Jul 2003 02:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:28 AM.