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