336 const int length = secondaries->length();
337
338 if (length == 0) {
339 return SECONDARY_SUPERS_BITMAP_EMPTY;
340 }
341
342 if (length == 1) {
343 int hash_slot = secondaries->at(0)->hash_slot();
344 return uintx(1) << hash_slot;
345 }
346
347 // For performance reasons we don't use a hashed table unless there
348 // are at least two empty slots in it. If there were only one empty
349 // slot it'd take a long time to create the table and the resulting
350 // search would be no faster than linear probing.
351 if (length > SECONDARY_SUPERS_TABLE_SIZE - 2) {
352 return SECONDARY_SUPERS_BITMAP_FULL;
353 }
354
355 {
356 PerfTraceTime ptt(ClassLoader::perf_secondary_hash_time());
357
358 ResourceMark rm;
359 uintx bitmap = SECONDARY_SUPERS_BITMAP_EMPTY;
360 auto hashed_secondaries = new GrowableArray<Klass*>(SECONDARY_SUPERS_TABLE_SIZE,
361 SECONDARY_SUPERS_TABLE_SIZE, nullptr);
362
363 for (int j = 0; j < length; j++) {
364 Klass* k = secondaries->at(j);
365 hash_insert(k, hashed_secondaries, bitmap);
366 }
367
368 // Pack the hashed secondaries array by copying it into the
369 // secondaries array, sans nulls, if modification is allowed.
370 // Otherwise, validate the order.
371 int i = 0;
372 for (int slot = 0; slot < SECONDARY_SUPERS_TABLE_SIZE; slot++) {
373 bool has_element = ((bitmap >> slot) & 1) != 0;
374 assert(has_element == (hashed_secondaries->at(slot) != nullptr), "");
375 if (has_element) {
376 Klass* k = hashed_secondaries->at(slot);
|
336 const int length = secondaries->length();
337
338 if (length == 0) {
339 return SECONDARY_SUPERS_BITMAP_EMPTY;
340 }
341
342 if (length == 1) {
343 int hash_slot = secondaries->at(0)->hash_slot();
344 return uintx(1) << hash_slot;
345 }
346
347 // For performance reasons we don't use a hashed table unless there
348 // are at least two empty slots in it. If there were only one empty
349 // slot it'd take a long time to create the table and the resulting
350 // search would be no faster than linear probing.
351 if (length > SECONDARY_SUPERS_TABLE_SIZE - 2) {
352 return SECONDARY_SUPERS_BITMAP_FULL;
353 }
354
355 {
356 //PerfTraceTime ptt(ClassLoader::perf_secondary_hash_time()); // Leyden FIXME
357
358 ResourceMark rm;
359 uintx bitmap = SECONDARY_SUPERS_BITMAP_EMPTY;
360 auto hashed_secondaries = new GrowableArray<Klass*>(SECONDARY_SUPERS_TABLE_SIZE,
361 SECONDARY_SUPERS_TABLE_SIZE, nullptr);
362
363 for (int j = 0; j < length; j++) {
364 Klass* k = secondaries->at(j);
365 hash_insert(k, hashed_secondaries, bitmap);
366 }
367
368 // Pack the hashed secondaries array by copying it into the
369 // secondaries array, sans nulls, if modification is allowed.
370 // Otherwise, validate the order.
371 int i = 0;
372 for (int slot = 0; slot < SECONDARY_SUPERS_TABLE_SIZE; slot++) {
373 bool has_element = ((bitmap >> slot) & 1) != 0;
374 assert(has_element == (hashed_secondaries->at(slot) != nullptr), "");
375 if (has_element) {
376 Klass* k = hashed_secondaries->at(slot);
|