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

Proactive initialization of @AOTSafeClassInitializer classes

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • hotspot

      Background:

      The AOT Assembly Phase is in essence a small Java program that executes a limited set of Java bytecodes. This program bootstraps the module system, loads classes, and performs certain ahead-of-time optimizations such as resolving invokedynamic call sites.

      As a side effect of Java program execution, a small set of Java classes are initialized in the Assembly Phase.

      Since JDK-8360163, if a class X is annotated with @AOTSafeClassInitializer *and* is initialized in the Assembly Phase, then X will be stored in the AOT cache in the "initialized" state. In the Production Run, X.<clinit> will not be executed, and the static variables of X will be available upon JVM bootstrap.

      Problem:
      The Assembly Phase doesn't touch many classes that may benefit from @AOTSafeClassInitializer. For example, jdk.internal.math.MathUtils::<clinit> creates a few large tables. Caching MathUtils in the "initialized" state will improve start-up time. However, since no bytecodes executed by the Assembly Phase use MathUtils. it will not be initialized.

      Proposal:
      If a class X has the @AOTSafeClassInitializer annotation *and* was initialized in the AOT Training Run, the JVM should proactively initialize X in the Assembly Phase. This will ensure that X will be cached in the "initialized" state.

      This RFE will implement the proposal. It will also add @AOTSafeClassInitializer to MathUtils as a proof of concept.

      @AOTSafeClassInitializer will be added to more classes in future RFEs.

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: