171 // bucket_info table is a 32-bit encoding of the bucket type and bucket offset,
172 // with the type in the left-most 2-bit and offset in the remaining 30-bit.
173 // The last entry is a special type. It contains the offset of the last
174 // bucket end. We use that information when traversing the compact table.
175 //
176 // There are two types of buckets, regular buckets and compact buckets. The
177 // compact buckets have '01' in their highest 2-bit, and regular buckets have
178 // '00' in their highest 2-bit.
179 //
180 // For normal buckets, each symbol's entry is 8 bytes in the table[]:
181 // juint hash; /* symbol hash */
182 // juint offset; /* Symbol* sym = (Symbol*)(base_address + offset) */
183 //
184 // For compact buckets, each entry has only the 4-byte 'offset' in the table[].
185 //
186 // See CompactHashtable::lookup() for how the table is searched at runtime.
187 // See CompactHashtableWriter::dump() for how the table is written at CDS
188 // dump time.
189 //
190 template <class T, class N> class CompactHashtable VALUE_OBJ_CLASS_SPEC {
191 uintx _base_address;
192 juint _entry_count;
193 juint _bucket_count;
194 juint _table_end_offset;
195 juint* _buckets;
196
197 inline bool equals(T entry, const char* name, int len) {
198 if (entry->equals(name, len)) {
199 assert(entry->refcount() == -1, "must be shared");
200 return true;
201 } else {
202 return false;
203 }
204 }
205
206 public:
207 CompactHashtable() {
208 _entry_count = 0;
209 _bucket_count = 0;
210 _table_end_offset = 0;
|
171 // bucket_info table is a 32-bit encoding of the bucket type and bucket offset,
172 // with the type in the left-most 2-bit and offset in the remaining 30-bit.
173 // The last entry is a special type. It contains the offset of the last
174 // bucket end. We use that information when traversing the compact table.
175 //
176 // There are two types of buckets, regular buckets and compact buckets. The
177 // compact buckets have '01' in their highest 2-bit, and regular buckets have
178 // '00' in their highest 2-bit.
179 //
180 // For normal buckets, each symbol's entry is 8 bytes in the table[]:
181 // juint hash; /* symbol hash */
182 // juint offset; /* Symbol* sym = (Symbol*)(base_address + offset) */
183 //
184 // For compact buckets, each entry has only the 4-byte 'offset' in the table[].
185 //
186 // See CompactHashtable::lookup() for how the table is searched at runtime.
187 // See CompactHashtableWriter::dump() for how the table is written at CDS
188 // dump time.
189 //
190 template <class T, class N> class CompactHashtable VALUE_OBJ_CLASS_SPEC {
191 friend class VMStructs;
192 uintx _base_address;
193 juint _entry_count;
194 juint _bucket_count;
195 juint _table_end_offset;
196 juint* _buckets;
197
198 inline bool equals(T entry, const char* name, int len) {
199 if (entry->equals(name, len)) {
200 assert(entry->refcount() == -1, "must be shared");
201 return true;
202 } else {
203 return false;
204 }
205 }
206
207 public:
208 CompactHashtable() {
209 _entry_count = 0;
210 _bucket_count = 0;
211 _table_end_offset = 0;
|