--- old/src/hotspot/share/opto/bytecodeInfo.cpp 2019-05-20 17:51:11.395076512 +0800 +++ new/src/hotspot/share/opto/bytecodeInfo.cpp 2019-05-20 17:51:11.187072470 +0800 @@ -325,7 +325,10 @@ if (!UseInterpreter) { return false; // -Xcomp } - if (profile.count() > 0) { + + // Get the snapshot of profile.count() + int profile_count = profile.count(); + if (profile_count > 0) { return false; // reachable according to profile } if (!callee_method->was_executed_more_than(0)) { @@ -334,10 +337,10 @@ if (caller_method->is_not_reached(caller_bci)) { return true; // call site not resolved } - if (profile.count() == -1) { - return false; // immature profile; optimistically treat as reached + if (profile_count <= -1) { + return false; // immature or typecheck profile; optimistically treat as reached } - assert(profile.count() == 0, "sanity"); + assert(profile_count == 0, "sanity"); // Profile info is scarce. // Try to guess: check if the call site belongs to a start block. @@ -347,6 +350,11 @@ if (is_start_block) { return false; // treat the call reached as part of start block } + + // Re-sample the profile.count() before giving up + if (profile.count() > 0) { + return false; + } return true; // give up and treat the call site as not reached }