Microsoft MVP성태의 닷넷 이야기
The JIT does dead-code elimination in Debuggable code [링크 복사], [링크+제목 복사],
조회: 8627
글쓴 사람
정성태 (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)
875정성태11/9/200710357.NET : 66. 한 눈으로 확인하는 .NET 데이터 액세스 계층
874정성태11/6/200711412Debug : 30. OpenFileDialog 사용시 메모리 사용이 급격하게 올라가는 문제
873정성태11/6/200710483Debug : 29. WinDBG - 명령어 !IToldYouSo
872정성태11/3/200710590Debug : 28. Debugger Visualizer - DynamicMethod / MethodInfo [1]
871정성태10/31/200710803TFS : 141. VS.NET 2008 - 개선된 WorkItem 기능
870정성태10/31/200710475TFS : 140. TFS to TFS Migration Tool
869정성태10/31/200710617.NET : 65. ASP.NET 을 어셈블리 언어로.
868정성태10/30/200710830.NET 3.0 : 23. 카드 스페이스 - SSL 없이도 구현가능.
867정성태10/30/200710741.NET : 64. CAB(Composite Application Block) 에 접근하고 싶으세요?
866정성태10/28/200710670개발 환경 구성: 115. VPC 를 이용한 AD 네트워크 구성
865정성태10/27/200710830.NET : 63. Singleton 패턴 구현
864정성태10/23/200710857TFS : 139. 단위 테스트를 MTA로 실행하도록 설정 [1]
863정성태10/20/200710614VisualNDepend
862정성태10/20/200710117.NET : 62. CAB 성능 향상 팁
861정성태10/20/200710498Debug : 27. SOS 를 이용하여 .NET Finalizer 디버깅
860정성태10/18/200710492TFS : 138. 팀 규모에 따른 물리 서버의 용량
859정성태10/16/200711413개발 환경 구성: 114. Eric Gunnerson 의 WiX 관련 포스트들 [3]
858정성태10/16/200710711.NET : 61. 메서드 안에서 정의된 블록 내부의 변수에 대한 범위
857정성태10/9/200710349TFS : 137. 특정 버전의 소스로 팀 빌드하는 방법
856정성태10/8/200711734.NET 3.5 : 32. ReaderWriterLock 과 ReaderWriterLockSlim 의 성능 비교.
855정성태10/5/200710465개발 환경 구성: 113. Virtual PC - 처음 생성한 VHD 파일의 크기를 바꿀 수 있을까?
854정성태10/3/200710335TFS : 136. Operations Guidance for Team Foundation Server
853정성태10/2/200710738.NET 3.5 : 31. ToJSON 확장 메서드 구현
852정성태9/30/200711866IIS : 18. IIS 7.0 의 FTP 서비스를 위한 방화벽 설정
851정성태9/27/200710889TFS : 135. TFS 2008 용 빌드 알림 도구
850정성태9/26/200710171TFS : 134. Visual Studio Team System Web Access 2008 파워툴 CTP
1  2  3  4  5  6  7  8  9  10  11  12  [13]  14  15  ...