Mercurial > hg > truffle
diff src/share/vm/code/codeCache.cpp @ 14262:3aaa4b9966f6
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
Summary: Avoid verifying dependencies multiple times by caching verified dependencies
Reviewed-by: kvn, twisti, roland
author | anoll |
---|---|
date | Wed, 15 Jan 2014 06:16:55 +0100 |
parents | 510fbd28919c |
children | 524b54a7f1b5 |
line wrap: on
line diff
--- a/src/share/vm/code/codeCache.cpp Tue Jan 14 14:51:47 2014 +0100 +++ b/src/share/vm/code/codeCache.cpp Wed Jan 15 06:16:55 2014 +0100 @@ -596,20 +596,13 @@ } #ifndef PRODUCT -// used to keep track of how much time is spent in mark_for_deoptimization +// Keeps track of time spent for checking dependencies static elapsedTimer dependentCheckTime; -static int dependentCheckCount = 0; -#endif // PRODUCT +#endif int CodeCache::mark_for_deoptimization(DepChange& changes) { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - -#ifndef PRODUCT - dependentCheckTime.start(); - dependentCheckCount++; -#endif // PRODUCT - int number_of_marked_CodeBlobs = 0; // search the hierarchy looking for nmethods which are affected by the loading of this class @@ -617,32 +610,23 @@ // then search the interfaces this class implements looking for nmethods // which might be dependent of the fact that an interface only had one // implementor. - - { No_Safepoint_Verifier nsv; - for (DepChange::ContextStream str(changes, nsv); str.next(); ) { - Klass* d = str.klass(); - number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes); - } - } - - if (VerifyDependencies) { - // Turn off dependency tracing while actually testing deps. - NOT_PRODUCT( FlagSetting fs(TraceDependencies, false) ); - FOR_ALL_ALIVE_NMETHODS(nm) { - if (!nm->is_marked_for_deoptimization() && - nm->check_all_dependencies()) { - ResourceMark rm; - tty->print_cr("Should have been marked for deoptimization:"); - changes.print(); - nm->print(); - nm->print_dependencies(); - } - } + // nmethod::check_all_dependencies works only correctly, if no safepoint + // can happen + No_Safepoint_Verifier nsv; + for (DepChange::ContextStream str(changes, nsv); str.next(); ) { + Klass* d = str.klass(); + number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes); } #ifndef PRODUCT - dependentCheckTime.stop(); -#endif // 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 return number_of_marked_CodeBlobs; } @@ -899,9 +883,7 @@ } tty->print_cr("CodeCache:"); - - tty->print_cr("nmethod dependency checking time %f", dependentCheckTime.seconds(), - dependentCheckTime.seconds() / dependentCheckCount); + tty->print_cr("nmethod dependency checking time %fs", dependentCheckTime.seconds()); if (!live.is_empty()) { live.print("live");