mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-21 21:33:07 +00:00
8293972: runtime/NMT/NMTInitializationTest.java#default_long-off failed with "Suspiciously long bucket chains in lookup table."
Reviewed-by: stuefe, dholmes
This commit is contained in:
parent
97b688340e
commit
78f67993f8
@ -143,22 +143,25 @@ class NMTPreInitAllocationTable {
|
||||
// VMs with insanely long command lines maybe ~700-1000. Which gives us an expected
|
||||
// load factor of ~.1. Hash collisions should be very rare.
|
||||
// ~8000 entries cost us ~64K for this table (64-bit), which is acceptable.
|
||||
static const int table_size = 7919;
|
||||
// We chose 8191, as this is a Mersenne prime (2^x - 1), which for a random
|
||||
// polynomial modulo p = (2^x - 1) is uniformily distributed in [p], so each
|
||||
// bit has the same distribution.
|
||||
static const int table_size = 8191; // i.e. 8191==(2^13 - 1);
|
||||
|
||||
NMTPreInitAllocation* _entries[table_size];
|
||||
|
||||
typedef int index_t;
|
||||
const index_t invalid_index = -1;
|
||||
|
||||
static unsigned calculate_hash(const void* p) {
|
||||
uintptr_t tmp = p2i(p);
|
||||
unsigned hash = (unsigned)tmp
|
||||
LP64_ONLY( ^ (unsigned)(tmp >> 32));
|
||||
return hash;
|
||||
static uint64_t calculate_hash(const void* p) {
|
||||
// Keep hash function simple, the modulo
|
||||
// operation in index function will do the "heavy lifting".
|
||||
return (uint64_t)(p);
|
||||
}
|
||||
|
||||
static index_t index_for_key(const void* p) {
|
||||
const unsigned hash = calculate_hash(p);
|
||||
const uint64_t hash = calculate_hash(p);
|
||||
// "table_size" is a Mersenne prime, so "modulo" is all we need here.
|
||||
return hash % table_size;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user