Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8234628: Change BasicHashTables::new_entry() to use clamp()
Reviewed-by: dcubed
  • Loading branch information
iklam committed Jun 2, 2020
1 parent 9c99008 commit ccb6d0e5721d998f2c5d568a3e1912d5e2d96886
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/hotspot/share/utilities/hashtable.cpp
@@ -61,7 +61,8 @@ template <MEMFLAGS F> BasicHashtableEntry<F>* BasicHashtable<F>::new_entry(unsig

if (entry == NULL) {
if (_first_free_entry + _entry_size >= _end_block) {
int block_size = MIN2(512, MAX3(2, (int)_table_size / 2, (int)_number_of_entries));
int block_size = MAX2((int)_table_size / 2, (int)_number_of_entries); // pick a reasonable value
block_size = clamp(block_size, 2, 512); // but never go out of this range
int len = _entry_size * block_size;
len = 1 << log2_int(len); // round down to power of 2
assert(len >= _entry_size, "");

0 comments on commit ccb6d0e

Please sign in to comment.