Search code examples
javajvmjava-11jitjava-16

Minor question about Segmented Code Cache (http://openjdk.java.net/jeps/197)


I see that this JEP (http://openjdk.java.net/jeps/197) introduced 3 types of code caches.

The most obvious one to me is -XX:NonNMethodCodeHeapSize. This is the one that deals with JVM internal data.

What I do not understand is what is the difference between NonProfiledCodeHeapSize and ProfiledCodeHeapSize. That document says that:

Tiered compilation also introduces a new compiled code type: instrumented compiled code (profiled code).

My understanding is that "instrumented" here means "with counters", so kind of logic to assume that this is really C1 compiled code? And the other one is C2?


Solution

  • In Tiered Compilation, profiled code means JIT-compiled methods that collect execution statistics (counters and type information), which can be used later for recompilation on a different tier.

    Non-profiled code is not only C2 code. It also includes compiled wrappers for native methods, as well as methods compiled by C1 without execution statistics (Tier 1), e.g. simple methods like getters/setters that will not benefit from recompilation.

    See codeBlob.hpp:

    // CodeBlob Types
    // Used in the CodeCache to assign CodeBlobs to different CodeHeaps
    struct CodeBlobType {
      enum {
        MethodNonProfiled   = 0,    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
        MethodProfiled      = 1,    // Execution level 2 and 3 (profiled) nmethods
        NonNMethod          = 2,    // Non-nmethods like Buffers, Adapters and Runtime Stubs
        All                 = 3,    // All types (No code cache segmentation)
        NumTypes            = 4     // Number of CodeBlobTypes
      };
    };