将 Psyco 移植到 64 位可能存在哪些陷阱?
Psyco 文档说:
仅供参考,Psyco 没有 可以在任何 64 位系统上工作。 这个事实值得再次注意, 现在最新的 Mac OS/X 10.6 “雪豹”自带默认 64 位上的 64 位 Python 机器。使用 Psyco 的唯一方法 OS/X 10.6是通过重新编译定制的 32 位模式下的 Python。
一般来说,只有当代码假定指针类型具有一定大小以及其他类似的小问题时,将程序从 32 位移植到 64 位才真正成为问题。考虑到 Psyco 并不是大量代码(约 32K 行 C + 约 8K 行 Python),它有多难?有没有人尝试过这个并且碰壁了?我还没有真正有机会仔细研究 Psyco 来源,所以我真的很高兴知道我是否在浪费时间研究这个......
The Psyco docs say:
Just for reference, Psyco does not
work on any 64-bit systems at all.
This fact is worth being noted again,
now that the latest Mac OS/X 10.6
"Snow Leopart" comes with a default
Python that is 64-bit on 64-bit
machines. The only way to use Psyco on
OS/X 10.6 is by recompiling a custom
Python in 32-bit mode.
In general, porting programs from 32 to 64 bits is only really an issue when the code assumes a certain size for a pointer type and other similarly small(ish) issues. Considering that Psyco isn't a whole lot of code (~32K lines of C + ~8K lines of Python), how hard could it be? Has anyone tried this and hit a wall? I haven't really had a chance to take a good look at the Psyco sources yet, so I'd really appreciate knowing if I'm wasting my time looking into this...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Psyco 开发人员之一 Christian Tismer 似乎也不同意“这有多难”的假设(引自 此处):
和
如果您想要更多详细信息(可能需要 Psyco 的内部知识),我想您可以随时尝试在 psyco 邮件列表之一上询问......
Christian Tismer, one of the Psyco developers also seems to disagree with the "how hard could it be" - assumption (quoted from here):
and
If you want more details (firm inside knowledge of Psyco probably needed) I guess you can always try to ask on one of the psyco mailing lists ...
由于 psyco 是一个编译器,因此它需要了解底层汇编语言才能生成有用的代码。这意味着它需要了解 8 个新寄存器、64 位代码的新操作码等。
此外,为了与现有代码进行互操作,它需要使用与 64 位代码相同的调用约定。 AMD-64 调用约定与旧的快速调用约定类似,其中一些参数在寄存器中传递(在 64 位情况下,指针为 rcx、rdx、r8、r9,浮点为 Xmm0-Xmm3),其余参数为推入堆栈上的溢出空间。与 x86 不同,这个额外空间通常为所有可能的调用分配一次。 IA64 约定和汇编语言仍然不同。
简而言之,我认为这可能并不像听起来那么简单。
Since psyco is a compiler, it would need to be aware of the underlying assembly language to generate useful code. That would mean it would need to know about the 8 new registers, new opcodes for 64 bit code, etc.
Furthermore, to interop with the existing code, it would need to use the same calling conventions as 64 bit code. The AMD-64 calling convention is similar to the old fast-call conventions in that some parameters are passed in registers (in the 64 bit case rcx,rdx,r8,r9 for pointers and Xmm0-Xmm3 for floating point) and the rest are pushed onto spill space on the stack. Unlike x86, this extra space is usually allocated once for all of the possible calls. The IA64 conventions and assembly language are different yet.
So in short, I think this is probably not as simple as it sounds.
Psyco 假设 sizeof(int) == sizeof(void*) 有点到处都是。这比仅仅写下 64 位调用约定和汇编程序要困难得多。顺便说一句,pypy 现在已经支持 64 位 jit。
干杯,
菲哈尔
Psyco assumes that sizeof(int) == sizeof(void*) a bit all over the place. That's much harder than just writing down 64bit calling conventions and assembler. On the sidenote, pypy has 64bit jit support these days.
Cheers,
fijal
+1 表示“...这有多难?”。
看一下这里: http://codespeak.net/svn/psyco /dist/c/i386/iprocessor.c
所有 ASM 都必须移植,并且到处都有关于底层处理器的假设。
我认为可以公平地说,如果移植很简单(或者不是太困难),那么它就已经完成了。
+1 for "... how hard could it be?".
Take a look here: http://codespeak.net/svn/psyco/dist/c/i386/iprocessor.c
All that ASM would have to be ported, and there are assumptions all over the place about the underlying processor.
I think it's fair to say that if it were trivial to port (or not too difficult), it would already have been done.