Are Java 6's performance improvements in the JDK, JVM, or both?

后端 未结 4 1337
[愿得一人]
[愿得一人] 2021-01-20 04:18

I\'ve been wondering about the performance improvements touted in Java SE 6 - is it in the compiler or the runtime? Put another way, would a Java 5 application compiled by J

4条回答
  •  伪装坚强ぢ
    2021-01-20 05:01

    javac, which compiles from Java source to bytecodes, does almost no optimisation. Indeed optimisation would often make code actually run slower by being harder to analyse for later optimisation.

    The only significant difference between generated code for 1.5 and 1.6 is that with -target 1.6 extra information is added about the state of the stack to make verification easier and faster (Java ME does this as well). This only affects class loading speeds.

    The real optimising part is the hotspot compiler that compile bytecode to native code. This is even updated on some update releases. On Windows only the slower client C1 version of hotspot is distributed in the JRE by default. The server C2 hotspot runs faster (use -server on the java command line), but is slower to start up and uses more memory.

    Also the libraries and tools (including javac) sometimes have optimisation work done.

    I don't know why you are finding JDK 6 slower to compile code than JDK 5. Is there some subtle difference in set up?

提交回复
热议问题