--- old/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp 2017-10-24 20:29:26.000000000 -0700 +++ new/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp 2017-10-24 20:29:25.000000000 -0700 @@ -2579,8 +2579,9 @@ const bool callee_is_static = callee->is_loaded() && callee->is_static(); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes - if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && - !callee_is_static && // required for optimized MH invokes + if (((bc == Bytecodes::_invokevirtual && !callee->can_be_statically_bound()) || + bc == Bytecodes::_invokeinterface) && + !callee_is_static && // Required for optimized MH invokes. C1ProfileVirtualCalls) { assert(op->recv()->is_single_cpu(), "recv must be allocated"); Register recv = op->recv()->as_register(); --- old/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp 2017-10-24 20:29:26.000000000 -0700 +++ new/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp 2017-10-24 20:29:26.000000000 -0700 @@ -3172,8 +3172,9 @@ const bool callee_is_static = callee->is_loaded() && callee->is_static(); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes - if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && - !callee_is_static && // required for optimized MH invokes + if (((bc == Bytecodes::_invokevirtual && !callee->can_be_statically_bound()) || + bc == Bytecodes::_invokeinterface) && + !callee_is_static && // Required for optimized MH invokes. C1ProfileVirtualCalls) { assert(op->recv()->is_single_cpu(), "recv must be allocated"); --- old/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp 2017-10-24 20:29:27.000000000 -0700 +++ new/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp 2017-10-24 20:29:27.000000000 -0700 @@ -2778,7 +2778,8 @@ const bool callee_is_static = callee->is_loaded() && callee->is_static(); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes. - if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && + if (((bc == Bytecodes::_invokevirtual && !callee->can_be_statically_bound()) || + bc == Bytecodes::_invokeinterface) && !callee_is_static && // Required for optimized MH invokes. C1ProfileVirtualCalls) { assert(op->recv()->is_single_cpu(), "recv must be allocated"); --- old/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp 2017-10-24 20:29:28.000000000 -0700 +++ new/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp 2017-10-24 20:29:28.000000000 -0700 @@ -2717,7 +2717,8 @@ const bool callee_is_static = callee->is_loaded() && callee->is_static(); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes. - if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && + if (((bc == Bytecodes::_invokevirtual && !callee->can_be_statically_bound()) || + bc == Bytecodes::_invokeinterface) && !callee_is_static && // Required for optimized MH invokes. C1ProfileVirtualCalls) { assert(op->recv()->is_single_cpu(), "recv must be allocated"); --- old/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp 2017-10-24 20:29:29.000000000 -0700 +++ new/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp 2017-10-24 20:29:28.000000000 -0700 @@ -2767,8 +2767,9 @@ const bool callee_is_static = callee->is_loaded() && callee->is_static(); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes - if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && - !callee_is_static && // required for optimized MH invokes + if (((bc == Bytecodes::_invokevirtual && !callee->can_be_statically_bound()) || + bc == Bytecodes::_invokeinterface) && + !callee_is_static && // Required for optimized MH invokes. C1ProfileVirtualCalls) { assert(op->recv()->is_single_cpu(), "recv must be allocated"); Register recv = op->recv()->as_register(); --- old/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp 2017-10-24 20:29:30.000000000 -0700 +++ new/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp 2017-10-24 20:29:29.000000000 -0700 @@ -3486,8 +3486,9 @@ const bool callee_is_static = callee->is_loaded() && callee->is_static(); // Perform additional virtual call profiling for invokevirtual and // invokeinterface bytecodes - if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && - !callee_is_static && // required for optimized MH invokes + if (((bc == Bytecodes::_invokevirtual && !callee->can_be_statically_bound()) || + bc == Bytecodes::_invokeinterface) && + !callee_is_static && // Required for optimized MH invokes. C1ProfileVirtualCalls) { assert(op->recv()->is_single_cpu(), "recv must be allocated"); Register recv = op->recv()->as_register(); --- old/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java 2017-10-24 20:29:30.000000000 -0700 +++ new/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java 2017-10-24 20:29:30.000000000 -0700 @@ -578,6 +578,12 @@ } totalCount += getMethodsNotRecordedExecutionCount(data, position); + + // Fixup the case of C1's inability to optimize profiling of a statically bindable call site + if (entries == 1) { + counts[0] = totalCount; + } + return new RawItemProfile<>(entries, methods, counts, totalCount); }