Managed code

From Wikipedia, the free encyclopedia

In Microsoft Windows terminology, managed code is computer instructions — that is, "code" — executed by a CLI-compliant virtual machine, such as Microsoft's .NET Framework Common Language Runtime, or other CLI implementations from The Mono Project or the DotGNU Project.

[edit] Execution of managed code

Programs for a managed code environment are normally written in a human-oriented programming language, typically C# or Visual Basic .NET.

Before the code is run, the Intermediate Language is compiled into native machine code. Since this compilation happens by the managed execution environment's own runtime-aware compiler, the managed execution environment can guarantee what the code is going to do. It can insert garbage collection hooks, exception handling, type safety, array bounds, index checking, etc.

This is traditionally referred to as Just-in-time compilation. However, unlike most traditional just-in-time compilers, the file that holds the pseudo machine code that the virtual machine compiles into native machine code can also contain pre-compiled binaries for different native machines (such as x86 and PowerPC). This is similar in concept to the Apple Universal binary format.

[edit] Managed and unmanaged

In a Microsoft Windows environment, all other code has come to be known as unmanaged code. In non-Windows and mixed environments, managed code is sometimes used more generally to refer to any interpreted programming language.

Managed refers to a method of exchanging information between the program and the runtime environment. It is specified that at any point of execution, the runtime may stop an executing CPU and retrieve information specific to the current CPU instruction address. Information that must be accessible generally pertains to runtime state, such as processor register or stack memory contents.

The necessary information is then encoded in Common Intermediate Language (formerly known as Microsoft Intermediate Language) and associated metadata.

[edit] External links

In other languages