Microsoft MVP성태의 닷넷 이야기
The JIT does dead-code elimination in Debuggable code [링크 복사], [링크+제목 복사],
조회: 8680
글쓴 사람
정성태 (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]


비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...
NoWriterDateCnt.TitleFile(s)
450정성태9/28/20069612.NET : 16. ADO.NET vNext Entity Data Model Designer Prototype, CTP
449정성태9/28/200610525TFS : 37. Team Foundation Server and Basic Authentication
448정성태9/28/200610092TFS : 36. Moving the Team Foundation Server Data Warehouse to a Separate Server
447정성태10/20/200610214Vista : 10. ASLR이 적용된 Vista
446정성태9/26/200610003개발환경 구성 : 31. Profiling Tool for .NET Developers
445정성태10/20/20069668Windows 2008 : 2. LHS Feature Of The Week #2 - Remote Differential Compression
444정성태10/20/200610229Windows 2008 : 1. LHS Feature Of The Week #1 - Transactional NTFS
443정성태9/23/200610119개발환경 구성 : 30. Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005
442정성태9/28/200610686TFS : 35. 설치 설명서 / 관리자 가이드 도움말 업데이트
441정성태9/21/200611173개발환경 구성 : 29. SQL Server Spec 비교
440정성태10/20/200610568.NET 3.0 : 3. WCF Workshops updated to Release Candidate 1
439정성태9/20/200610560개발환경 구성 : 28. Caml Viewer 2007 : released on Codeplex
438정성태9/20/200610330개발환경 구성 : 27. Enterprise Smart Card Deployment in the Microsoft® Windows® Smart Card Framework
437정성태9/19/200610265TFS : 34. Getting Started with TFS Integrator 파일 다운로드2
434정성태9/20/200610978개발환경 구성 : 26. Developing Web Applications on Windows Vista with Visual Studio 2005
433정성태10/20/200610422Vista : 9. Next Generation TCP/IP Stack
432정성태9/16/200610303TFS : 33. Now Available: Teamprise V2 Preview 2
431정성태9/16/20069943개발환경 구성 : 25. Announcing the Web Client Software Factory
430정성태9/15/200610291.NET : 15. ASP.NET 2.0 - A Preview of Web LINQ - BLINQ
429정성태9/15/20069874The True Cost of .NET Exceptions
428정성태9/15/200611663.NET : 14. IronPython 예제들
427정성태9/14/200611163개발환경 구성 : 24. Smart Start and Stop Service in VS.NET Build
426정성태9/13/200610591TFS : 32. Team Foundation Server Language Change Package
425정성태9/12/200610436TFS : 31. Team Foundation Administrator's Guide (TFSAdmin.chm)
424정성태9/12/200611109Visual C++ : 2. Managed Debugger Expression Evaluator - mcee_mc.dat
422정성태9/8/200611010.NET : 13. An Introduction to LINQ
... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...