I was wondering if there is a method maximum size for JIT C2 to compile it. Let's assume there is a method which just maps one class to another, but this class contains a lot of fields. It became hot, C1 optimizes it but at some point C2 will kick in. If byte code is long enough, will C2 ignore that method and do not compile it? I couldn't find any answer for my question. Maybe there is not such a thing?
Asked
Active
Viewed 1,047 times
1 Answers
4
There are a number of JIT compiler limits.
One of them is HugeMethodLimit
equal to 8000 and not tunable in product JVM builds. The methods with more than 8000 bytes of bytecode will not be compiled, neither by C2 nor by C1. This limit can be turned off with -XX:-DontCompileHugeMethods
.
C2 can also cease compilation of smaller methods, if the total number of IR nodes (not bytes of bytecode) reaches 80000. This limit can be tuned with -XX:MaxNodeLimit
(C2-specific option).
There many other thresholds (see 1, 2) that affect inlining and certain JIT optimizations.
-
This is useful information, but could benefit from extra details. For example, how can method have more than 8000 bytecodes? I assume 1 method equals 1 bytecode. Or do you mean bytecode instructions? If so, is there some tool to determine how many bytecode instructions one method in a .class file has? – juhist Apr 12 '20 at 15:31
-
@juhist I mean, the length of the method code in bytes, as stored in .class file. This is not the same as the number of bytecode instructions, since one instruction may take several bytes. Use [`javap -c`](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javap.html) to find the method length in bytecodes. – apangin Apr 12 '20 at 16:30
-
I believe that discussing what the bytecode is, and how to count method size, is beyond the scope of this question. Please, open a new one if you need more details. – apangin Apr 12 '20 at 16:30