Skip to content

Commit 64ee3c9

Browse files
author
Evgeny Astigeevich
committedOct 12, 2023
8317266: Move nmethod::check_all_dependencies to codeCache.cpp and mark it NOT_PRODUCT
Reviewed-by: kvn, dlong
1 parent 32ac72c commit 64ee3c9

File tree

3 files changed

+49
-50
lines changed

3 files changed

+49
-50
lines changed
 

‎src/hotspot/share/code/codeCache.cpp

+49-1
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,54 @@ void CodeCache::cleanup_inline_caches_whitebox() {
12511251
// Keeps track of time spent for checking dependencies
12521252
NOT_PRODUCT(static elapsedTimer dependentCheckTime;)
12531253

1254+
#ifndef PRODUCT
1255+
// Check if any of live methods dependencies have been invalidated.
1256+
// (this is expensive!)
1257+
static void check_live_nmethods_dependencies(DepChange& changes) {
1258+
// Checked dependencies are allocated into this ResourceMark
1259+
ResourceMark rm;
1260+
1261+
// Turn off dependency tracing while actually testing dependencies.
1262+
FlagSetting fs(Dependencies::_verify_in_progress, true);
1263+
1264+
typedef ResourceHashtable<DependencySignature, int, 11027,
1265+
AnyObj::RESOURCE_AREA, mtInternal,
1266+
&DependencySignature::hash,
1267+
&DependencySignature::equals> DepTable;
1268+
1269+
DepTable* table = new DepTable();
1270+
1271+
// Iterate over live nmethods and check dependencies of all nmethods that are not
1272+
// marked for deoptimization. A particular dependency is only checked once.
1273+
NMethodIterator iter(NMethodIterator::only_not_unloading);
1274+
while(iter.next()) {
1275+
nmethod* nm = iter.method();
1276+
// Only notify for live nmethods
1277+
if (!nm->is_marked_for_deoptimization()) {
1278+
for (Dependencies::DepStream deps(nm); deps.next(); ) {
1279+
// Construct abstraction of a dependency.
1280+
DependencySignature* current_sig = new DependencySignature(deps);
1281+
1282+
// Determine if dependency is already checked. table->put(...) returns
1283+
// 'true' if the dependency is added (i.e., was not in the hashtable).
1284+
if (table->put(*current_sig, 1)) {
1285+
if (deps.check_dependency() != nullptr) {
1286+
// Dependency checking failed. Print out information about the failed
1287+
// dependency and finally fail with an assert. We can fail here, since
1288+
// dependency checking is never done in a product build.
1289+
tty->print_cr("Failed dependency:");
1290+
changes.print();
1291+
nm->print();
1292+
nm->print_dependencies_on(tty);
1293+
assert(false, "Should have been marked for deoptimization");
1294+
}
1295+
}
1296+
}
1297+
}
1298+
}
1299+
}
1300+
#endif
1301+
12541302
void CodeCache::mark_for_deoptimization(DeoptimizationScope* deopt_scope, KlassDepChange& changes) {
12551303
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
12561304

@@ -1272,7 +1320,7 @@ void CodeCache::mark_for_deoptimization(DeoptimizationScope* deopt_scope, KlassD
12721320
// Object pointers are used as unique identifiers for dependency arguments. This
12731321
// is only possible if no safepoint, i.e., GC occurs during the verification code.
12741322
dependentCheckTime.start();
1275-
nmethod::check_all_dependencies(changes);
1323+
check_live_nmethods_dependencies(changes);
12761324
dependentCheckTime.stop();
12771325
}
12781326
#endif

‎src/hotspot/share/code/nmethod.cpp

-45
Original file line numberDiff line numberDiff line change
@@ -2148,51 +2148,6 @@ PcDesc* PcDescContainer::find_pc_desc_internal(address pc, bool approximate, con
21482148
}
21492149
}
21502150

2151-
2152-
void nmethod::check_all_dependencies(DepChange& changes) {
2153-
// Checked dependencies are allocated into this ResourceMark
2154-
ResourceMark rm;
2155-
2156-
// Turn off dependency tracing while actually testing dependencies.
2157-
NOT_PRODUCT( FlagSetting fs(Dependencies::_verify_in_progress, true));
2158-
2159-
typedef ResourceHashtable<DependencySignature, int, 11027,
2160-
AnyObj::RESOURCE_AREA, mtInternal,
2161-
&DependencySignature::hash,
2162-
&DependencySignature::equals> DepTable;
2163-
2164-
DepTable* table = new DepTable();
2165-
2166-
// Iterate over live nmethods and check dependencies of all nmethods that are not
2167-
// marked for deoptimization. A particular dependency is only checked once.
2168-
NMethodIterator iter(NMethodIterator::only_not_unloading);
2169-
while(iter.next()) {
2170-
nmethod* nm = iter.method();
2171-
// Only notify for live nmethods
2172-
if (!nm->is_marked_for_deoptimization()) {
2173-
for (Dependencies::DepStream deps(nm); deps.next(); ) {
2174-
// Construct abstraction of a dependency.
2175-
DependencySignature* current_sig = new DependencySignature(deps);
2176-
2177-
// Determine if dependency is already checked. table->put(...) returns
2178-
// 'true' if the dependency is added (i.e., was not in the hashtable).
2179-
if (table->put(*current_sig, 1)) {
2180-
if (deps.check_dependency() != nullptr) {
2181-
// Dependency checking failed. Print out information about the failed
2182-
// dependency and finally fail with an assert. We can fail here, since
2183-
// dependency checking is never done in a product build.
2184-
tty->print_cr("Failed dependency:");
2185-
changes.print();
2186-
nm->print();
2187-
nm->print_dependencies_on(tty);
2188-
assert(false, "Should have been marked for deoptimization");
2189-
}
2190-
}
2191-
}
2192-
}
2193-
}
2194-
}
2195-
21962151
bool nmethod::check_dependency_on(DepChange& changes) {
21972152
// What has happened:
21982153
// 1) a new class dependee has been added

‎src/hotspot/share/code/nmethod.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,6 @@ class nmethod : public CompiledMethod {
677677
virtual int compile_id() const { return _compile_id; }
678678
const char* compile_kind() const;
679679

680-
// tells if any of this method's dependencies have been invalidated
681-
// (this is expensive!)
682-
static void check_all_dependencies(DepChange& changes);
683-
684680
// tells if this compiled method is dependent on the given changes,
685681
// and the changes have invalidated it
686682
bool check_dependency_on(DepChange& changes);

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Oct 12, 2023

@openjdk-notifier[bot]
Please sign in to comment.