Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim identity-hashcode to 25bit #3

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/hotspot/share/oops/markWord.hpp
Expand Up @@ -41,8 +41,8 @@
//
// 64 bits:
// --------
// unused:25 hash:31 -->| unused_gap:1 age:4 biased_lock:1 lock:2 (normal object)
// JavaThread*:54 epoch:2 unused_gap:1 age:4 biased_lock:1 lock:2 (biased object)
// unused:32 hash:25 -->| age:4 biased_lock:1 lock:2 (normal object)
// JavaThread*:54 epoch:2 age:4 biased_lock:1 lock:2 (biased object)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not compute. Where did the unused_gap go in the second case? Is epoch now larger? Or does JavaThread* now takes 55 bits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Epoch and JavaThread in the biased case are already overlaid with hashcode. Hashcode and biased state doesn't happen at the same time. 32+25+4+1+2 == 64.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, unused_gap is now used, epoch is moved 1 bit to the right and JavaThread is now 55 bits (actually, I guess it is still 54 bits and the uppermost bit is unused). I will correct this.

//
// - hash contains the identity hash value: largest value is
// 31 bits, see os::random(). Also, 64-bit vm's require
Expand Down Expand Up @@ -130,17 +130,15 @@ class markWord {
static const int lock_bits = 2;
static const int biased_lock_bits = 1;
static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - biased_lock_bits;
static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;
static const int unused_gap_bits = LP64_ONLY(1) NOT_LP64(0);
static const int hash_bits = max_hash_bits > 25 ? 25 : max_hash_bits;
static const int epoch_bits = 2;

// The biased locking code currently requires that the age bits be
// contiguous to the lock bits.
static const int lock_shift = 0;
static const int biased_lock_shift = lock_bits;
static const int age_shift = lock_bits + biased_lock_bits;
static const int unused_gap_shift = age_shift + age_bits;
static const int hash_shift = unused_gap_shift + unused_gap_bits;
static const int hash_shift = age_shift + age_bits;
static const int epoch_shift = hash_shift;

static const uintptr_t lock_mask = right_n_bits(lock_bits);
Expand Down
12 changes: 9 additions & 3 deletions src/hotspot/share/services/heapObjectStatistics.cpp
Expand Up @@ -137,15 +137,21 @@ void HeapObjectStatistics::begin_sample() {

void HeapObjectStatistics::visit_object(oop obj) {
increase_counter(_num_objects);
if (!obj->mark().has_no_hash()) {
markWord mark = obj->mark();
if (!mark.has_no_hash()) {
increase_counter(_num_ihashed);
if (obj->mark().age() > 0) {
if (mark.age() > 0) {
increase_counter(_num_ihashed_moved);
}
}
if (obj->mark().is_locked()) {
if (mark.is_locked()) {
increase_counter(_num_locked);
}
#ifdef ASSERT
if (!mark.has_displaced_mark_helper()) {
assert((mark.value() & 0xffffffff00000000) == 0, "upper 32 mark bits must be free");
}
#endif
increase_counter(_lds, obj->size());
}

Expand Down