Skip to content

Commit f754840

Browse files
author
Thomas Schatzl
committed
8296773: G1: Factor out hash function for G1CardSet
Reviewed-by: iwalulya, kbarrett
1 parent fdabd37 commit f754840

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/hotspot/share/gc/g1/g1CardSet.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ G1CardSet::ContainerPtr G1CardSet::FullCardSet = (G1CardSet::ContainerPtr)-1;
4141
uint G1CardSet::_split_card_shift = 0;
4242
size_t G1CardSet::_split_card_mask = 0;
4343

44+
class G1CardSetHashTableConfig : public StackObj {
45+
public:
46+
using Value = G1CardSetHashTableValue;
47+
48+
static uintx get_hash(Value const& value, bool* is_dead);
49+
static void* allocate_node(void* context, size_t size, Value const& value);
50+
static void free_node(void* context, void* memory, Value const& value);
51+
};
52+
53+
using CardSetHash = ConcurrentHashTable<G1CardSetHashTableConfig, mtGCCardSet>;
54+
4455
static uint default_log2_card_regions_per_region() {
4556
uint log2_card_regions_per_heap_region = 0;
4657

@@ -241,7 +252,7 @@ class G1CardSetHashTable : public CHeapObj<mtGCCardSet> {
241252
public:
242253
explicit G1CardSetHashTableLookUp(uint region_idx) : _region_idx(region_idx) { }
243254

244-
uintx get_hash() const { return _region_idx; }
255+
uintx get_hash() const { return G1CardSetHashTable::get_hash(_region_idx); }
245256

246257
bool equals(G1CardSetHashTableValue* value, bool* is_dead) {
247258
*is_dead = false;
@@ -307,6 +318,10 @@ class G1CardSetHashTable : public CHeapObj<mtGCCardSet> {
307318
return found.value();
308319
}
309320

321+
static uint get_hash(uint region_idx) {
322+
return region_idx;
323+
}
324+
310325
G1CardSetHashTableValue* get(uint region_idx) {
311326
G1CardSetHashTableLookUp lookup(region_idx);
312327
G1CardSetHashTableFound found;
@@ -345,6 +360,11 @@ class G1CardSetHashTable : public CHeapObj<mtGCCardSet> {
345360
size_t log_table_size() { return _table.get_size_log2(Thread::current()); }
346361
};
347362

363+
uintx G1CardSetHashTableConfig::get_hash(Value const& value, bool* is_dead) {
364+
*is_dead = false;
365+
return G1CardSetHashTable::get_hash(value._region_idx);
366+
}
367+
348368
void* G1CardSetHashTableConfig::allocate_node(void* context, size_t size, Value const& value) {
349369
G1CardSetMemoryManager* mm = (G1CardSetMemoryManager*)context;
350370
return mm->allocate_node();

src/hotspot/share/gc/g1/g1CardSet.hpp

-14
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,4 @@ class G1CardSetHashTableValue {
414414
G1CardSetHashTableValue(uint region_idx, ContainerPtr container) : _region_idx(region_idx), _num_occupied(0), _container(container) { }
415415
};
416416

417-
class G1CardSetHashTableConfig : public StackObj {
418-
public:
419-
using Value = G1CardSetHashTableValue;
420-
421-
static uintx get_hash(Value const& value, bool* is_dead) {
422-
*is_dead = false;
423-
return value._region_idx;
424-
}
425-
static void* allocate_node(void* context, size_t size, Value const& value);
426-
static void free_node(void* context, void* memory, Value const& value);
427-
};
428-
429-
using CardSetHash = ConcurrentHashTable<G1CardSetHashTableConfig, mtGCCardSet>;
430-
431417
#endif // SHARE_GC_G1_G1CARDSET_HPP

0 commit comments

Comments
 (0)