Skip to content

Commit

Permalink
Check only in debug vm
Browse files Browse the repository at this point in the history
  • Loading branch information
reinrich committed Mar 29, 2023
1 parent bde34b9 commit 7dd0644
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/hotspot/share/runtime/sharedRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,7 @@ bool SharedRuntime::resolve_sub_helper_internal(methodHandle callee_method, cons
return true;
}

#ifdef ASSERT
class Search2OopsClosure : public OopClosure {
bool _found;
const oop _o1;
Expand Down Expand Up @@ -1407,7 +1408,7 @@ class Search2OopsClosure : public OopClosure {
// Check if the holder of the target method is reachable from the caller nmethod if
// the call is statically bound.
// Without that path the target method could get unloaded even if the caller
// nmethod is not unloading and a dangling Method* could be left int the static
// nmethod is not unloading and a dangling Method* could be left in the static
// stub for the call.
static void check_path_to_callee(bool is_virtual,
bool is_optimized,
Expand Down Expand Up @@ -1438,12 +1439,13 @@ static void check_path_to_callee(bool is_virtual,
if (!f.found()) {
stringStream ss;
to_method->print_short_name(&ss);
guarantee(false, "Missing dependency resolving %s%s (%s) call to %s",
(is_optimized) ? "optimized " : "", (is_virtual) ? "virtual" : "static",
Bytecodes::name(invoke_code), ss.freeze());
assert(false, "Missing dependency resolving %s%s (%s) call to %s",
(is_optimized) ? "optimized " : "", (is_virtual) ? "virtual" : "static",
Bytecodes::name(invoke_code), ss.freeze());
}
}
}
#endif /* ASSERT */

// Resolves a call. The compilers generate code for calls that go here
// and are patched with the real destination of the call.
Expand Down Expand Up @@ -1494,10 +1496,12 @@ methodHandle SharedRuntime::resolve_sub_helper(bool is_virtual, bool is_optimize
}
#endif

#ifdef ASSERT
if (!is_virtual || is_optimized) {
// The holder of the callee_method must be reachable from caller_nm
check_path_to_callee(is_virtual, is_optimized, caller_nm, receiver, callee_method, invoke_code, current /* thread */);
}
#endif /* ASSERT */

if (invoke_code == Bytecodes::_invokestatic) {
assert(callee_method->method_holder()->is_initialized() ||
Expand Down

0 comments on commit 7dd0644

Please sign in to comment.