0

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. Java JVM's had a feature called CompressedOops since 2010 (since 6u23). 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)?


The V8 implementation seems to be still not finalized, but I found at least some references:

  1. JVM implementation:

  2. V8 implementation

Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239

1 Answers1

1

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. (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.)

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.

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. 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).

jmrk
  • 34,271
  • 7
  • 59
  • 74
  • I can confirm what you wrote about the JVM. Their trick to shift by three bit and align each allocation at multiples of 8. – Philipp Claßen Dec 11 '19 at 10:38
  • 1
    The HotSpot JVM also supports a nonzero base address for the heap. When the configured maximum heap size is smaller than 4GiB, it will use only a base address without shifting. Further, when you configure it to use a stronger object alignment, e.g. multiple of 16 or 32 bytes, it is also possible to use a bigger address shift, supporting even 64 GiB or 128 GiB heap with compressed Oops. But this doesn’t happen automatically. – Holger Dec 11 '19 at 11:27