Microsoft MVP성태의 닷넷 이야기
The JIT does dead-code elimination in Debuggable code [링크 복사], [링크+제목 복사],
조회: 11616
글쓴 사람
정성태 (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)
296정성태5/27/200613154WWF 로 만든 Tetris
294정성태5/21/200613219Session State Uses a Reader-Writer Lock
293정성태5/21/200611877Microsoft Threat Analysis & Modeling v2.0 RC1
291정성태5/18/200613222Managed Stack Explorer
289정성태5/17/200613686Microsoft ASP.NET Providers - PDF 메뉴얼
288정성태5/17/200614053TFS Administration Tool 1.0 Released...with Shared Source!
287정성태5/17/200613124An Introduction to 64-bit Installers with Visual Studio 2005: Part 1
283정성태5/15/200613677Windows Workflow Foundation: Running Service Activated Workflows on Windows Vista and IIS7
284정성태5/15/200613890    답변글 Windows Workflow Foundation: Exposing Workflows as Services [1]
281정성태5/12/200612422Microsoft Compute Cluster Pack SDK
280정성태5/11/200616586C# 3.0 : One-Step Object Creation and Initialization
279정성태5/11/200614493Vista에서 제거되는 DHTML Editing Control
278정성태5/11/200612756LINQ CTP - May 2006
286정성태5/16/200612264    답변글 Using LINQ with ASP.NET (Part 1)
277정성태5/9/200612374Web Application Projects - 정식 릴리스
276정성태5/8/200612732SNK 파일 공유하기파일 다운로드1
275정성태5/8/200612458Building Security Awareness in .NET Assemblies
274정성태5/7/200612402QuickSYS파일 다운로드2
273정성태5/7/200612642Developing Firewalls for Windows 2000/XP파일 다운로드1
272정성태5/6/200614603Windows PowerShell [3]
292정성태5/19/200612745    답변글 Windows PowerShell - PowerShell Script to Create a WorkItem
271정성태5/6/200612982MSBee
282정성태5/15/200612821    답변글 MSBee will be on CodePlex
290정성태5/18/200613285    답변글 MSBuild Extras - Toolkit for .NET 1.1 "MSBee"
270정성태5/4/200613004ISO Recorder
269정성태5/4/200612967Visual Studio 2005 Team System Level 200 Course Material
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...