The next test shows strange OSR compilation behavior. C2 does osr recompilations of the loop in test() method until PerBytecodeRecompilationCutoff (200) is reached: public class Test { private static final int ITERS = 10000000; public static void main(String args[]) { Test t = new Test(); for (int i=0; i<10; i++) { test(t, 7); } } static Test test(Test t, int m) { int i = -(ITERS/2); if (i == 0) return null; Test v = null; while(i < ITERS) { if ((i&m) == 0) { v = t; } i++; } return v; } } % java -server -Xbatch -XX:+PrintCompilation -XX:-TieredCompilation -XX:CICompilerCount=1 Test 414 1 % b Test::test @ 11 (33 bytes) 436 1 % Test::test @ -2 (33 bytes) made not entrant 436 2 % b Test::test @ 11 (33 bytes) 445 2 % Test::test @ -2 (33 bytes) made not entrant 445 3 % b Test::test @ 11 (33 bytes) 454 3 % Test::test @ -2 (33 bytes) made not entrant 454 4 % b Test::test @ 11 (33 bytes) 463 4 % Test::test @ -2 (33 bytes) made not entrant ... 2330 201 % Test::test @ -2 (33 bytes) made not entrant 2330 202 % b Test::test @ 11 (33 bytes) 3116 1 b Test::test (33 bytes) With Tiered compilation it is doubled since C1 version of compiled code is thrown out after C2 compilation is done so it needs to be compiled again by C1: % java -server -Xbatch -XX:+PrintCompilation -XX:+TieredCompilation -XX:CICompilerCount=1 Test 462 1 b 3 java.lang.Integer::rotateLeft (9 bytes) 781 2 b 3 java.lang.String::hash32 (45 bytes) 865 3 b 3 java.lang.String::charAt (29 bytes) 887 4 n 0 java.lang.System::arraycopy (native) (static) 898 5 b 3 java.lang.String::length (6 bytes) 899 6 b 3 java.lang.Object::<init> (1 bytes) 908 7 b 3 java.lang.String::indexOf (70 bytes) 920 8 b 1 java.lang.Integer::rotateLeft (9 bytes) 922 1 3 java.lang.Integer::rotateLeft (9 bytes) made not entrant 922 9 b 3 java.lang.Math::min (11 bytes) 929 10 b 3 java.lang.String::equals (81 bytes) 940 11 b 3 java.lang.AbstractStringBuilder::ensureCapacityInternal (16 bytes) 985 12 b 1 java.lang.Object::<init> (1 bytes) 986 6 3 java.lang.Object::<init> (1 bytes) made not entrant 991 1 % b 3 Test::test @ 11 (33 bytes) 995 13 b 3 Test::test (33 bytes) 997 2 % b 4 Test::test @ 11 (33 bytes) 1025 1 % 3 Test::test @ -2 (33 bytes) made not entrant 1027 2 % 4 Test::test @ -2 (33 bytes) made not entrant 1028 3 % b 3 Test::test @ 11 (33 bytes) 1030 4 % b 4 Test::test @ 11 (33 bytes) 1041 3 % 3 Test::test @ -2 (33 bytes) made not entrant 1042 4 % 4 Test::test @ -2 (33 bytes) made not entrant 1042 5 % b 3 Test::test @ 11 (33 bytes) 1044 6 % b 4 Test::test @ 11 (33 bytes) 1055 5 % 3 Test::test @ -2 (33 bytes) made not entrant 1056 6 % 4 Test::test @ -2 (33 bytes) made not entrant 1057 7 % b 3 Test::test @ 11 (33 bytes) 1059 8 % b 4 Test::test @ 11 (33 bytes) 1067 7 % 3 Test::test @ -2 (33 bytes) made not entrant 1068 8 % 4 Test::test @ -2 (33 bytes) made not entrant ... 2979 401 % b 3 Test::test @ 11 (33 bytes) 2981 402 % b 4 Test::test @ 11 (33 bytes) 2989 401 % 3 Test::test @ -2 (33 bytes) made not entrant 2989 402 % 4 Test::test @ -2 (33 bytes) made not entrant 2989 403 % b 3 Test::test @ 11 (33 bytes) 2991 404 % b 4 Test::test @ 11 (33 bytes) 2999 403 % 3 Test::test @ -2 (33 bytes) made not entrant 3272 14 b 4 Test::test (33 bytes) 3277 13 3 Test::test (33 bytes) made not entrant Note that standalone C1 is not affected: % java -client -Xbatch -XX:+PrintCompilation -XX:+TieredCompilation -XX:CICompilerCount=1 Test 1999 1 b java.lang.String::equals (81 bytes) 2412 2 b java.lang.Integer::rotateLeft (9 bytes) 2424 3 b java.lang.String::indexOf (70 bytes) 2455 4 b java.lang.String::lastIndexOf (52 bytes) 2464 5 b sun.misc.Hashing::murmur3_32 (188 bytes) 2472 6 b java.lang.String::charAt (29 bytes) 2480 7 b java.lang.String::hashCode (55 bytes) 2484 8 b java.io.UnixFileSystem::normalize (75 bytes) 2646 9 b java.lang.Object::<init> (1 bytes) 2711 1 % b Test::test @ 11 (33 bytes) 2751 10 b Test::test (33 bytes)
|