< prev index next >
src/hotspot/share/classfile/compactHashtable.hpp
Print this page
@@ -133,11 +133,11 @@
#define BUCKET_TYPE(info) (((info) & ~BUCKET_OFFSET_MASK) >> BUCKET_TYPE_SHIFT)
#define BUCKET_INFO(offset, type) (((type) << BUCKET_TYPE_SHIFT) | ((offset) & BUCKET_OFFSET_MASK))
/////////////////////////////////////////////////////////////////////////////
//
-// CompactHashtable is used to stored the CDS archive's symbol/string tables.
+// CompactHashtable is used to store the CDS archive's symbol/string tables.
//
// Because these tables are read-only (no entries can be added/deleted) at run-time
// and tend to have large number of entries, we try to minimize the footprint
// cost per entry.
//
@@ -209,12 +209,10 @@
_entry_count = entry_count;
_buckets = buckets;
_entries = entries;
}
- bool exists(u4 value);
-
// For reading from/writing to the CDS archive
void serialize(SerializeClosure* soc);
inline bool empty() {
return (_entry_count == 0);
@@ -228,17 +226,12 @@
bool (*EQUALS)(V value, K key, int len)
>
class CompactHashtable : public SimpleCompactHashtable {
friend class VMStructs;
- V if_equals(const K key, int len, u4 offset) const {
- V value = DECODE(_base_address, offset);
- if (EQUALS(value, key, len)) {
- return value;
- } else {
- return NULL;
- }
+ V decode(u4 offset) const {
+ return DECODE(_base_address, offset);
}
public:
CompactHashtable() : SimpleCompactHashtable() {}
@@ -250,25 +243,25 @@
u4 bucket_offset = BUCKET_OFFSET(bucket_info);
int bucket_type = BUCKET_TYPE(bucket_info);
u4* entry = _entries + bucket_offset;
if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
- V res = if_equals(key, len, entry[0]);
- if (res != NULL) {
- return res;
+ V value = decode(entry[0]);
+ if (EQUALS(value, key, len)) {
+ return value;
}
} else {
// This is a regular bucket, which has more than one
// entries. Each entry is a pair of entry (hash, offset).
// Seek until the end of the bucket.
u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
while (entry < entry_max) {
unsigned int h = (unsigned int)(entry[0]);
if (h == hash) {
- V res = if_equals(key, len, entry[1]);
- if (res != NULL) {
- return res;
+ V value = decode(entry[1]);
+ if (EQUALS(value, key, len)) {
+ return value;
}
}
entry += 2;
}
}
@@ -283,15 +276,15 @@
u4 bucket_offset = BUCKET_OFFSET(bucket_info);
int bucket_type = BUCKET_TYPE(bucket_info);
u4* entry = _entries + bucket_offset;
if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
- iter->do_value(DECODE(_base_address, entry[0]));
+ iter->do_value(decode(entry[0]));
} else {
u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
while (entry < entry_max) {
- iter->do_value(DECODE(_base_address, entry[1]));
+ iter->do_value(decode(entry[1]));
entry += 2;
}
}
}
}
< prev index next >