<tfoot id='Ylv9U'></tfoot>

    <small id='Ylv9U'></small><noframes id='Ylv9U'>

      <bdo id='Ylv9U'></bdo><ul id='Ylv9U'></ul>
    <legend id='Ylv9U'><style id='Ylv9U'><dir id='Ylv9U'><q id='Ylv9U'></q></dir></style></legend>

  1. <i id='Ylv9U'><tr id='Ylv9U'><dt id='Ylv9U'><q id='Ylv9U'><span id='Ylv9U'><b id='Ylv9U'><form id='Ylv9U'><ins id='Ylv9U'></ins><ul id='Ylv9U'></ul><sub id='Ylv9U'></sub></form><legend id='Ylv9U'></legend><bdo id='Ylv9U'><pre id='Ylv9U'><center id='Ylv9U'></center></pre></bdo></b><th id='Ylv9U'></th></span></q></dt></tr></i><div id='Ylv9U'><tfoot id='Ylv9U'></tfoot><dl id='Ylv9U'><fieldset id='Ylv9U'></fieldset></dl></div>

    1. CLR 与 JIT

      CLR vs JIT(CLR 与 JIT)
    2. <legend id='158ns'><style id='158ns'><dir id='158ns'><q id='158ns'></q></dir></style></legend>
        <tbody id='158ns'></tbody>
      <i id='158ns'><tr id='158ns'><dt id='158ns'><q id='158ns'><span id='158ns'><b id='158ns'><form id='158ns'><ins id='158ns'></ins><ul id='158ns'></ul><sub id='158ns'></sub></form><legend id='158ns'></legend><bdo id='158ns'><pre id='158ns'><center id='158ns'></center></pre></bdo></b><th id='158ns'></th></span></q></dt></tr></i><div id='158ns'><tfoot id='158ns'></tfoot><dl id='158ns'><fieldset id='158ns'></fieldset></dl></div>

            <bdo id='158ns'></bdo><ul id='158ns'></ul>

            <tfoot id='158ns'></tfoot>

            <small id='158ns'></small><noframes id='158ns'>

                本文介绍了CLR 与 JIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                JIT 编译器和 CLR 有什么区别?如果您将代码编译为 il 并且 CLR 运行该代码,那么 JIT 在做什么?向 CLR 添加泛型后,JIT 编译有何变化?

                What is the difference between the JIT compiler and CLR? If you compile your code to il and CLR runs that code then what is the JIT doing? How has JIT compilation changed with the addition of generics to the CLR?

                推荐答案

                JIT 是 CLR 的一个方面.

                The JIT is one aspect of the CLR.

                具体来说,它负责将原始语言的编译器(例如 Microsoft c# 的 csc.exe)生成的 CIL(以下称为 IL)更改为当前处理器(以及它在当前处理器中公开的体系结构)的本机代码进程,例如 32/64 位).如果有问题的程序集是 ngen 的,那么 JIT 过程是完全没有必要的,没有它,CLR 将运行此代码.

                Specifically it is the part responsible for changing CIL (hereafter called IL) produced by the original language's compiler (csc.exe for Microsoft c# for example) into machine code native to the current processor (and architecture that it exposes in the current process, for example 32/64bit). If the assembly in question was ngen'd then the the JIT process is completely unnecessary and the CLR will run this code just fine without it.

                在使用尚未从中间表示转换的方法之前,JIT 有责任对其进行转换.
                何时 JIT 将启动是特定于实现的,并且可能会发生变化.然而,CLR 设计要求 JIT相关代码执行之前发生,相比之下,JVM 可以在一段时间内自由解释代码,而单独的线程会创建机器代码表示.
                正常" CLR 使用 pre-JIT 存根方法,其中方法仅在使用时进行 JIT 编译.这涉及让初始本地方法存根成为间接指示 JIT 编译该方法,然后修改原始调用以跳过初始存根.当前的精简版会在加载类型时编译该类型的所有方法.

                Before a method is used which has not yet been converted from the intermediate representation it is the JIT's responsibility to convert it.
                Exactly when the JIT will kick in is implementation specific, and subject to change. However the CLR design mandates that the JIT happens before the relevant code executes, JVMs in contrast would be free to interpret the code for a while while a separate thread creates a machine code representation.
                The 'normal' CLR uses a pre-JIT stub approach where by methods are JIT compiled only as they are used. This involves having the initial native method stub be an indirection to instruct the JIT to compile the method then modify the original call to skip past the initial stub. The current compact edition instead compiles all methods on a type when it is loaded.

                解决泛型的添加问题.

                这是 IL 规范和 JIT 在语义方面的最后一次重大更改,而不是其内部实现细节.

                This was the last major change to the IL specification and JIT in terms of its semantics as opposed to its internal implementation details.

                添加了几个新的 IL 指令,并为检测类型和成员提供了更多元数据选项.在 IL 级别也添加了约束.

                Several new IL instructions were added, and more meta data options were provided for instrumenting types and members. Constraints were added at the IL level as well.

                当 JIT 编译具有通用参数的方法(通过包含类显式或隐式)时,它可能为使用的每种类型设置不同的代码路径(机器代码指令).实际上,JIT 对所有引用类型使用共享实现,因为这些引用类型的变量将表现出相同的语义并占用相同的空间 (IntPtr.Size).

                When the JIT compiles a method which has generic arguments (either explicitly or implicitly through the containing class) it may set up different code paths (machine code instructions) for each type used. In practice the JIT uses a shared implementation for all reference types since variables for these will exhibit the same semantics and occupy the same space (IntPtr.Size).

                每种值类型都会为其生成特定的代码,处理堆栈/堆上变量大小的减少/增加是造成这种情况的主要原因.此外,通过在方法调用之前发出受约束的操作码,对非引用类型的许多调用不需要封装值来调用方法(这种优化也用于非通用情况).这也允许正确处理默认的<T> 行为,并在使用非 Nullable 值类型时将与 null 的比较作为无操作(始终为 false)剥离.

                Each value type will get specific code generated for it, dealing with the reduced / increased size of the variables on the stack/heap is a major reason for this. Also by emitting the constrained opcode before method calls many invocations on non reference types need not box the value to call the method (this optimization is used in non generic cases as well). This also allows the default<T> behaviour to be correctly handled and for comparisons to null to be stripped out as no ops (always false) when a non Nullable value type is used.

                如果在运行时尝试通过反射创建泛型类型的实例,则类型参数将由运行时验证以确保它们通过任何约束.这不会直接影响 JIT,除非在类型系统中使用它(尽管可能).

                If an attempt is made at runtime to create an instance of a generic type via reflection then the type parameters will be validated by the runtime to ensure they pass any constraints. This does not directly affect the JIT unless this is used within the type system (unlikely though possible).

                这篇关于CLR 与 JIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                Cannot remove items from ListBox(无法从列表框中删除项目)
                Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  <tbody id='YDMzh'></tbody>

                        <legend id='YDMzh'><style id='YDMzh'><dir id='YDMzh'><q id='YDMzh'></q></dir></style></legend>
                        <tfoot id='YDMzh'></tfoot>
                        <i id='YDMzh'><tr id='YDMzh'><dt id='YDMzh'><q id='YDMzh'><span id='YDMzh'><b id='YDMzh'><form id='YDMzh'><ins id='YDMzh'></ins><ul id='YDMzh'></ul><sub id='YDMzh'></sub></form><legend id='YDMzh'></legend><bdo id='YDMzh'><pre id='YDMzh'><center id='YDMzh'></center></pre></bdo></b><th id='YDMzh'></th></span></q></dt></tr></i><div id='YDMzh'><tfoot id='YDMzh'></tfoot><dl id='YDMzh'><fieldset id='YDMzh'></fieldset></dl></div>

                        <small id='YDMzh'></small><noframes id='YDMzh'>

                          <bdo id='YDMzh'></bdo><ul id='YDMzh'></ul>