c# - CIL是汇编语言,JIT是汇编程序吗

标签 c# .net assembly cil

即时编译器(JIT) 是否真的将程序中的每个通用中间语言(CIL) 指令映射到底层处理器的操作码?

如果是这样我们可以称 CIL 为汇编语言而 JIT 为汇编程序吗

注意: 维基百科未在其 list of assembly languages 中将 CIL 列为汇编语言

最佳答案

这个问题都是关于定义的,所以让我们正确地定义术语。一、assembly language :

Assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices in which each statement corresponds to a single machine language instruction. An assembly language is specific to a certain computer architecture, in contrast to most high-level programming languages, which generally are portable to multiple systems.

现在,CIL :

Common Intermediate Language is the lowest-level human-readable programming language defined by the Common Language Infrastructure (CLI) specification and is used by the .NET Framework and Mono. Languages which target a CLI-compatible runtime environment compile to CIL, which is assembled into an object code that has a bytecode-style format.

好吧,这部分在技术上是不正确的:例如 C# 编译器直接编译为字节码,它不通过 CIL(人类可读语言),但从理论上讲,我们可以想象这就是正在发生的事情。

根据这两个定义,CIL 一种汇编语言,因为其中的每条语句都被编译为单个字节码指令。没有可以直接执行该字节码的物理计算机这一事实并不重要。

定义说每种汇编语言都是“特定于特定的计算机体系结构”。在这种情况下,架构是 CLR 虚拟机。


关于 JIT:JIT 编译器不能被视为汇编程序:它不执行从人类可读形式到字节码的 1:1 转换,ilasm 会执行此操作。

JIT 编译器是一种优化的编译器,可将字节码编译为 native 机器码(适用于其运行的任何 ISA/CPU),同时进行优化。

关于c# - CIL是汇编语言,JIT是汇编程序吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11701063/

相关文章:

c# - 调用异步回调但有时不执行

c# - 如何解决泛型的 Swashbuckle/Swagger -UI 模型命名问题?

c++ - 加载 128 位混合 float+int 数据?

assembly - Gnu 汇编程序给出了意外的内存操作数

c# - 为什么接口(interface)变量实例化是可能的?

c# - DataTable.Load,一行或多行包含违反非空、唯一或外键约束的值

c# - WebRequest "HEAD"轻量级替代

c# - 为什么嵌套的 using block 会多次处理对象?

.net - 在 .NET 中与 COM 交互之前是否需要调用 CoInitialize?

linux - assembly 中的倒车阵列故障