简体   繁体   English

Windows x64的44位虚拟内存地址限制背后

[英]Behind Windows x64's 44-bit virtual memory address limit

http://www.alex-ionescu.com/?p=50 . http://www.alex-ionescu.com/?p=50

I read the above post. 我读了上面的帖子。 The author explains why Windows x64 supports only 44-bit virtual memory address with singly linked list example. 作者通过单链列表示例解释了为什么Windows x64仅支持44位虚拟内存地址。

 struct { // 8-byte header ULONGLONG Depth:16; ULONGLONG Sequence:9; ULONGLONG NextEntry:39; } Header8; 

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. 首先要做出的牺牲是将序列号的空间减少到9位而不是16位,减少列表可以达到的最大序列号。 This still only left 39 bits for the pointer — a mediocre improvement over 32 bits. 这仍然只剩下39位用于指针-比32位有中等改进。 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。


Oh, I can't understand. 哦,我听不懂。

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." “通过在分配时强制结构对齐16字节,可以再赢得4位,因为现在始终可以将最低位假定为0。” means? 手段?

16 is 0010000 in binary

32 is 0100000 in binary

64 is 1000000 in binary

etc 等等

You can see that for all numbers that are multiples of 16, the last four bits are always zero. 您可以看到,对于所有16的倍数,最后四位始终为零。 So, instead of storing these bits you can leave them out and add them back in when it's time to use the pointer. 因此,除了存储这些位之外,您还可以将其保留下来,并在需要使用指针时将其重新添加回去。

For a 2^N-byte aligned pointer, its address is always divisible by 2^N - which means that lower N bits are always zero. 对于2 ^ N字节的对齐指针,其地址始终可被2 ^ N整除-这意味着低N位始终为零。 You can store additional information in them: 您可以在其中存储其他信息:

encode ptr payload = ptr | payload
decode_ptr data = data & ~mask
decode_payload data = data & mask

where mask is (1 << N) - 1 - ie a number with low N bits set. 其中mask是(1 << N) - 1即设置了低N位的数字。

This trick is often used to save space in low-level code (payload can be GC flags, type tag, etc.) 此技巧通常用于在低级代码中节省空间(有效载荷可以是GC标志,类型标记等)

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. 当然,应注意不要将数字解引用为指针而不进行解码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在x64 Windows程序中选择堆栈的虚拟地址 - Choosing the virtual address of the stack in a x64 Windows program x64 Windows地址空间上的进程内存,GPU共享内存和x86进程 - Process memory, GPU shared memory and x86 process on x64 windows address space 为什么在Windows Vista x64上调用GlobalMemoryStatus时可用物理内存(dwAvailPhys)&gt;可用虚拟内存(dwAvailVirtual) - Why is Available Physical Memory (dwAvailPhys) > Available Virtual Memory (dwAvailVirtual) in call GlobalMemoryStatus on Windows Vista x64 如何在C ++中将x64机器代码写入虚拟内存并在Windows中执行 - How to write x64 machine code into virtual memory and execute it for Windows in C++ 在x64位版本中获取Windows目录的变量? - Variables to get windows directories in x64 bit version? Windows x64上的Python x64位复制文件性能评估/问题 - Python x64 bit on Windows x64 copy file performance evaluation / problem 在 windows x64 位上安装 Opencv-python 时出现问题 - Issue installing Opencv-python on windows x64 bit 64 位操作系统 (Windows) 上的 32 位应用程序内存限制 - 32 bit applications memory limit on a 64 bit OS (Windows) 将系统JRE从64位更改为32位(Windows 8 x64) - Change system JRE from 64bit to 32bit (Windows 8 x64) 哪个Java版本可以安装Windows x86,Windows x64,以便它将同时在32位和64位上运行 - which java version to install Windows x86,Windows x64 so that it will run on both 32 bit and 64 bit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM