简体   繁体   English

V8 中的压缩指针实现与 JVM 的压缩 Oops 有何不同?

[英]How does the compressed pointer implementation in V8 differ from JVM's compressed Oops?

Background: V8 announced a feature called pointer compression ( What's happening in V8? - Benedikt Meurer ), which is intended to reduce the memory overhead of pointers for 64-bit processes.背景:V8 宣布了一项称为指针压缩的功能( V8 中发生了什么?- Benedikt Meurer ),旨在减少 64 位进程的指针的内存开销。 Java JVM's had a feature called CompressedOops since 2010 (since 6u23). Java JVM 自 2010 年(自 6u23 起)就有一个称为CompressedOops的功能。 At a first glance, it looks similar but then I realized it is not quite the same.乍一看,它看起来很相似,但后来我意识到它并不完全相同。

Question: What are the main differences between the pointer compression techniques (V8 vs JVM)?问题:指针压缩技术(V8 与 JVM)之间的主要区别是什么?


The V8 implementation seems to be still not finalized, but I found at least some references: V8 的实现似乎还没有最终确定,但我至少找到了一些参考资料:

  1. JVM implementation: JVM 实现:

  2. V8 implementation V8 实现

I think the links you provided already contain the answer?我认为您提供的链接已经包含答案? In short:简而言之:

JVM's "compressed Oops" save 3 bits via shifting and thereby make it possible to address 2³ * 4 GB using 32-bit pointers at 8-byte granularity. JVM 的“压缩 Oops”通过移位节省了 3 位,从而可以使用 8 字节粒度的 32 位指针寻址 2³ * 4 GB。 (At least that's what your link says; I know nothing about the JVM so I cannot confirm or deny that this is accurate information.) (至少你的链接是这样说的;我对 JVM 一无所知,所以我无法确认或否认这是准确的信息。)

V8's "compressed pointers" pick a base address somewhere in the 64 (well, 48 really) bit address space and then store all heap pointers as 32-bit offsets from that base address, so the maximum heap size that can be addressed in this mode is 4GB. V8 的“压缩指针”在 64 位(实际上是 48 位)地址空间中的某处选择一个基地址,然后将所有堆指针存储为该基地址的 32 位偏移量,因此可以在这种模式下寻址的最大堆大小是 4GB。

I would guess that the JVM also needs to employ some variant of a base address, otherwise the shifted pointers would be limited to a very small and fixed subset of the full address space.我猜想 JVM 也需要使用一些基地址的变体,否则移位的指针将被限制在完整地址空间的一个非常小的固定子集。 V8's approach leaves the bits around that the JVM shifts away, which is nice for V8's purposes because it uses those bits to store other information (its pointers are tagged, and the tags are in those bits). V8 的方法留下了 JVM 移开的位,这对 V8 的目的来说很好,因为它使用这些位来存储其他信息(它的指针被标记,并且标记在这些位中)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM