Microsoft MVP성태의 닷넷 이야기
The JIT does dead-code elimination in Debuggable code [링크 복사], [링크+제목 복사],
조회: 8710
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

출처: http://blogs.msdn.com/jmstall/archive/2006/03/13/dead_code_elimination.aspx

The JIT does dead-code elimination in Debuggable code

The desktop CLR JIT (at least x86) does dead-code elimination, even in debuggable code. This is obviously perfectly safe, transparent, (and good), from a program-execution perspective. But it can be a little surprising under the debugger because you can't set-next-statement (setip) to eliminated code.

In other words, if you have this C# code:
    Console.WriteLine("Hi!");
    if (false) {
        Console.WriteLine("Boo!"); // <-- can't setip here
    }
    Console.WriteLine("Bye");

You couldn't Set-next-statement to the "Boo!" line.  Normally this is fine, but every now and then it gets me. I think code-generators are more likely to produce code like that than a real person.

However, the JIT will not remove side-effect free expressions in debuggable code. For example,
    void Foo() {
        int x = 5;
        x ++;
    }

The JIT will not remove either of those lines, even though 'x' is unused and so they don't actually do anything for program behavior. This means you can still set and hit breakpoints on those lines, which is what you'd expect from debuggable (non-optimized) code.

In optimized-code, anything's fair game and a function like Foo() would very likely be optimized out of existence.

Published Monday, March 13, 2006 5:44 PM by jmstall

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

You can also stay up to date using your favorite aggregator by subscribing to the CommentRss Feed








[최초 등록일: ]
[최종 수정일: 4/14/2006]


비밀번호

댓글 작성자
 




... 31  32  33  34  35  36  37  38  39  40  [41]  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
160정성태4/13/20069425MS 인증서버 : 인증서 유효 기간 기본값 변경
157정성태4/13/20069038Converting a managed PDB into a XML file
158정성태4/13/20068693    답변글 [추가]: A SymWriter sample is coming...
156정성태4/13/20069493Method Call Interception (MCI) in C++
155정성태4/13/20068900Web Project Conversion Wizard
154정성태12/21/20059628Interprocess Communication Using the Running Object Table (ROT)파일 다운로드1
153정성태4/13/20069116Assembly loading failure is expensive [1]
152정성태4/13/20069703ASCX 컨트롤을 커스텀 컨트롤로 사용하는 방법.
151정성태4/13/20068526TechNet 세미나 목록
150정성태4/13/20068691SCDL Tool [2]
149정성태4/13/20068780Disk (based) Output Cache
147정성태4/13/20068726CLR Profiler for the .NET Framework 2.0
146정성태4/13/20069702Scriptomatic Version 2.0 by the Microsoft Scripting Guys
145정성태4/13/20069151Windows Server 2003 R2 [2]
144정성태4/13/20069538WTL(Windows Template Library) 7.5
143정성태4/13/20069782.NET 1.1 에서 WebService Client 의 KeepAlive = false; 설정
142정성태4/13/20068952Virtual Server 2005 R2 (x86, x64) EE 180-day Evaluation [2]
141정성태4/13/20069638.NET 표준개발 가이드와 Microsoft.Framework 공개
140정성태4/13/20068158PAINT.NET
139정성태11/30/2005922112월 세미나 행사
137정성태11/17/20058670WSE 3.0 정식 버전
162정성태4/13/20069337    답변글 [추가]: Web Service Security Guide
136정성태11/17/20058971Creating an Outlook My.Blogs Managed Code Add-in
138정성태11/24/20058423    답변글 Ceating an Outlook Business Contact Assistant Add-in with Visual Studio Tools for Office
135정성태11/16/20058717What's port 445 used for in Windows 2000/XP?파일 다운로드1
134정성태11/15/20058707Microsoft SQL Server Management Studio Express - Community Technical Preview (CTP) November 2005 [1]
... 31  32  33  34  35  36  37  38  39  40  [41]  42  43  44  45  ...