381
382 if (length == 0) {
383 return SECONDARY_SUPERS_BITMAP_EMPTY;
384 }
385
386 if (length == 1) {
387 int hash_slot = secondaries->at(0)->hash_slot();
388 return uintx(1) << hash_slot;
389 }
390
391 // Invariant: _secondary_supers.length >= population_count(_secondary_supers_bitmap)
392
393 // Don't attempt to hash a table that's completely full, because in
394 // the case of an absent interface linear probing would not
395 // terminate.
396 if (length >= SECONDARY_SUPERS_TABLE_SIZE) {
397 return SECONDARY_SUPERS_BITMAP_FULL;
398 }
399
400 {
401 PerfTraceTime ptt(ClassLoader::perf_secondary_hash_time());
402
403 ResourceMark rm;
404 uintx bitmap = SECONDARY_SUPERS_BITMAP_EMPTY;
405 auto hashed_secondaries = new GrowableArray<Klass*>(SECONDARY_SUPERS_TABLE_SIZE,
406 SECONDARY_SUPERS_TABLE_SIZE, nullptr);
407
408 for (int j = 0; j < length; j++) {
409 Klass* k = secondaries->at(j);
410 hash_insert(k, hashed_secondaries, bitmap);
411 }
412
413 // Pack the hashed secondaries array by copying it into the
414 // secondaries array, sans nulls, if modification is allowed.
415 // Otherwise, validate the order.
416 int i = 0;
417 for (int slot = 0; slot < SECONDARY_SUPERS_TABLE_SIZE; slot++) {
418 bool has_element = ((bitmap >> slot) & 1) != 0;
419 assert(has_element == (hashed_secondaries->at(slot) != nullptr), "");
420 if (has_element) {
421 Klass* k = hashed_secondaries->at(slot);
|
381
382 if (length == 0) {
383 return SECONDARY_SUPERS_BITMAP_EMPTY;
384 }
385
386 if (length == 1) {
387 int hash_slot = secondaries->at(0)->hash_slot();
388 return uintx(1) << hash_slot;
389 }
390
391 // Invariant: _secondary_supers.length >= population_count(_secondary_supers_bitmap)
392
393 // Don't attempt to hash a table that's completely full, because in
394 // the case of an absent interface linear probing would not
395 // terminate.
396 if (length >= SECONDARY_SUPERS_TABLE_SIZE) {
397 return SECONDARY_SUPERS_BITMAP_FULL;
398 }
399
400 {
401 //PerfTraceTime ptt(ClassLoader::perf_secondary_hash_time()); // Leyden FIXME
402
403 ResourceMark rm;
404 uintx bitmap = SECONDARY_SUPERS_BITMAP_EMPTY;
405 auto hashed_secondaries = new GrowableArray<Klass*>(SECONDARY_SUPERS_TABLE_SIZE,
406 SECONDARY_SUPERS_TABLE_SIZE, nullptr);
407
408 for (int j = 0; j < length; j++) {
409 Klass* k = secondaries->at(j);
410 hash_insert(k, hashed_secondaries, bitmap);
411 }
412
413 // Pack the hashed secondaries array by copying it into the
414 // secondaries array, sans nulls, if modification is allowed.
415 // Otherwise, validate the order.
416 int i = 0;
417 for (int slot = 0; slot < SECONDARY_SUPERS_TABLE_SIZE; slot++) {
418 bool has_element = ((bitmap >> slot) & 1) != 0;
419 assert(has_element == (hashed_secondaries->at(slot) != nullptr), "");
420 if (has_element) {
421 Klass* k = hashed_secondaries->at(slot);
|