. NET Framework performance-JIT Compiler

Source: Internet
Author: User

When compiling any. NET application, the compiler converts the source code to Microsoft intermediate language (MSIL ). MSIL is not executed on any specific processor. In fact, MSIL is designed to be independent of the processor. To execute an application in a specific environment, a JIT compiler accepts the MSIL output and converts the commands to the native commands of the host processor. the JIT compiler compiles the code in real time, so that the application starts to run.

Unlike traditional compilers, such as C ++ compilers, JIT compilers have so much time for optimization. Unlike traditional compilers running on machines during development, the end user is waiting for the JIT compiler to complete so that the program can run. The JIT compiler still takes time to perform a certain amount of optimization. It only compiles a few small parts of the program at a time. Whenever the execution reaches a method in the Assembly that has not been compiled by JIT, the JIT compiler only compiles the method currently waiting for execution, and saves the result for future calls to the same method, knowing that the application is over. This technology means that applications will never waste Compilation Time on unused methods.

The JIT compiler performs some optimization when generating local commands, including clearing sub-expressions, expanding loops, and inline methods. These optimizations are built-in. NET optimizations that we cannot control.

Inlining is an optimization that the compiler uses to call a method in place of its own instructions. The compiler concatenates a method when it sees a chance to significantly reduce the overhead. A small method is the best inline object, because the overhead of stack frame settings, branches, and return is often greater than the amount of code in the method.

Compilation before execution also has some advantages. The compiler will understand the specific characteristics of the runtime environment and provide specific instructions for the host CPU. The compiler can greatly optimize the memory on a RAM-limited platform, and use the processing capability of faster machines to optimize the speed.

There are many opportunities to optimize programs from source code to MSIL and then to the local code of the host CPU.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.