RFR (S): 8233702: Introduce helper function to clamp value to range
Thomas Schatzl
thomas.schatzl at oracle.com
Tue Nov 12 09:17:16 UTC 2019
Hi all,
I would like to introduce a small helper function to clamp a given
value between a min/max value.
This would unclutter a few MIN(MAX(value, <min_value>), <max_value>)
statements for imho better readability.
There are two places in (non-CMS) code remaining with the above
statement, because in these cases it happens that a value min > max is
passed, i.e. you potentially (already) get returned unexpected values.
(I did remove that assert in this webrev)
These are in
methodData.cpp:
int MethodData::compute_extra_data_count(int data_size, int
empty_bc_count, bool needs_speculative_traps) {
933: int extra_data_count = MIN2(empty_bc_count, MAX2(4,
(empty_bc_count * 30) / 100));
hashtable.cpp:
template <MEMFLAGS F> BasicHashtableEntry<F>*
BasicHashtable<F>::new_entry(unsigned int hashValue) {
64: int block_size = MIN2(512, MAX2((int)_table_size / 2,
(int)_number_of_entries));
I would like to ask the responsible teams (compiler and runtime) to give
an opinion on these cases, i.e. if these should be converted (these are
intentional) or I should file an RFE to investigate further.
CR:
https://bugs.openjdk.java.net/browse/JDK-8233702
Webrev:
http://cr.openjdk.java.net/~tschatzl/8233702/webrev/
Testing:
hs-tier1-5
Thanks,
Thomas
More information about the hotspot-dev
mailing list