Microsoft MVP성태의 닷넷 이야기
The JIT does dead-code elimination in Debuggable code [링크 복사], [링크+제목 복사],
조회: 8719
글쓴 사람
정성태 (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)
65정성태2/15/200510504Office 2003: XML Reference Schemas
64정성태2/14/200511678MFC 및 ATL 컨트롤을 위한 서명된 CAB 파일 만들기
63정성태2/15/200510205[CodeProject] Overriding MFC's Default Client Site to Implement IServiceProvider파일 다운로드1
62정성태11/14/200510549간략 소개 - 64bit Windows
61정성태1/29/200510635XP SP2 팝업창을 코드로 띄우는 것이 가능하군요.
60정성태1/28/20058980MSDN Chat : VS.NET 2005 Team System public chats파일 다운로드1
59정성태1/27/200511121Error 1034. Error writing to file" when installing Visual Studio .NET 2005 CTP December 2004 - error code is 2350
57정성태1/17/200510431Microsoft .NET: Implement a Custom Common Language Runtime Host for Your Managed App파일 다운로드1
56정성태1/12/200510798.NET Framework 2.0 설치 후, InfoPath 폼이 VS.NET 2003 에서 디버깅이 안되는 경우.
55정성태1/10/200510920Management (WMI) Extensions for Visual Studio .NET 2003 Server Explorer
54정성태1/11/200510152WSE 2.0 및 Sun JWSDP 1.4를 사용한 WS-Security 상호 운용성
76정성태3/10/200510608    답변글 [추가]: Web Services Security Interoperability using WSE 2.0 and Systinet Server 5.0 for Java
94정성태5/12/200510375    답변글 [추가]: JWSDP 1.5 버전이 나왔군요.
148정성태12/12/20058694    답변글 [추가]: WS-Security Interoperability with .NET/WSE and WebLogic Workshop 8.1파일 다운로드1
53정성태1/6/200511039버퍼 오버런 해결!
58정성태1/23/200511762    답변글 VS.NET 2005 : 새롭게 소개되는 버퍼 오버런 방지 CRT 함수들
52정성태1/6/20059912Visual C# .NET Code Samples
51정성태1/6/200510046Visual C++ .NET 2003 Code Samples
50정성태1/6/200510058Visual Studio .NET 2003 Automation Samples
49정성태1/3/200599222005년 올 한 해 릴리스 될 MS 제품
48정성태1/2/200510232.NET 2.0 : 연결 문자열 및 기타 .config 내용 암호화
47정성태12/31/200410397뉴스그룹: Microsoft Whidbey Private 뉴스 그룹
46정성태12/31/200410183MSDN Magazine: Comparing the Timer Classes in the .NET Framework Class Library
45정성태12/31/20049687MSDN Magazine: Updating the UI from a Secondary Thread
44정성태12/30/200410842NewSID : 사용자 계정의 보안 식별자를 변경해 주는 프로그램파일 다운로드1
43정성태12/28/200410166VSMT 소개: Physical Server to Virtual Server
... 31  32  33  34  35  36  37  38  39  40  41  42  43  44  [45]  ...