RFR(T) 8234628 Change BasicHashTables::new_entry() to use clamp()

Ioi Lam ioi.lam at oracle.com
Tue Jun 2 15:33:36 UTC 2020


https://bugs.openjdk.java.net/browse/JDK-8234628

A small clean up. Rewrite the code to say what it means to do

Tested with mach5 tier1/2


$ hg diff
diff -r 37c816b004e5 src/hotspot/share/utilities/hashtable.cpp
--- a/src/hotspot/share/utilities/hashtable.cpp    Tue Jun 02 01:08:44 
2020 -0700
+++ b/src/hotspot/share/utilities/hashtable.cpp    Tue Jun 02 08:24:59 
2020 -0700
@@ -61,7 +61,8 @@

    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, "");

Thanks
- Ioi


More information about the hotspot-runtime-dev mailing list