--- old/src/share/vm/ci/ciEnv.cpp 2017-01-30 16:06:32.000000000 +0300 +++ new/src/share/vm/ci/ciEnv.cpp 2017-01-30 16:06:31.000000000 +0300 @@ -101,6 +101,7 @@ _debug_info = NULL; _dependencies = NULL; _failure_reason = NULL; + _inc_decompile_count_on_failure = true; _compilable = MethodCompilable; _break_at_compile = false; _compiler_data = NULL; @@ -161,6 +162,7 @@ _debug_info = NULL; _dependencies = NULL; _failure_reason = NULL; + _inc_decompile_count_on_failure = true; _compilable = MethodCompilable_never; _break_at_compile = false; _compiler_data = NULL; @@ -902,7 +904,12 @@ if (deps.is_klass_type()) continue; // skip klass dependencies Klass* witness = deps.check_dependency(); if (witness != NULL) { - record_failure("invalid non-klass dependency"); + if (deps.type() == Dependencies::call_site_target_value) { + _inc_decompile_count_on_failure = false; + record_failure("call site target change"); + } else { + record_failure("invalid non-klass dependency"); + } return; } } @@ -1017,7 +1024,7 @@ if (failing()) { // While not a true deoptimization, it is a preemptive decompile. MethodData* mdo = method()->method_data(); - if (mdo != NULL) { + if (mdo != NULL && _inc_decompile_count_on_failure) { mdo->inc_decompile_count(); } --- old/src/share/vm/ci/ciEnv.hpp 2017-01-30 16:06:32.000000000 +0300 +++ new/src/share/vm/ci/ciEnv.hpp 2017-01-30 16:06:32.000000000 +0300 @@ -55,6 +55,7 @@ DebugInformationRecorder* _debug_info; Dependencies* _dependencies; const char* _failure_reason; + bool _inc_decompile_count_on_failure; int _compilable; bool _break_at_compile; int _num_inlined_bytecodes; --- old/src/share/vm/code/codeCache.cpp 2017-01-30 16:06:32.000000000 +0300 +++ new/src/share/vm/code/codeCache.cpp 2017-01-30 16:06:32.000000000 +0300 @@ -1211,7 +1211,7 @@ CompiledMethodIterator iter; while(iter.next_alive()) { CompiledMethod* nm = iter.method(); - if (nm->is_marked_for_deoptimization()) { + if (nm->is_marked_for_deoptimization() && !nm->is_not_entrant()) { nm->make_not_entrant(); } } --- old/src/share/vm/code/nmethod.cpp 2017-01-30 16:06:33.000000000 +0300 +++ new/src/share/vm/code/nmethod.cpp 2017-01-30 16:06:32.000000000 +0300 @@ -1146,6 +1146,14 @@ assert(state == zombie || state == not_entrant, "must be zombie or not_entrant"); assert(!is_zombie(), "should not already be a zombie"); + if (_state == state) { + // Avoid taking the lock if already in required state. + // This is safe from races because the state is an end-state, + // which the nmethod cannot back out of once entered. + // No need for fencing either. + return false; + } + // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. nmethodLocker nml(this); methodHandle the_method(method());