RFR(xs): 8244733: Add ResourceHashtable::compute_if_absent

Thomas Stüfe thomas.stuefe at gmail.com
Tue May 12 04:25:26 UTC 2020


Hi all,

May I please have reviews for this enhancement:

JBS: https://bugs.openjdk.java.net/browse/JDK-8244733
Webrev:
http://cr.openjdk.java.net/~stuefe/webrevs/8244733--add-resourcehashtable--compute_if_absent/webrev.00/webrev/

A common pattern when using ResourceHashTable is:

if (table.get(k) == NULL) table.add(k,v);

This runs the lookup code twice. By providing a new method which combines
these two operations we would save one lookup.

The new method is named ResourceHashTable::compute_if_absent() and behaves
very similar to the similarly named variant in j.u.Map.

Note: Actually replacing caller code will happen in a separate RFE. The
first caller to use this will be the ClassLoaderStats VM operation - I was
able to significantly reduce runtime for that vm op. But since that is JFR
territory and this is more of a runtime topic I wanted to keep the review
separate.

Thanks, Thomas


More information about the hotspot-runtime-dev mailing list