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