On Tue, 22 Sep 2026 00:41:53 GMT, Vladimir Kozlov <[email protected]> wrote:

>> Improve startup and warmup time by making optimized native code for an 
>> application instantly available when the HotSpot Java Virtual Machine 
>> starts. Achieve this by compiling application code to native code in a 
>> training run, storing the native code in the [AOT 
>> cache](https://openjdk.org/jeps/483#Description) for use in subsequent 
>> production runs.
>> 
>> More details in the [JEP](https://openjdk.org/jeps/544).
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Vladimir Kozlov has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Add guarantee to initialize_runtime_shared_and_meta_spaces

Thank you for incorporating my suggestions. I have some more minor suggestions, 
but c1, compiler, opto, runtime, and test look good to me regardless.

src/hotspot/share/ci/ciEnv.cpp line 1907:

> 1905: #if INCLUDE_CDS
> 1906: 
> 1907: bool ciEnv::is_aot_compile() {

This could become `const` if you make `CompileTask::is_aot_compile` `const` as 
well, which only calls a static function.

src/hotspot/share/compiler/abstractCompiler.hpp line 167:

> 165: 
> 166:   void set_num_aot_compiler_threads(int num) { _num_aot_compiler_threads 
> = num;  }
> 167:   int num_aot_compiler_threads()             { return 
> _num_aot_compiler_threads; }

Suggestion:

void set_num_compiler_threads(int num) { _num_compiler_threads = num;  }
int num_compiler_threads() const       { return _num_compiler_threads; }

  void set_num_aot_compiler_threads(int num) { _num_aot_compiler_threads = num; 
 }
  int num_aot_compiler_threads() const       { return 
_num_aot_compiler_threads; }

src/hotspot/share/compiler/compileTask.hpp line 146:

> 144:   bool         is_aot_load() const               { return 
> _aot_code_entry != nullptr; }
> 145:   bool         is_aot_preload() const            { return 
> (_compile_reason == Reason_AOTPreload); }
> 146:   AOTCodeEntry* aot_code_entry()                 { return 
> _aot_code_entry; }

Suggestion:

  AOTCodeEntry* aot_code_entry() const           { return _aot_code_entry; }

test/hotspot/jtreg/runtime/cds/appcds/aotCode/TestAOTCodeCounters.java line 58:

> 56:         {"-XX:AOTCodeInvokeBase=10000.0", "-XX:AOTCodeInvokeScale=0.001"},
> 57:         {"-XX:AOTCodeInvokeBase=10000.0", "-XX:AOTCodeInvokeScale=1000.0"}
> 58:     };

A run with random values would be nice. Something like

Suggestion:

import java.util.Random;

import jdk.test.lib.cds.CDSAppTester;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;

public class TestAOTCodeCounters {
    private static final Random RANDOM = Utils.getRandomInstance();
    
    // Too long to test both, default and opposite, values.
    // Only test opposite.
    static double randomBase = RANDOM.nextDouble(1.0, 10000.0);
    static double randomScale = RANDOM.nextDouble(0.001, 1000.0);
    static String[][] flags = {
        {"-XX:AOTCodeInvokeBase=1.0",     "-XX:AOTCodeInvokeScale=0.001"},
        {"-XX:AOTCodeInvokeBase=1.0",     "-XX:AOTCodeInvokeScale=1000.0"},
        {"-XX:AOTCodeInvokeBase=10000.0", "-XX:AOTCodeInvokeScale=0.001"},
        {"-XX:AOTCodeInvokeBase=10000.0", "-XX:AOTCodeInvokeScale=1000.0"},
        {"-XX:AOTCodeInvokeBase=" + randomBase.toString(), 
"-XX:AOTCodeInvokeScale=" + randomScale.toString()}
    };

Also, isn't this already testing default and opposite values?

-------------

Marked as reviewed by mhaessig (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/30778#pullrequestreview-5275697737
PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r4069726881
PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r4069838591
PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r4072196929
PR Review Comment: https://git.openjdk.org/jdk/pull/30778#discussion_r4072072652

Reply via email to