473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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

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

Jul 21 '05 #1
3 1690
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.
Jul 21 '05 #2
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.
Jul 21 '05 #3
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.
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: VM | last post by:
Hello, I'm looking for information on C# compiler optimization or compilation for an engineering short paper I want to write. Any sites with some technical info on the new advances of C#...
5
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and...
3
by: Andrew | last post by:
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...
5
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.