C2
Inlining
- Predicate:
allow_inline
parameter toCompile::call_generator()
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b3d08045220f/src/share/vm/opto/doCall.cpp#l65
Inlining is controlled by the product flag Inline
. There are many other inlining related flags which control inlining depth, size and other heuristics.
Incremental Inlining
- Predicate: global flag
IncrementalInline
andCompile::_inlining_incrementally
which is set during compilation
If the inlining budgets are exhausted methods are queue to be inlined later if possible, like here:
Escape Analysis
- Predicate:
do_escape_analysis
parameter toCompile::Compile()
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b3d08045220f/src/share/vm/opto/compile.cpp#l610
Compile::_do_escape_analysis
is required in many places in the compiler.
It depends on DoEscapeAnalysis
flag, JVMTI enabled events and recompilation. It is set in C2Compiler::compile_method()
.
Additional conditions are checked in ConnectionGraph::has_candidates()
- presence of allocations, locks, boxing methods (valueOf).
Autobox Elimination
- Predicate:
eliminate_boxing
parameter toCompile::Compile()
which is set by the global flag EliminateAutoBox
in C2Compiler::compile_method
:
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b3d08045220f/src/share/vm/opto/c2compiler.cpp#l103
Compile::_eliminate_boxing
is required from many places in the compiler. Compile::aggressive_unboxing()
is also controlled by the global flag AggressiveUnboxing
.
Loop unrolling
- Predicate:
IdealLoopTree::policy_unroll()
which is required here:
Checks number of unrolls and predicted size of loop after unroll and other restrictions.
- Transformation:
PhaseIdealLoop::do_unroll()
Does one unroll per PhaseIdealLoop
invocation. Unroll only main loop after a counted loop is split into pre-main-post.
C1
Inlining
- predicate: Inline (product)
- trace: PrintInlining (diagnostic)
- Happens during parsing
- Depth limited (MaxInlineLevel, MaxRecursiveInlineLevel), bytecode size limited (MaxInlineSize, MaxTrivialSize, NestedInliningSizeRatio) inlining of static calls, and monomorphic virtual/interface calls (either final method/class or discovered via class hierarchy analysis).
- Inlining of method handle intrinsics
- Inlining of intrinsics
Canonicalizer
- predicate: CanonicalizeNodes (develop)
- trace: PrintCanonicalization (develop)
- Applied during parsing
- IR instruction specific simplification
Local Value Numbering
- predicate: UseLocalValueNumbering (develop)
- trace: PrintValueNumbering (develop)
- Applied during parsing
- Remove redundant IR instructions using value numbering in current block
Conditional Expressions Eliminations
- predicate: DoCEE (develop), disabled when C1 does profiling of branches
- trace: PrintCEE (develop)
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_Optimizer.cpp#l305
- Independent pass
- Convert if/then/else control flow to single IR instruction of the form x {cond} y ? tval : fval to then take advantage of conditional moves
Basic Block Eliminations
- predicate: EliminateBlocks (develop), disabled when C1 does profiling of branches
- trace: PrintBlockElimination (develop)
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_Optimizer.cpp#l470
- Independent pass
- Merge block with single successor
Null Check Elimination
- predicate: EliminateNullChecks (develop)
- trace: PrintNullCheckElimination (develop)
- Independent pass
- Eliminate null checks that can be proved redundant by data flow analysis (iterate until fix point)
Global Value Numbering
- predicate: UseGlobalValueNumbering (develop)
- trace: PrintValueNumbering (develop)
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_ValueMap.cpp#l487
- Independent pass
- Remove redundant IR instructions using dominator based value numbering
Loop Invariant Code Motion
- predicate: UseLoopInvariantCodeMotion (product), disabled if tiered is on or a previous compilation of this method saw a deoptimization due to this optimization or bound check elimination
- trace: PrintValueNumbering (develop)
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_ValueMap.cpp#l330
- Independent pass
- Move some IR instructions out of loops if their operands are loop invariant. If the IR instruction traps, deoptimization is needed.
Bound Check Elimination
- predicate: RangeCheckElimination (product), more aggressive if tiered is off and a previous compilation of this method didn't see a deoptimization due to this optimization or loop invariant code motion
- trace: TraceRangeCheckElimination (develop)
- Independent pass
- Follow dominator tree and propagate knowledge about ranges of integer values, use it to remove useless array bound checks
- Attempts to reorder array bound checks in a block to minimize the number of checks
- Aggressive version of the optimization can cause deoptimization
Register Allocation
- predicate: none
- trace: TraceLinearScanLevel (develop)
- operates on the LIR as independent pass
- linear scan register allocation
Peephole
- predicate: sparc only, LIRFillDelaySlots
- trace: LIRTracePeephole (develop)
description
operates on the LIR during code emission
- attempts to fill delay slot of sparc branch/call instructions with a useful instruction
- blocks
-
JDK-8043473 JEP 234: Additional Run-Time Compiler JVM Trace Events
-
- Candidate
-