即时 (JIT) 编译器有什么作用? [英] What does a just-in-time (JIT) compiler do?

查看:29
本文介绍了即时 (JIT) 编译器有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与非 JIT 编译器相比,JIT 编译器具体做什么?谁能给出一个简洁易懂的描述?

解决方案

JIT 编译器在之后运行,并动态编译代码(通常是字节码或某种 VM 指令)(或称为即时)转换为通常更快的形式,通常是主机 CPU 的本机指令集.JIT 可以访问动态运行时信息,而标准编译器则不能,并且可以进行更好的优化,例如内联经常使用的函数.

这与传统编译器形成对比,传统编译器将所有代码编译为机器语言在程序首次运行之前.

换句话说,传统编译器在您第一次运行之前将整个程序构建为 EXE 文件.对于较新风格的程序,程序集是用伪代码(p 代码)生成的.只有在您在操作系统上执行程序(例如,通过双击其图标)后,(JIT)编译器才会启动并生成基于 Intel 的处理器或其他任何可以理解的机器代码(m 代码).

What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?

解决方案

A JIT compiler runs after the program has started and compiles the code (usually bytecode or some kind of VM instructions) on the fly (or just-in-time, as it's called) into a form that's usually faster, typically the host CPU's native instruction set. A JIT has access to dynamic runtime information whereas a standard compiler doesn't and can make better optimizations like inlining functions that are used frequently.

This is in contrast to a traditional compiler that compiles all the code to machine language before the program is first run.

To paraphrase, conventional compilers build the whole program as an EXE file BEFORE the first time you run it. For newer style programs, an assembly is generated with pseudocode (p-code). Only AFTER you execute the program on the OS (e.g., by double-clicking on its icon) will the (JIT) compiler kick in and generate machine code (m-code) that the Intel-based processor or whatever will understand.

这篇关于即时 (JIT) 编译器有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆