--- old/src/share/vm/code/codeCache.cpp 2014-01-09 15:21:03.584523319 +0100 +++ new/src/share/vm/code/codeCache.cpp 2014-01-09 15:21:03.468523321 +0100 @@ -628,18 +628,41 @@ if (VerifyDependencies) { // Turn off dependency tracing while actually testing deps. NOT_PRODUCT( FlagSetting fs(TraceDependencies, false) ); + + ResourceMark rm; + // 'signature_buffers' is used to cache already checked dependencies. + GrowableArray* dep_signature_buffers = new GrowableArray(); + + // Iterate over live nmethods and check dependencies of all nmethods that are not + // marked for deoptimization. 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(); + if (!nm->is_marked_for_deoptimization()) { + for (Dependencies::DepStream deps(nm); deps.next(); ) { + // Get dependency signature buffer for a specific dependency type signature + DependencySignatureBuffer* buffer = DependencySignatureBuffer::buffer(dep_signature_buffers, deps.type()); + // A DependencySignature object abstracts a dependency. + DependencySignature current_sig(&deps); + + // Check if the current dependency is already checked + if (!buffer->contains(¤t_sig)) { + // If the dependency has not already been checked, perform the check and add the + // current dependency signature to the checked dependency signatures. + + // Check dependency and print out an error if the dependency check fails. + if (deps.check_dependency() != NULL) { + ResourceMark rm; + tty->print_cr("Should have been marked for deoptimization:"); + changes.print(); + nm->print(); + nm->print_dependencies(); + } + // Add dependency signature to checked dependencies + buffer->add(¤t_sig); + } + } } } } - #ifndef PRODUCT dependentCheckTime.stop(); #endif // PRODUCT