Microsoft MVP성태의 닷넷 이야기
The JIT does dead-code elimination in Debuggable code [링크 복사], [링크+제목 복사],
조회: 8622
글쓴 사람
정성태 (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]


비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  [9]  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
975정성태10/9/200810678.NET : 88. ClickOnce에서 .application 파일을 다운로드 하려고 할 때.
974정성태10/8/200810695TFS : 168. MSBuild Extension Pack
973정성태10/5/200812387.NET 3.5 : 42. WPF - Web Browser 및 Splash Control 추가
972정성태10/2/200810654TFS : 167. TFS Power Tools 다음 버전 소개
971정성태9/22/200810973TFS : 166. Index cards and Team System
970정성태9/16/200810961Vista : 53. 설치 디스크를 USB 로 만들기
968정성태9/11/200810565XML Conformance Level 에 Fragment 값이 쓰이는 경우.
967정성태9/8/200810698.NET : 87. CertEnroll 개체를 이용한 인증서 요청/반환/설치
966정성태9/2/200810748.NET : 86. .NET Framework 3.5 SP1 소스 코드 공개
965정성태9/2/200811699Vista : 52. SPI(Stateful Packet Inspection) 옵션 제거
964정성태8/18/200812703.NET 3.0 : 24. WPF DataGrid
969정성태9/16/200810974    답변글 .NET 3.0 : 24.1 Editing Tabular Data in WPF - Building a WPF Grid
963정성태7/25/200811774.NET : 85. VPL(Visual Programming Language)를 아세요?
962정성태7/24/200810835TFS : 165. WorkItem 에 대해 Full Text 검색
961정성태7/20/200810764.NET : 84. WCSF Application Architecture
960정성태7/14/200810606.NET : 83. Non Paged CLR Host
959정성태7/7/200811138.NET : 82. Composite Application Guidance for WPF
958정성태7/7/200812303.NET : 81. C# - 왜 모든 함수호출에서 callvirt 를 사용할까?
957정성태6/30/200811278GUID
956정성태6/27/200810784TFS : 164. 팀 프로젝트 간 WorkItem 이동 방법
955정성태6/26/200811295TFS : 163. 삭제된 항목을 소스 컨트롤 탐색기에서 보이도록 하는 방법
954정성태6/20/200810918Debug : 37. IDE 디자인 모드에서의 디버깅 기법
953정성태6/10/200811771.NET : 80. Unity Application Block 소개(?) [1]
952정성태4/28/200811040.NET : 79. IconHandler 2.0
951정성태4/28/200811467SDK : 14. STA / MTA 기원
950정성태4/24/200810564.NET : 78. Ajax View
1  2  3  4  5  6  7  8  [9]  10  11  12  13  14  15  ...