yangyixiaof
yangyixiaof

Reputation: 257

What is the function of jdk's UseCompressedOops?

See the following:

void link_prev(FreeChunk* ptr) {
  LP64_ONLY(if (UseCompressedOops) _prev = ptr; else)
  _prev = (FreeChunk*)((intptr_t)ptr | 0x1);
}

If not LP64 why should '_prev = ptr | 0x1' instead of '_prev = ptr' directly?

This code is from jdk8/openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeChunk.hpp line 118.

Upvotes: 1

Views: 2964

Answers (1)

yangyixiaof
yangyixiaof

Reputation: 257

Sorry,every one,I am answering my own question here.

_prev = (ptr | 0x1); It's meaning is that the _prev is free for use.

If an address pointer's last bit being 1 means the space the address pointer pointed to is free.

Similarly last bit being 0 means not free.

It is just a jdk implementation trick I guess.

Upvotes: 1

Related Questions