(original) (raw)

hi, everyone!

I have some question about the jdk 1.7 compiler.

According to the source code of "hotspot\\src\\share\\vm\\interpreter\\invocationCounter.cpp", the "InterpreterBackwardBranchLimit" is calculated by the following rules:

if (ProfileInterpreter) {
InterpreterBackwardBranchLimit = (CompileThreshold \* (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
} else {
InterpreterBackwardBranchLimit = ((CompileThreshold \* OnStackReplacePercentage) / 100) << number\_of\_noncount\_bits;
}

So if I run a piece of code on a server edition jvm, the InterpreterBackwardBranchLimit should be 10700 (CompileThreshold is 10000, OnStackReplacePercentage is 140, and InterpreterProfilePercentage is 33). But when I added -XX:+PrintCompilation, a loop with 10700 times would not print anything. When the loop growed up to 14564 times, the compiler began to work.

Could anybody give me some advice?

I use jdk1.7.0\_67, and the test code as following:

public class OSRDemo {
public static void main(String\[\] args) {
int result = 1;
for (int i = 1; i < 10700; i++) {//14564
result+=i;
}

System.out.println(result);
}
}

Thank you very much!


Thomas