Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8067286

Add a spec/doc on existing C1/C2 optimizations

XMLWordPrintable

    • Icon: JEP Task JEP Task
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • hotspot
    • None

      C2

      Inlining

      • Predicate: allow_inline parameter to Compile::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 and Compile::_inlining_incrementally which is set during compilation

      If the inlining budgets are exhausted methods are queue to be inlined later if possible, like here:

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b3d08045220f/src/share/vm/opto/bytecodeInfo.cpp#l328


      Escape Analysis

      • Predicate: do_escape_analysis parameter to Compile::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 to Compile::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:

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b3d08045220f/src/share/vm/opto/loopTransform.cpp#l2333

      Checks number of unrolls and predicted size of loop after unroll and other restrictions.

      • Transformation: PhaseIdealLoop::do_unroll()

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b3d08045220f/src/share/vm/opto/loopTransform.cpp#l1195

      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)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_GraphBuilder.cpp#l3300

      • 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)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_Canonicalizer.hpp#l53

      • Applied during parsing
      • IR instruction specific simplification

      Local Value Numbering

      • predicate: UseLocalValueNumbering (develop)
      • trace: PrintValueNumbering (develop)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_GraphBuilder.cpp#l2215

      • 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)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_Optimizer.cpp#l1152

      • 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)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_RangeCheckElimination.cpp#l46

      • 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)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/share/vm/c1/c1_LinearScan.cpp#l3016

      • operates on the LIR as independent pass
      • linear scan register allocation

      Peephole

      • predicate: sparc only, LIRFillDelaySlots
      • trace: LIRTracePeephole (develop)

      http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/a184ee1d7172/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp#l3515

      • description

      • operates on the LIR during code emission

      • attempts to fill delay slot of sparc branch/call instructions with a useful instruction

            Unassigned Unassigned
            iignatyev Igor Ignatyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: