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