Lua和LuaJIT处理代码的方式有什么不同?(What's the difference in the way Lua and LuaJIT process the code?)

编程入门 行业动态 更新时间:2024-10-27 12:39:24
Lua和LuaJIT处理代码的方式有什么不同?(What's the difference in the way Lua and LuaJIT process the code?)

根据我的理解,标准的Lua解释器首先将输入代码编译为“字节码”( luac的输出),然后“解释”该字节码。

但这基本上不是JIT编译器的定义吗? 那时LuaJIT做了什么? 它与标准的Lua解释器有何不同? 怎么会这么快?

From what I understood, the standard Lua interpreter first compiles the input code to "bytecode" (the output of luac) and then "interpretes" that bytecode.

But isn't that basically the definition of a JIT compiler? What does LuaJIT do then? How does it differ from the standard Lua interpreter? How can it be this faster?

最满意答案

基本上不是JIT编译器的定义吗? 那时LuaJIT做了什么?

它实现了自己的解释器,它通常比“标准”Lua解释器更快,并且JIT将频繁访问的片段编译为机器指令,这带来了进一步的性能提升,但限制了可移植性(因为这些指令是机器/体系结构特定的) 。

还有更多的改进和优化,您可以在Mike Pall的概述中找到它们。 另请参阅此页面以了解整个JIT讨论 ,特别是Mike Pall对此的评论 。

isn't that basically the definition of a JIT compiler? What does LuaJIT do then?

It implements its own interpreter, which is often faster than the "standard" Lua interpreter and it JIT-compiles frequently visited fragments to machine instructions, which brings further performance gains, but limits the portability (as those instructions are machine/architecture-specific).

There are many more improvements and optimizations, which you can find in Mike Pall's overview. Also see this page for the overall JIT discussion and specifically Mike Pall's comments on it.

更多推荐

本文发布于:2023-08-07 15:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464760.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么不同   代码   方式   LuaJIT   Lua

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!