Reputation: 831
I understand that a JVM interprets / JITs the bytecodes; and that JVM provides the platform specific machine code generation functionality (and runtime) for running the program, in the current context.
I would like to understand what platform specific code generation tuning options are available in JVM. I ran into https://docs.oracle.com/cd/E21764_01/web.1111/e13814/jvm_tuning.htm#PERFM167, which are actually only flags to tune the JVM runtime.
I am interested in knowing if JVM allows for tuning options for code generation for a specific platform, much like gcc on x86 https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#x86-Options.
Upvotes: 0
Views: 914
Reputation: 718708
First of all, JVM flags are fundamentally different to GCC's optimization flags. The GCC flags affect the code generated at compile time. The JVM options (to the extent that they affect JIT compilation at all) do NOT affect the bytecode.
There are various flags that affect the native code emitted by the JIT compiler; for example:
-ea
options determine whether assertions are checked.-server
option (in part) controls when the code is JIT compiler which affects its optimization. The -Xcomp
option does the same.-Xint
and -Xmixed
affect whether code is JIT compiled at all.Then there are options that specifically change specific optimization-related things. These include -XX:ObjectAlignmentInBytes
, -XX:CompressedOops
, -XX:AggressiveOpts
, the -XX:AllocatePrefetch
options, -XX:DoEscapeAnalysis
, the -XX:Inline
options, -XX:OptimizeStringConcat
, the -XX:UseAES
options and the -XX:UseSHA
options.
For a more complete listing, refer to the Oracle documentation for your platform.
Note that:
-X
and -XX
options may change between Java versions.Java programmers typically let the platform select the optimization settings. Java programs are less likely to break due to choice of the optimization settings than (say) C and C++ programs 1.
1 - For a single-threaded Java code, optimization settings should not alter the behavior of a program. For a multi-threaded code, the behavior of an incorrect application could change due to inadequate synchronization. While this might be sensitive to optimizer settings, it could also be influenced by hardware characteristics, Java version and so on.
Upvotes: 3