why doesn't trigger compile when loop 10700 times?
Vladimir Kozlov
vladimir.kozlov at oracle.com
Sun Jun 28 04:36:40 UTC 2015
Add -Xbatch (or -XX:-BackgroundCompilation) otherwise code continue
execution after requesting compilation and may finish before compilation
starts.
Also counters are not precise so you may not see exact 10700.
Regards,
Vladimir
On 6/27/15 9:15 PM, weatry at gmail.com wrote:
> 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
More information about the hotspot-compiler-dev
mailing list