The static `nmethod::check_all_dependencies` has the following code:
```
// Turn off dependency tracing while actually testing dependencies.
NOT_PRODUCT( FlagSetting fs(Dependencies::_verify_in_progress, true));
```
which is critical for it. In a release build, the code will not be available and there will be significant performance impact. See https://bugs.openjdk.org/browse/JDK-7194669 for details.
There is only one use of the function in `CodeCache::mark_for_deoptimization`:
```
#ifndef PRODUCT
if (VerifyDependencies) {
// Object pointers are used as unique identifiers for dependency arguments. This
// is only possible if no safepoint, i.e., GC occurs during the verification code.
dependentCheckTime.start();
nmethod::check_all_dependencies(changes);
dependentCheckTime.stop();
}
#endif
As `VerifyDependencies` is a develop option, there are no uses of `check_all_dependencies` in a release build.
`check_all_dependencies` does not use any private/protected members of nmethod.
As there are no other uses of `check_all_dependencies` but in codeCache.cpp, we propose to move the function in codeCache.cpp and make it a static function. Also the new function must be guarded by `#ifndef PRODUCT` because it is not intended for release builds.