gpt4 book ai didi

python - "register machine"到底是什么?

转载 作者:IT老高 更新时间:2023-10-28 22:25:06 30 4
gpt4 key购买 nike

来自 http://code.google.com/p/unladen-swallow/wiki/ProjectPlan我引用:

“使用 JIT 还可以让我们将 Python 从基于堆栈的机器转移到寄存器机器,这已被证明可以提高其他类似语言的性能(Ierusalimschy 等人,2005 年;Shi 等人,2005 年)。 "

在大学里,我为一种带有递归过程的语言构建了一个简单的编译器——它为每个调用的过程维护堆栈帧——这样它们就可以被递归调用,这样参数和返回值就可以工作......

两件事:

1) 考虑到上述引文中使用的术语,我认为我所实现的将被视为“基于堆栈的机器”是否正确?

2) 如果我在第 (1) 点的假设是正确的,那么“注册机”是如何工作的?即它与基于堆栈的机器有什么不同?

谢谢!

最佳答案

注册机是一种硬件或软件单元,当处理数据时,它会从内存中获取数据,将其放在可以快速处理的位置,然后返回结果。

例如,常规 CPU 是一台寄存器机。由于 ALU(CPU 中处理数字的单元)只能处理寄存器中的数字。

基于堆栈的机器将数据添加到堆栈中,然后将数据弹出或压入堆栈。

例如,两个数字相加是

Push 2 // Push 2 onto the stack
Push 3 // Push 3 onto the stack
Add // Add the top two things on the stack.

在注册机中会是这样的。

Load x, r0 // Load x onto register 0
Load y, r1 // Load y onto register 1
Add r0, r1, r2 // Add 1 and 2 and store the result in register 2

关于python - "register machine"到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1622530/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com