75 size_t _number_of_entries;
76
77 protected:
78 JfrBasicHashtable(uintptr_t table_size, size_t entry_size) :
79 _buckets(NULL), _table_size(table_size), _entry_size(entry_size), _number_of_entries(0) {
80 _buckets = NEW_C_HEAP_ARRAY2(Bucket, table_size, mtTracing, CURRENT_PC);
81 memset((void*)_buckets, 0, table_size * sizeof(Bucket));
82 }
83
84 size_t hash_to_index(uintptr_t full_hash) const {
85 const uintptr_t h = full_hash % _table_size;
86 assert(h >= 0 && h < _table_size, "Illegal hash value");
87 return (size_t)h;
88 }
89 size_t entry_size() const { return _entry_size; }
90 void unlink_entry(TableEntry* entry) {
91 entry->set_next(NULL);
92 --_number_of_entries;
93 }
94 void free_buckets() {
95 if (NULL != _buckets) {
96 FREE_C_HEAP_ARRAY(Bucket, _buckets);
97 _buckets = NULL;
98 }
99 }
100 TableEntry* bucket(size_t i) { return _buckets[i].get_entry();}
101 TableEntry** bucket_addr(size_t i) { return _buckets[i].entry_addr(); }
102 uintptr_t table_size() const { return _table_size; }
103 size_t number_of_entries() const { return _number_of_entries; }
104 void add_entry(size_t index, TableEntry* entry) {
105 assert(entry != NULL, "invariant");
106 entry->set_next(bucket(index));
107 _buckets[index].set_entry(entry);
108 ++_number_of_entries;
109 }
110 };
111
112 template <typename IdType, typename Entry, typename T>
113 class AscendingId : public CHeapObj<mtTracing> {
114 private:
115 IdType _id;
116 public:
117 AscendingId() : _id(0) {}
118 // callbacks
|
75 size_t _number_of_entries;
76
77 protected:
78 JfrBasicHashtable(uintptr_t table_size, size_t entry_size) :
79 _buckets(NULL), _table_size(table_size), _entry_size(entry_size), _number_of_entries(0) {
80 _buckets = NEW_C_HEAP_ARRAY2(Bucket, table_size, mtTracing, CURRENT_PC);
81 memset((void*)_buckets, 0, table_size * sizeof(Bucket));
82 }
83
84 size_t hash_to_index(uintptr_t full_hash) const {
85 const uintptr_t h = full_hash % _table_size;
86 assert(h >= 0 && h < _table_size, "Illegal hash value");
87 return (size_t)h;
88 }
89 size_t entry_size() const { return _entry_size; }
90 void unlink_entry(TableEntry* entry) {
91 entry->set_next(NULL);
92 --_number_of_entries;
93 }
94 void free_buckets() {
95 FREE_C_HEAP_ARRAY(Bucket, _buckets);
96 _buckets = NULL;
97 }
98 TableEntry* bucket(size_t i) { return _buckets[i].get_entry();}
99 TableEntry** bucket_addr(size_t i) { return _buckets[i].entry_addr(); }
100 uintptr_t table_size() const { return _table_size; }
101 size_t number_of_entries() const { return _number_of_entries; }
102 void add_entry(size_t index, TableEntry* entry) {
103 assert(entry != NULL, "invariant");
104 entry->set_next(bucket(index));
105 _buckets[index].set_entry(entry);
106 ++_number_of_entries;
107 }
108 };
109
110 template <typename IdType, typename Entry, typename T>
111 class AscendingId : public CHeapObj<mtTracing> {
112 private:
113 IdType _id;
114 public:
115 AscendingId() : _id(0) {}
116 // callbacks
|