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