背后的Windows x64的44位虚拟内存地址限制 [英] Behind Windows x64's 44-bit virtual memory address limit
问题描述
http://www.alex-ionescu.com/?p=50。
我读了一柱上。
作者解释了单向链表例如为什么的Windows x64只支持44位虚拟内存地址。
Author explains the why Windows x64 supports only 44-bit virtual memory address with singly linked list example.
结构{// 8字节标题 ULONGLONG深度:16; ULONGLONG顺序:9; ULONGLONG NextEntry:39; } Header8;
struct { // 8-byte header ULONGLONG Depth:16; ULONGLONG Sequence:9; ULONGLONG NextEntry:39; } Header8;
第一牺牲做出是为了减少对的序列号空间向9位,而不是16位,减少了最大序列号的名单可以实现。这仍然只能留下39位的指针 - 一个平庸的改进32位。通过迫使结构是16字节,分配时对齐,4更多的位可以争取,由于底位现在可以始终被假定为0
The first sacrifice to make was to reduce the space for the sequence number to 9 bits instead of 16 bits, reducing the maximum sequence number the list could achieve. This still only left 39 bits for the pointer — a mediocre improvement over 32 bits. By forcing the structure to be 16-byte aligned when allocated, 4 more bits could be won, since the bottom bits could now always be assumed to be 0.
呵呵,我无法理解。
什么通过迫使结构是16字节,分配时对齐,4更多的位可以争取,由于底位现在可以总是被假设为0。手段?
What "By forcing the structure to be 16-byte aligned when allocated, 4 more bits could be won, since the bottom bits could now always be assumed to be 0." means?
推荐答案
对于2 ^ N字节对齐的指针,它的地址总是能被2整除^ N - 这意味着较低N位始终为零。您可以在其中存储附加信息:
For a 2^N-byte aligned pointer, its address is always divisible by 2^N - which means that lower N bits are always zero. You can store additional information in them:
encode ptr payload = ptr | payload
decode_ptr data = data & ~mask
decode_payload data = data & mask
其中,掩码为(1<< N) - 1
- 即一些具有低氮位设置
where mask is (1 << N) - 1
- i.e. a number with low N bits set.
这招经常被用来保存在低级别的code空间(有效载荷可以被GC标志,类型标记等。)
This trick is often used to save space in low-level code (payload can be GC flags, type tag, etc.)
在影响你不保存一个指针,而是一个号码,在指针可以提取。当然,应注意,以不取消引用号码作为不进行解码的指针。
In effect you're not storing a pointer, but a number from which a pointer can be extracted. Of course, care should be taken to not dereference the number as a pointer without decoding.
这篇关于背后的Windows x64的44位虚拟内存地址限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!