mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8371418: Methods in AdapterHandlerLibrary use HashtableBase iterate method incorrectly
Reviewed-by: kvn, adinn
This commit is contained in:
parent
8a911aed26
commit
cc54d2c06b
@ -518,7 +518,7 @@ void LambdaProxyClassDictionary::print_on(const char* prefix,
|
||||
if (!dictionary->empty()) {
|
||||
st->print_cr("%sShared Lambda Dictionary", prefix);
|
||||
SharedLambdaDictionaryPrinter ldp(st, start_index);
|
||||
dictionary->iterate(&ldp);
|
||||
dictionary->iterate_all(&ldp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -294,6 +294,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Iterate through the values in the table, stopping when do_value() returns false.
|
||||
template <class ITER>
|
||||
inline void iterate(ITER* iter) const { iterate([&](V v) { iter->do_value(v); }); }
|
||||
|
||||
@ -302,6 +303,7 @@ public:
|
||||
iterate(const_cast<Function&>(function));
|
||||
}
|
||||
|
||||
// Iterate through the values in the table, stopping when the lambda returns false.
|
||||
template<typename Function>
|
||||
inline void iterate(Function& function) const { // lambda enabled API
|
||||
for (u4 i = 0; i < _bucket_count; i++) {
|
||||
@ -311,17 +313,35 @@ public:
|
||||
u4* entry = _entries + bucket_offset;
|
||||
|
||||
if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
|
||||
function(decode(entry[0]));
|
||||
if (!function(decode(entry[0]))) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
u4* entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
|
||||
while (entry < entry_max) {
|
||||
function(decode(entry[1]));
|
||||
if (!function(decode(entry[1]))) {
|
||||
return;
|
||||
}
|
||||
entry += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unconditionally iterate through all the values in the table
|
||||
template <class ITER>
|
||||
inline void iterate_all(ITER* iter) const { iterate_all([&](V v) { iter->do_value(v); }); }
|
||||
|
||||
// Unconditionally iterate through all the values in the table using lambda
|
||||
template<typename Function>
|
||||
void iterate_all(Function function) const { // lambda enabled API
|
||||
auto wrapper = [&] (V v) {
|
||||
function(v);
|
||||
return true;
|
||||
};
|
||||
iterate(wrapper);
|
||||
}
|
||||
|
||||
void print_table_statistics(outputStream* st, const char* name) {
|
||||
st->print_cr("%s statistics:", name);
|
||||
int total_entries = 0;
|
||||
|
||||
@ -908,7 +908,7 @@ void StringTable::dump(outputStream* st, bool verbose) {
|
||||
st->print_cr("# Shared strings:");
|
||||
st->print_cr("#----------------");
|
||||
PrintSharedString pss(thr, st);
|
||||
_shared_table.iterate(&pss);
|
||||
_shared_table.iterate_all(&pss);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -272,9 +272,7 @@ public:
|
||||
void SymbolTable::symbols_do(SymbolClosure *cl) {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
|
||||
// all symbols from shared table
|
||||
SharedSymbolIterator iter(cl);
|
||||
_shared_table.iterate(&iter);
|
||||
_dynamic_shared_table.iterate(&iter);
|
||||
shared_symbols_do(cl);
|
||||
|
||||
// all symbols from the dynamic table
|
||||
SymbolsDo sd(cl);
|
||||
@ -284,8 +282,8 @@ void SymbolTable::symbols_do(SymbolClosure *cl) {
|
||||
// Call function for all symbols in shared table. Used by -XX:+PrintSharedArchiveAndExit
|
||||
void SymbolTable::shared_symbols_do(SymbolClosure *cl) {
|
||||
SharedSymbolIterator iter(cl);
|
||||
_shared_table.iterate(&iter);
|
||||
_dynamic_shared_table.iterate(&iter);
|
||||
_shared_table.iterate_all(&iter);
|
||||
_dynamic_shared_table.iterate_all(&iter);
|
||||
}
|
||||
|
||||
Symbol* SymbolTable::lookup_dynamic(const char* name,
|
||||
@ -669,14 +667,14 @@ void SymbolTable::dump(outputStream* st, bool verbose) {
|
||||
st->print_cr("# Shared symbols:");
|
||||
st->print_cr("#----------------");
|
||||
DumpSharedSymbol dss(st);
|
||||
_shared_table.iterate(&dss);
|
||||
_shared_table.iterate_all(&dss);
|
||||
}
|
||||
if (!_dynamic_shared_table.empty()) {
|
||||
st->print_cr("#------------------------");
|
||||
st->print_cr("# Dynamic shared symbols:");
|
||||
st->print_cr("#------------------------");
|
||||
DumpSharedSymbol dss(st);
|
||||
_dynamic_shared_table.iterate(&dss);
|
||||
_dynamic_shared_table.iterate_all(&dss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1431,11 +1431,11 @@ const char* SystemDictionaryShared::loader_type_for_shared_class(Klass* k) {
|
||||
}
|
||||
|
||||
void SystemDictionaryShared::get_all_archived_classes(bool is_static_archive, GrowableArray<Klass*>* classes) {
|
||||
get_archive(is_static_archive)->_builtin_dictionary.iterate([&] (const RunTimeClassInfo* record) {
|
||||
get_archive(is_static_archive)->_builtin_dictionary.iterate_all([&] (const RunTimeClassInfo* record) {
|
||||
classes->append(record->klass());
|
||||
});
|
||||
|
||||
get_archive(is_static_archive)->_unregistered_dictionary.iterate([&] (const RunTimeClassInfo* record) {
|
||||
get_archive(is_static_archive)->_unregistered_dictionary.iterate_all([&] (const RunTimeClassInfo* record) {
|
||||
classes->append(record->klass());
|
||||
});
|
||||
}
|
||||
@ -1464,9 +1464,9 @@ void SystemDictionaryShared::ArchiveInfo::print_on(const char* prefix,
|
||||
st->print_cr("%sShared Dictionary", prefix);
|
||||
SharedDictionaryPrinter p(st);
|
||||
st->print_cr("%sShared Builtin Dictionary", prefix);
|
||||
_builtin_dictionary.iterate(&p);
|
||||
_builtin_dictionary.iterate_all(&p);
|
||||
st->print_cr("%sShared Unregistered Dictionary", prefix);
|
||||
_unregistered_dictionary.iterate(&p);
|
||||
_unregistered_dictionary.iterate_all(&p);
|
||||
LambdaProxyClassDictionary::print_on(prefix, st, p.index(), is_static_archive);
|
||||
}
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ static void verify_archived_entry(TrainingData* td, const TrainingData::Key* k)
|
||||
|
||||
void TrainingData::verify() {
|
||||
if (TrainingData::have_data() && !TrainingData::assembling_data()) {
|
||||
archived_training_data_dictionary()->iterate([&](TrainingData* td) {
|
||||
archived_training_data_dictionary()->iterate_all([&](TrainingData* td) {
|
||||
if (td->is_KlassTrainingData()) {
|
||||
KlassTrainingData* ktd = td->as_KlassTrainingData();
|
||||
if (ktd->has_holder() && ktd->holder()->is_loaded()) {
|
||||
@ -466,7 +466,7 @@ void TrainingData::init_dumptime_table(TRAPS) {
|
||||
precond((!assembling_data() && !need_data()) || need_data() != assembling_data());
|
||||
if (assembling_data()) {
|
||||
_dumptime_training_data_dictionary = new DumptimeTrainingDataDictionary();
|
||||
_archived_training_data_dictionary.iterate([&](TrainingData* record) {
|
||||
_archived_training_data_dictionary.iterate_all([&](TrainingData* record) {
|
||||
_dumptime_training_data_dictionary->append(record);
|
||||
});
|
||||
}
|
||||
@ -692,7 +692,7 @@ void TrainingData::print_archived_training_data_on(outputStream* st) {
|
||||
st->print_cr("Archived TrainingData Dictionary");
|
||||
TrainingDataPrinter tdp(st);
|
||||
TrainingDataLocker::initialize();
|
||||
_archived_training_data_dictionary.iterate(&tdp);
|
||||
_archived_training_data_dictionary.iterate_all(&tdp);
|
||||
}
|
||||
|
||||
void TrainingData::Key::metaspace_pointers_do(MetaspaceClosure *iter) {
|
||||
|
||||
@ -3036,7 +3036,7 @@ void AdapterHandlerLibrary::link_aot_adapters() {
|
||||
* result in collision of adapter ids between AOT stored handlers and runtime generated handlers.
|
||||
* To avoid such situation, initialize the _id_counter with the largest adapter id among the AOT stored handlers.
|
||||
*/
|
||||
_aot_adapter_handler_table.iterate([&](AdapterHandlerEntry* entry) {
|
||||
_aot_adapter_handler_table.iterate_all([&](AdapterHandlerEntry* entry) {
|
||||
assert(!entry->is_linked(), "AdapterHandlerEntry is already linked!");
|
||||
entry->link();
|
||||
max_id = MAX2(max_id, entry->id());
|
||||
@ -3388,26 +3388,6 @@ JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) )
|
||||
FREE_C_HEAP_ARRAY(intptr_t, buf);
|
||||
JRT_END
|
||||
|
||||
bool AdapterHandlerLibrary::contains(const CodeBlob* b) {
|
||||
bool found = false;
|
||||
#if INCLUDE_CDS
|
||||
if (AOTCodeCache::is_using_adapter()) {
|
||||
auto findblob_archived_table = [&] (AdapterHandlerEntry* handler) {
|
||||
return (found = (b == CodeCache::find_blob(handler->get_i2c_entry())));
|
||||
};
|
||||
_aot_adapter_handler_table.iterate(findblob_archived_table);
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
if (!found) {
|
||||
auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* a) {
|
||||
return (found = (b == CodeCache::find_blob(a->get_i2c_entry())));
|
||||
};
|
||||
assert_locked_or_safepoint(AdapterHandlerLibrary_lock);
|
||||
_adapter_handler_table->iterate(findblob_runtime_table);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
const char* AdapterHandlerLibrary::name(AdapterHandlerEntry* handler) {
|
||||
return handler->fingerprint()->as_basic_args_string();
|
||||
}
|
||||
@ -3416,6 +3396,36 @@ uint32_t AdapterHandlerLibrary::id(AdapterHandlerEntry* handler) {
|
||||
return handler->id();
|
||||
}
|
||||
|
||||
bool AdapterHandlerLibrary::contains(const CodeBlob* b) {
|
||||
bool found = false;
|
||||
#if INCLUDE_CDS
|
||||
if (AOTCodeCache::is_using_adapter()) {
|
||||
auto findblob_archived_table = [&] (AdapterHandlerEntry* handler) {
|
||||
if (b == CodeCache::find_blob(handler->get_i2c_entry())) {
|
||||
found = true;
|
||||
return false; // abort iteration
|
||||
} else {
|
||||
return true; // keep looking
|
||||
}
|
||||
};
|
||||
_aot_adapter_handler_table.iterate(findblob_archived_table);
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
if (!found) {
|
||||
auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* handler) {
|
||||
if (b == CodeCache::find_blob(handler->get_i2c_entry())) {
|
||||
found = true;
|
||||
return false; // abort iteration
|
||||
} else {
|
||||
return true; // keep looking
|
||||
}
|
||||
};
|
||||
assert_locked_or_safepoint(AdapterHandlerLibrary_lock);
|
||||
_adapter_handler_table->iterate(findblob_runtime_table);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void AdapterHandlerLibrary::print_handler_on(outputStream* st, const CodeBlob* b) {
|
||||
bool found = false;
|
||||
#if INCLUDE_CDS
|
||||
@ -3425,23 +3435,23 @@ void AdapterHandlerLibrary::print_handler_on(outputStream* st, const CodeBlob* b
|
||||
found = true;
|
||||
st->print("Adapter for signature: ");
|
||||
handler->print_adapter_on(st);
|
||||
return true;
|
||||
return false; // abort iteration
|
||||
} else {
|
||||
return false; // keep looking
|
||||
return true; // keep looking
|
||||
}
|
||||
};
|
||||
_aot_adapter_handler_table.iterate(findblob_archived_table);
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
if (!found) {
|
||||
auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* a) {
|
||||
if (b == CodeCache::find_blob(a->get_i2c_entry())) {
|
||||
auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* handler) {
|
||||
if (b == CodeCache::find_blob(handler->get_i2c_entry())) {
|
||||
found = true;
|
||||
st->print("Adapter for signature: ");
|
||||
a->print_adapter_on(st);
|
||||
return true;
|
||||
handler->print_adapter_on(st);
|
||||
return false; // abort iteration
|
||||
} else {
|
||||
return false; // keep looking
|
||||
return true; // keep looking
|
||||
}
|
||||
};
|
||||
assert_locked_or_safepoint(AdapterHandlerLibrary_lock);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user