带有 x86-64 ISA 的 32 位指针:为什么不呢? [英] 32-bit pointers with the x86-64 ISA: why not?

查看:39
本文介绍了带有 x86-64 ISA 的 32 位指针:为什么不呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

x86-64 指令集添加了更多寄存器和其他改进,以帮助简化可执行代码.但是,在许多应用程序中,增加的指针大小是一种负担.每个指针中额外的、未使用的字节会阻塞缓存,甚至可能溢出 RAM.例如,GCC 使用 -m32 标志构建,我认为这就是原因.

The x86-64 instruction set adds more registers and other improvements to help streamline executable code. However, in many applications the increased pointer size is a burden. The extra, unused bytes in every pointer clog up the cache and might even overflow RAM. GCC, for example, builds with the -m32 flag, and I assume this is the reason.

可以加载 32 位值并将其视为指针.这不需要额外的指令,只需加载/计算 32 位并从结果地址加载.然而,这个技巧不会是可移植的,因为平台有不同的内存映射.在 Mac OS X 上,整个低 4 GiB 地址空间被保留.尽管如此,对于我编写的一个程序,在使用之前将 0x100000000L 添加到 32 位地址",大大提高了真正的 64 位地址的性能,或者使用 -m32 进行编译.

It's possible to load a 32-bit value and treat it as a pointer. This doesn't necessitate extra instructions, just load/compute the 32 bits and load from the resulting address. The trick won't be portable, though, as platforms have different memory maps. On Mac OS X, the entire low 4 GiB of address space is reserved. Still, for one program I wrote, hackishly adding 0x100000000L to 32-bit "addresses" before use improved performance greatly over true 64-bit addresses, or compiling with -m32.

使用 32 位 x86-64 平台有什么根本性的障碍吗?我认为支持这样的嵌合体会增加任何操作系统的复杂性,任何想要最后 20% 的人都应该让它工作™,但似乎这仍然是各种计算密集型程序的最佳选择.

Is there any fundamental impediment to having a 32-bit, x86-64 platform? I suppose that supporting such a chimera would add complexity to any operating system, and anyone wanting that last 20% should just Make it Work™, but it still seems that this would be the best fit for a variety of computationally intensive programs.

推荐答案

有一个名为x32"的 ABI 用于正在开发的 linux.它是 x86_64 和 ia32 之间的混合,类似于您所描述的 - 32 位地址空间,同时使用完整的 64 位寄存器集.它需要一个自定义内核、binutils 和 gcc.

There is an ABI called "x32" for linux in development. It's a mix between x86_64 and ia32 similar to what you describe - 32 bit address space while using the full 64 bit register set. It needs a custom kernel, binutils and gcc.

某些 SPEC 运行表明在某些基准测试中性能提高了约 30%.请访问 https://sites.google.com/site/x32abi/

Some SPEC runs indicate a performace improvement of about 30% in some benchmarks. See further information at https://sites.google.com/site/x32abi/

这篇关于带有 x86-64 ISA 的 32 位指针:为什么不呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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