← Back to Pull requests

8388410: [Leyden] Improve map file logging to add Embedded Stubs from StubGenBlobs #118

Closed
Delawen closed this pull request without merging on Jul 27, 2026 12:20 UTC
View on GitHub
Delawen Delawen commented on Jul 16, 2026 18:29 UTC
Author

Continuation of https://github.com/openjdk/leyden/pull/115

Right now, we log StubGenBlobs in premain2: https://github.com/openjdk/leyden/pull/115

Current output example:

0x00007f1b37ffefe4: @@ StubGenBlob 24452 73 initial_blob (stub gen)

But we are skipping logging of the embedded stubs inside those blobs. This PR improves the logging to add the embedded stubs too.

The log line for EmbeddedStub contains the following data:
- Pointer
- Size of the Embedded Stub
- Id of the StubGenBlob (BlobId) to link back to which StubGenBlob it belongs (although it should be ordered)
- Id of the Embedded Stub
- Name of the Embedded stub

Example of output:

0x00007fd2fbffefe4: @@ StubGenBlob       24452 73 initial_blob (stub gen)
0x00007fd2dbfff05b: @@ EmbeddedStub      276 73 77 call_stub_stub (stub gen)
0x00007fd2dbfff010: @@ EmbeddedStub      75 73 78 forward_exception_stub (stub gen)
0x00007fd2dbfff16f: @@ EmbeddedStub      31 73 79 catch_exception_stub (stub gen)
0x00007fd2dbfff350: @@ EmbeddedStub      612 73 80 updateBytesCRC32_stub (stub gen)
0x00007fd2dbfff5d0: @@ EmbeddedStub      612 73 81 updateBytesCRC32C_stub (stub gen)
0x00007fd2dbfff83e: @@ EmbeddedStub      14 73 82 f2hf_stub (stub gen)
0x00007fd2dbfff834: @@ EmbeddedStub      10 73 83 hf2f_stub (stub gen)
0x00007fd2dc00196f: @@ EmbeddedStub      909 73 84 dexp_stub (stub gen)
0x00007fd2dc002ed7: @@ EmbeddedStub      660 73 85 dlog_stub (stub gen)
0x00007fd2dc00316b: @@ EmbeddedStub      744 73 86 dlog10_stub (stub gen)
0x00007fd2dc001cfc: @@ EmbeddedStub      4571 73 87 dpow_stub (stub gen)
0x00007fd2dbfff84c: @@ EmbeddedStub      1861 73 88 dsin_stub (stub gen)
0x00007fd2dbffff91: @@ EmbeddedStub      1793 73 89 dcos_stub (stub gen)
0x00007fd2dc000692: @@ EmbeddedStub      2312 73 90 dtan_stub (stub gen)
0x00007fd2dc000f9a: @@ EmbeddedStub      1029 73 91 dsinh_stub (stub gen)
0x00007fd2dc00139f: @@ EmbeddedStub      859 73 92 dtanh_stub (stub gen)
0x00007fd2dc0016fa: @@ EmbeddedStub      629 73 93 dcbrt_stub (stub gen)
0x00007fd2dc003470: @@ EmbeddedStub      489 73 94 fmod_stub (stub gen)
0x00007fd2dbfff18e: @@ EmbeddedStub      1 73 95 verify_mxcsr_stub (stub gen)
0x00007fd2dbfff18f: @@ EmbeddedStub      56 73 96 f2i_fixup_stub (stub gen)
0x00007fd2dbfff1c7: @@ EmbeddedStub      67 73 97 f2l_fixup_stub (stub gen)
0x00007fd2dbfff20a: @@ EmbeddedStub      80 73 98 d2i_fixup_stub (stub gen)
0x00007fd2dbfff25a: @@ EmbeddedStub      90 73 99 d2l_fixup_stub (stub gen)
0x00007fd2dbfff2d0: @@ EmbeddedStub      16 73 100 float_sign_mask_stub (stub gen)
0x00007fd2dbfff2f0: @@ EmbeddedStub      16 73 101 float_sign_flip_stub (stub gen)
0x00007fd2dbfff310: @@ EmbeddedStub      16 73 102 double_sign_mask_stub (stub gen)
0x00007fd2dbfff330: @@ EmbeddedStub      16 73 103 double_sign_flip_stub (stub gen)

---------

  • I confirm that I make this contribution in accordance with the OpenJDK Interim AI Policy.
  • <!-- Anything below this marker will be automatically updated, please do not edit manually! -->
    ---------

    Progress


  • \[x\] Change must be properly reviewed (1 review required, with at least 1 Reviewer)

  • \[x\] Change must not contain extraneous whitespace

  • \[x\] Commit message must refer to an issue
  • Issue


    JDK-8388410: [Leyden] Improve map file logging to add Embedded Stubs from StubGenBlobs (Sub-task - P4)

    Reviewers


    Vladimir Kozlov (@vnkozlov - Reviewer)
    Andrew Dinn (@adinn - Reviewer)
    Ioi Lam (@iklam - Reviewer)

    Reviewing


    <details><summary>Using <code>git</code></summary>

    Checkout this PR locally: \
    $ git fetch https://git.openjdk.org/leyden.git pull/118/head:pull/118 \
    $ git checkout pull/118

    Update a local copy of the PR: \
    $ git checkout pull/118 \
    $ git pull https://git.openjdk.org/leyden.git pull/118/head

    </details>
    <details><summary>Using Skara CLI tools</summary>

    Checkout this PR locally: \
    $ git pr checkout 118

    View PR using the GUI difftool: \
    $ git pr show -t 118

    </details>
    <details><summary>Using diff file</summary>

    Download this PR as a diff file: \
    <a href="https://git.openjdk.org/leyden/pull/118.diff">https://git.openjdk.org/leyden/pull/118.diff</a>

    </details>
    <details><summary>Using Webrev</summary>

    Link to Webrev Comment
    </details>

    Diff: 112 lines (+103 / -9) across 4 files Reviewer: adinn Review duration: 15470m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.36) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 112 lines diff across 4 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.72 · 5 substantive comment(s)
    0.72
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    83%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.283
    Real PR Conversation Timeline
    49 items
    bridgekeeper[bot] bridgekeeper[bot] commented on Jul 16, 2026 18:30 UTC
    Bot

    <!-- Welcome message -->

    :wave: Welcome back mariasde! A progress list of the required criteria for merging this PR into premain2 will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

    openjdk[bot] openjdk[bot] commented on Jul 16, 2026 18:32 UTC
    Bot

    @Delawen This change now passes all automated pre-integration checks.

    ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

    After integration, the commit message for the final commit will be:

    8388410: [Leyden] Improve map file logging to add Embedded Stubs from StubGenBlobs
    
    Reviewed-by: kvn, adinn, iklam
    

    You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

    At the time when this comment was updated there had been 371 new commits pushed to the premain2 branch:

    c821bad0ebcea325aaf8ea4a76b17c14d2183566: 8388411: [leyden] Increase memory limit for C2 AOT compilations
    558735508c5efce0db1e932ebfee35db22517e2c: Merge
    405120e6356fd37a1f196060e931b472c8efde32: Merge master 07-16-2026
    ... and 368 more: https://git.openjdk.org/leyden/compare/5031301ed5443d85f06522c0a1989d980a23195c...premain2

    As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

    As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @adinn, @iklam) but any other Committer may sponsor as well.

    ➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).
    <!-- PullRequestBot merge is ready comment -->

    Delawen Delawen commented on Jul 16, 2026 18:35 UTC
    Author

    Windows test are failing but I am quite sure it is not my fault (??) It doesn't even finish the configuration.

    https://github.com/Delawen/leyden/actions/runs/29523768519/job/87707205844

    mlbridge[bot] mlbridge[bot] commented on Jul 16, 2026 19:12 UTC
    Bot

    <!-- mlbridge webrev comment -->
    <!-- mlbridge webrev header -->

    Webrevs


    <!-- mlbridge webrev list -->
    08: Full - Incremental (c396c4d5)
    07: Full - Incremental (cb613e34)
    06: Full - Incremental (5922557b)
    05: Full - Incremental (13276190)
    04: Full - Incremental (8766a796)
    03: Full - Incremental (faacf432)
    02: Full - Incremental (77a26f6a)
    01: Full - Incremental (222b1d8f)
    * 00: Full (4da696d4)

    ashu-mehra ashu-mehra commented on Jul 16, 2026 19:13 UTC
    Contributor

    Windows test are failing but I am quite sure it is not my fault (??) It doesn't even finish the configuration.

    If I remember correctly I have seen it failing in mainline as well. I don't think it is related to your changes.

    vnkozlov vnkozlov commented on code on Jul 16, 2026 19:26 UTC
    Code Review
    src/hotspot/share/code/aotCodeCache.hpp:1
    @@ -603,6 +603,7 @@ class AOTCodeCache : public CHeapObj<mtCode> {
       AOTCodeCache(bool is_dumping, bool is_using);
     
       const char* cache_buffer() const { return _load_buffer; }
    +  const char* store_buffer()      const { return _store_buffer; }

    Please align (too many spaces)

    vnkozlov vnkozlov commented on Jul 16, 2026 19:46 UTC
    Reviewer

    My concern is the way you find the offset of embedded stubs information is fragile.
    May be we should consider adding an other offset field to AOTCodeEntry so you can directly use it. Or may be union with _comp_level and _comp_id and have add separate AOTCodeEntry() constructor for stubs.

    Delawen Delawen commented on Jul 17, 2026 09:14 UTC
    Author

    May be we should consider adding an other offset field to AOTCodeEntry so you can directly use it. Or may be union with _comp_level and _comp_id and have add separate AOTCodeEntry() constructor for stubs.

    Do we need a separated AOTCodeEntry constructor for any other reason? If not, adding an extra offset field seems more clean to me.

    iklam iklam commented on Jul 17, 2026 15:24 UTC
    Contributor

    It's common for the existing logs to use the first number as the size. E.g.

    0x00000008000d3788: @@ TypeArrayU8       96
    0x00000008000d3788:   000000000000000b 000000080033a7e8 000000080033a730 000000080033a678   ..........3.....0.3.....x.3.....
    0x00000008000d37a8:   000000080033a608 000000080033a598 000000080033a528 000000080033a4b8   ..3.......3.....(.3.......3.....
    0x00000008000d37c8:   000000080033a448 000000080033a3d8 000000080033a368 000000080033a2f8   H.3.......3.....h.3.......3.....
    0x00000008000d37e8: @@ TypeArrayU8       24
    0x00000008000d37e8:   0000000000000002 00000008000dd000 00000008000dc800                    ........................
    

    However, the meaning of the other number is not easy to understand.

    0x00007fd2fbffefe4: @@ StubGenBlob       24452 73 initial_blob (stub gen)
    0x00007fd2dbfff05b: @@ EmbeddedStub      276 73 77 call_stub_stub (stub gen)
    

    I think it's better to do this

    0x00007fd2fbffefe4: @@ StubGenBlob       24452 id = 73 initial_blob (stub gen)
    0x00007fd2dbfff05b: @@ EmbeddedStub      276 id = 77 blob = 73 call_stub_stub (stub gen)
    

    (I swapped the order of id and blob so the id always appears first.

    Also, is (stub gen) always printed?

    adinn adinn approved these changes on Jul 17, 2026 15:25 UTC
    Approved Reviewer

    All looks good.

    vnkozlov vnkozlov commented on Jul 17, 2026 18:50 UTC
    Contributor

    Do we need a separated AOTCodeEntry constructor for any other reason? If not, adding an extra offset field seems more clean to me.

    I agree to new offset field.

    vnkozlov vnkozlov commented on Jul 17, 2026 18:51 UTC
    Contributor

    Yes, having (stab gen) in all names is strange. @adinn do we really need it?

    Delawen Delawen commented on Jul 20, 2026 09:00 UTC
    Author

    Yes, having (stab gen) in all names is strange. @adinn do we really need it?

    I just print what I get, if it is needed we can also scrap that before printing on the log (hope it won't break things further)

    adinn adinn commented on Jul 20, 2026 10:03 UTC
    Contributor

    Yes, having (stub gen) in all names is strange. @adinn do we really need it?

    Well, yes, we can avoid it but it is not as simple or as clean as it looks. Omitting the(stub gen) suffix has implications for other print contexts.

    The need for the suffix is an unfortunate legacy of the way names have been given to stubs/blobs. We have several places where the names used to declare blobs and their associated stubs overlap across different groups of blob/stub.

    So, for example, forward_exception is used declare a C1 blob

    #define C1_STUBS_DO(do_blob)                                           \
      do_blob(dtrace_object_alloc)                                         \
      ...                                                                  \
      do_blob(forward_exception)                                           \
      ...                                                                  \
    

    and also to declare an initial stubgen stub
    #define STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob,                     \
                                     do_stub,                               \
                                     do_entry, do_entry_init,               \
                                     do_entry_array,                        \
                                     do_arch_blob,                          \
                                     do_arch_entry, do_arch_entry_init,     \
                                     do_arch_entry_array)                   \
      do_blob(initial)                                                      \
      do_stub(initial, call_stub)                                           \
      do_entry(initial, call_stub, call_stub_entry, call_stub_entry)        \
      ...                                                                   \
      do_stub(initial, forward_exception)                                   \
      do_entry(initial, forward_exception, forward_exception_entry,         \
               forward_exception_entry)                                     \
      ...                                                                   \
    

    Another example is new_instance which is use in the declaration of both a C1 blob and its associated stub

    #define C1_STUBS_DO(do_blob)                                           \
      do_blob(dtrace_object_alloc)                                         \
      ...                                                                  \
      do_blob(new_instance)                                                \
      ...                                                                  \
    

    and a C2 blob and its associate stub
    #define C2_STUBS_DO(do_blob, do_stub)                                  \
      do_blob(uncommon_trap, UncommonTrapBlob)                             \
      ...                                                                  \
      do_stub(new_instance, 0, true, false)                                \
      ...                                                                  \
    

    Note that in the second example in both cases there is a C1 and C2 blob and an associated C1 and C2 stub which need to have a name generated for them both of them starting with the single declaration id new_instance

    In order to ensure we have unique stub names (or unique blob names) we have to append the declared stub (or blob) name to the stub category name e.g. for the first case we generate stub names "forward_exception (stub gen)" and"forward_exception (c1)" and for the second case we generate stub (and blob) names "new_instance (c1)" and "new_instance (c2)".

    Note that in the first case the clash only occurs in the stub names. The blob names are "initial (stub gen)" and "forward_exception (c1)". In the second case the clash occurs for both the blob name and the stub name (when we have a single stub blob we use the same name for the blob or stub).

    So, even though the (stub gen) suffix appears to be redundant in the map printout -- because we only need to print the stub names for stubgen blobs i.e. multi-stub blobs -- it is actually an important element of the stub name that distinguishes it from other occurrences where a different stub is being named.

    If we wanted to avoid having the suffix in the name then the way to achieve that would be to ensure that declaration names were unique across stub categories. We could, for example, just add a qualifying tag to the declaration name in the cases where names clash forward_exception_stubgen and forward_exception_c1 -- likewise, new_instance_c1 and new_instance_c2.

    However, this would imply a change to the generated stub enum tags, field and accessor names for these cases requiring client code also to be updated. Calls to SharedRuntime::forward_exception() would now need to be written as SharedRuntime::forward_exception_stubgen(). Meanwhile other calls like SharedRuntime::catch_exception() would continue to omit the _stubgen suffix. Likewise, the code that accesses the C2 stub would now need to access OptoRuntime::new_instance_c2_Java() while other calls like OptoRuntime::new-array_Java() would stay as they are.

    I don't think this is actually much nicer as a solution. The map printout is slightly simplified but the client calls are now non-uniform.

    adinn adinn commented on Jul 20, 2026 10:15 UTC
    Contributor

    @vnkozlov I agree the current code that accesses the stub details is rather fragile -- I was thinking about that last night and thought of two ways to deal with it.

    Firstly, we should probably move the code in print routine AOTMapLogger::log_embedded_stubs into class AOTCodeCache. That way if the layout gets changed then there is more chance that the print code will also get updated.

    Secondly, we could usefully add some asserts to the printing code to ensure the data values read are as expected.

    So, for example when we read the sizes for intermediate data to skip over the blob, the relocs and any oop map there should be asserts that the current position is within the bounds of the entry.

    Likewise when reading successive stub ids
    - the stubid should be checked to ensure that is lies between StubId::NO_STUBID and StubId::NUM_STUBIDS
    - it should be an id associated with the current blob id StubInfo::blob(stub_id) == blob_id
    - the entry+extras count for the stub read from the file should exceed the declared entry count count >= StubInfo::entry_count(blob_id)

    adinn adinn requested changes on Jul 20, 2026 10:22 UTC
    Changes Requested Reviewer

    Maria, could you add asserts to the print code as mentioned in my comment to @vnkozlov and also consider moving the print routine into class AOTCodeCache?

    Delawen Delawen commented on Jul 20, 2026 10:29 UTC
    Author

    Sure. I was already working on adding the offset as a field, I can do the rest too.

    adinn adinn commented on Jul 20, 2026 15:20 UTC
    Contributor

    @Delawen
    Just to confirm what we discussed online . . .

    The entry + extras count for the stub that is read from the file always omits the first entry. Every stub must have at least one entry, at offset 0, and may have 0 or more extra entries. So, if you read value count then that value is supposed to represent StubInfo::entry_count(blob_id) - 1 + extras. So the minimum value for count is StubInfo::entry_count(blob_id) - 1 and the asserted condition should be count >= StubInfo::entry_count(blob_id) - 1.

    vnkozlov vnkozlov approved these changes on Jul 20, 2026 16:57 UTC
    Approved Reviewer

    Looks good to me.

    vnkozlov vnkozlov commented on Jul 20, 2026 17:00 UTC
    Contributor

    @adinn

    I am okay with keeping (stub gen). thank you for explaining the situation with it.

    Firstly, we should probably move the code in print routine AOTMapLogger::log_embedded_stubs into class AOTCodeCache. That way if the layout gets changed then there is more chance that the print code will also get updated.

    Yes, I agree.

    Secondly, we could usefully add some asserts to the printing code to ensure the data values read are as expected.

    Yes, we can add asserts. At lest check stubs ID.

    iklam iklam commented on code on Jul 20, 2026 19:47 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -120,6 +120,46 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
       log_info(aot, map)("[End of AOT cache map]");
     }
     
    +void AOTMapLogger::log_embedded_stubs(const AOTCodeCache* cache, const AOTCodeEntry* entry) {
    +
    +  //start at the beginning of our AOT cache
    +  const char* buf = cache->store_buffer();
    +
    +  // jump to the embedded stubs section
    +  uint pos = entry->offset() + entry->embedded_stub_offset();
    +
    +  // Now we can get the information we want to log (embedded stubs)
    +  // get the first embedded stub id
    +  StubId stub_id = *(StubId*)(buf + pos);
    +  pos += sizeof(StubId);
    +
    +  // Embedded StubGenBlobs are assumed to have the following structure
    +  // [ StubId | offset | size | N | offset_1 | offset_2 | ... | offset_N ]
    +
    +  // loop until we run out of stubs (no stubid)
    +  while (stub_id != StubId::NO_STUBID) {
    +    uint offset = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +    uint size = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +
    +    // Log the embedded stub
    +    log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d id=%d blob=%d %s",
    +      p2i(buf + entry->offset() + entry->code_offset() + offset),
    +      "EmbeddedStub", size, (int) stub_id, entry->id(), StubInfo::name(stub_id));
    +
    +    //Get the number of secondary/extra entry offsets
    +    int n = *(int*) (buf + pos);
    +    pos += sizeof(int);
    +    //to skip them and prepare for the following stub (if exists)
    +    pos += n * sizeof(uint);
    +
    +    // position ourselves in the potential following stub
    +    stub_id = *(StubId*)(buf + pos);
    +    pos += sizeof(StubId);
    +  }

    Do we have an iterator that can be used, instead of doing low level operations here in the AOT code?

    For modularity, I would prefer an iterator that lives in the stub management code.

    adinn adinn commented on code on Jul 21, 2026 08:25 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -120,6 +120,46 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
       log_info(aot, map)("[End of AOT cache map]");
     }
     
    +void AOTMapLogger::log_embedded_stubs(const AOTCodeCache* cache, const AOTCodeEntry* entry) {
    +
    +  //start at the beginning of our AOT cache
    +  const char* buf = cache->store_buffer();
    +
    +  // jump to the embedded stubs section
    +  uint pos = entry->offset() + entry->embedded_stub_offset();
    +
    +  // Now we can get the information we want to log (embedded stubs)
    +  // get the first embedded stub id
    +  StubId stub_id = *(StubId*)(buf + pos);
    +  pos += sizeof(StubId);
    +
    +  // Embedded StubGenBlobs are assumed to have the following structure
    +  // [ StubId | offset | size | N | offset_1 | offset_2 | ... | offset_N ]
    +
    +  // loop until we run out of stubs (no stubid)
    +  while (stub_id != StubId::NO_STUBID) {
    +    uint offset = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +    uint size = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +
    +    // Log the embedded stub
    +    log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d id=%d blob=%d %s",
    +      p2i(buf + entry->offset() + entry->code_offset() + offset),
    +      "EmbeddedStub", size, (int) stub_id, entry->id(), StubInfo::name(stub_id));
    +
    +    //Get the number of secondary/extra entry offsets
    +    int n = *(int*) (buf + pos);
    +    pos += sizeof(int);
    +    //to skip them and prepare for the following stub (if exists)
    +    pos += n * sizeof(uint);
    +
    +    // position ourselves in the potential following stub
    +    stub_id = *(StubId*)(buf + pos);
    +    pos += sizeof(StubId);
    +  }

    Do we have an iterator that can be used, instead of doing low level operations here in the AOT code?

    The nearest thing we have is class AOTStubData, which collects details of the stubs and associated entries as part of a traversal of the full entry contents. It supports full rehydration of the blob so it does a lot more work than we need simply to print details of the stubs.

    Delawen Delawen commented on code on Jul 21, 2026 11:13 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -120,6 +120,46 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
       log_info(aot, map)("[End of AOT cache map]");
     }
     
    +void AOTMapLogger::log_embedded_stubs(const AOTCodeCache* cache, const AOTCodeEntry* entry) {
    +
    +  //start at the beginning of our AOT cache
    +  const char* buf = cache->store_buffer();
    +
    +  // jump to the embedded stubs section
    +  uint pos = entry->offset() + entry->embedded_stub_offset();
    +
    +  // Now we can get the information we want to log (embedded stubs)
    +  // get the first embedded stub id
    +  StubId stub_id = *(StubId*)(buf + pos);
    +  pos += sizeof(StubId);
    +
    +  // Embedded StubGenBlobs are assumed to have the following structure
    +  // [ StubId | offset | size | N | offset_1 | offset_2 | ... | offset_N ]
    +
    +  // loop until we run out of stubs (no stubid)
    +  while (stub_id != StubId::NO_STUBID) {
    +    uint offset = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +    uint size = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +
    +    // Log the embedded stub
    +    log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d id=%d blob=%d %s",
    +      p2i(buf + entry->offset() + entry->code_offset() + offset),
    +      "EmbeddedStub", size, (int) stub_id, entry->id(), StubInfo::name(stub_id));
    +
    +    //Get the number of secondary/extra entry offsets
    +    int n = *(int*) (buf + pos);
    +    pos += sizeof(int);
    +    //to skip them and prepare for the following stub (if exists)
    +    pos += n * sizeof(uint);
    +
    +    // position ourselves in the potential following stub
    +    stub_id = *(StubId*)(buf + pos);
    +    pos += sizeof(StubId);
    +  }

    I tried using AOTStubData but I think it is overkilling. This check on base returns always the nullpointer: https://github.com/openjdk/leyden/blob/premain2/src/hotspot/share/code/aotCodeCache.cpp#L4235-L4238

    Which leads me to think we can only use AOTStubData if/when we are loading the cache into memory, not when we are generating it. Modifying it further to be able to have a valid StubAddrRange seems too complex.

    The code I'm using is https://github.com/Delawen/leyden/blob/tiriri/src/hotspot/share/cds/aotMapLogger.cpp#L125-L153

    Delawen Delawen commented on code on Jul 21, 2026 11:15 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -120,6 +120,46 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
       log_info(aot, map)("[End of AOT cache map]");
     }
     
    +void AOTMapLogger::log_embedded_stubs(const AOTCodeCache* cache, const AOTCodeEntry* entry) {
    +
    +  //start at the beginning of our AOT cache
    +  const char* buf = cache->store_buffer();
    +
    +  // jump to the embedded stubs section
    +  uint pos = entry->offset() + entry->embedded_stub_offset();
    +
    +  // Now we can get the information we want to log (embedded stubs)
    +  // get the first embedded stub id
    +  StubId stub_id = *(StubId*)(buf + pos);
    +  pos += sizeof(StubId);
    +
    +  // Embedded StubGenBlobs are assumed to have the following structure
    +  // [ StubId | offset | size | N | offset_1 | offset_2 | ... | offset_N ]
    +
    +  // loop until we run out of stubs (no stubid)
    +  while (stub_id != StubId::NO_STUBID) {
    +    uint offset = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +    uint size = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +
    +    // Log the embedded stub
    +    log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d id=%d blob=%d %s",
    +      p2i(buf + entry->offset() + entry->code_offset() + offset),
    +      "EmbeddedStub", size, (int) stub_id, entry->id(), StubInfo::name(stub_id));
    +
    +    //Get the number of secondary/extra entry offsets
    +    int n = *(int*) (buf + pos);
    +    pos += sizeof(int);
    +    //to skip them and prepare for the following stub (if exists)
    +    pos += n * sizeof(uint);
    +
    +    // position ourselves in the potential following stub
    +    stub_id = *(StubId*)(buf + pos);
    +    pos += sizeof(StubId);
    +  }

    So unless you have any other ideas I think this PR is ready to go.

    adinn adinn commented on code on Jul 21, 2026 14:35 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -120,6 +120,46 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
       log_info(aot, map)("[End of AOT cache map]");
     }
     
    +void AOTMapLogger::log_embedded_stubs(const AOTCodeCache* cache, const AOTCodeEntry* entry) {
    +
    +  //start at the beginning of our AOT cache
    +  const char* buf = cache->store_buffer();
    +
    +  // jump to the embedded stubs section
    +  uint pos = entry->offset() + entry->embedded_stub_offset();
    +
    +  // Now we can get the information we want to log (embedded stubs)
    +  // get the first embedded stub id
    +  StubId stub_id = *(StubId*)(buf + pos);
    +  pos += sizeof(StubId);
    +
    +  // Embedded StubGenBlobs are assumed to have the following structure
    +  // [ StubId | offset | size | N | offset_1 | offset_2 | ... | offset_N ]
    +
    +  // loop until we run out of stubs (no stubid)
    +  while (stub_id != StubId::NO_STUBID) {
    +    uint offset = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +    uint size = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +
    +    // Log the embedded stub
    +    log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d id=%d blob=%d %s",
    +      p2i(buf + entry->offset() + entry->code_offset() + offset),
    +      "EmbeddedStub", size, (int) stub_id, entry->id(), StubInfo::name(stub_id));
    +
    +    //Get the number of secondary/extra entry offsets
    +    int n = *(int*) (buf + pos);
    +    pos += sizeof(int);
    +    //to skip them and prepare for the following stub (if exists)
    +    pos += n * sizeof(uint);
    +
    +    // position ourselves in the potential following stub
    +    stub_id = *(StubId*)(buf + pos);
    +    pos += sizeof(StubId);
    +  }

    Yes, AOTStubData is built to do a much more complex job than you need.

    So unless you have any other ideas I think this PR is ready to go.

    You can still relocate the code that iterates over the stub entries in method log_embedded_stub from class AOTMapLogger into class AOTCodeCcache. You will need to refactor it a bit -- just transplanting the method as is moves the printing logic out of class AOTMapLogger. You can avoid that by implementing a method on AOTCodeCache that accepts a StubGen entry and a function pointer or a closure and applies the function to each stub in the entry e.g.

    Declare a fn pointer type in aotCodeCache.hpp

    typedef void (*stub_printer_t)(BlobId blob_id, StubId stub_id, int base, int code_base, int offset);
    

    Then add a public method to class AOTCodeCache:

    void AOTCodeCache::do_print_stub_details(AOTCodeEntry* entry, aot_stub_printer_t printer) {
      assert(entry->kind() == StubGen), "invalid call");
      BlobId blob_id = (BlobId)entry->id();
      int base = entry->offset();
      int code_base = entry->code_offset();
      //skip forward to entries
      . . .
       while (stub_id != StubId::NO_STUBID) {
         offset = ...;
         (*printer)(blob_id, stub_id, base, code_base, offset);
         // skip to next id
        . . .
      }
    }
    

    You can then call AOTCodeCache::do_print_stub_details from AOTMapLogger passing in a pointer to the print function.

    An alternative to using a fn pointer is to use a lambda or a closure i.e. an instance of a class that implements callback method.

    Delawen Delawen commented on code on Jul 22, 2026 11:37 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -120,6 +120,46 @@ void AOTMapLogger::dumptime_log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
       log_info(aot, map)("[End of AOT cache map]");
     }
     
    +void AOTMapLogger::log_embedded_stubs(const AOTCodeCache* cache, const AOTCodeEntry* entry) {
    +
    +  //start at the beginning of our AOT cache
    +  const char* buf = cache->store_buffer();
    +
    +  // jump to the embedded stubs section
    +  uint pos = entry->offset() + entry->embedded_stub_offset();
    +
    +  // Now we can get the information we want to log (embedded stubs)
    +  // get the first embedded stub id
    +  StubId stub_id = *(StubId*)(buf + pos);
    +  pos += sizeof(StubId);
    +
    +  // Embedded StubGenBlobs are assumed to have the following structure
    +  // [ StubId | offset | size | N | offset_1 | offset_2 | ... | offset_N ]
    +
    +  // loop until we run out of stubs (no stubid)
    +  while (stub_id != StubId::NO_STUBID) {
    +    uint offset = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +    uint size = *(uint*)(buf + pos);
    +    pos += sizeof(uint);
    +
    +    // Log the embedded stub
    +    log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d id=%d blob=%d %s",
    +      p2i(buf + entry->offset() + entry->code_offset() + offset),
    +      "EmbeddedStub", size, (int) stub_id, entry->id(), StubInfo::name(stub_id));
    +
    +    //Get the number of secondary/extra entry offsets
    +    int n = *(int*) (buf + pos);
    +    pos += sizeof(int);
    +    //to skip them and prepare for the following stub (if exists)
    +    pos += n * sizeof(uint);
    +
    +    // position ourselves in the potential following stub
    +    stub_id = *(StubId*)(buf + pos);
    +    pos += sizeof(StubId);
    +  }

    Pushed it http://github.com/openjdk/leyden/pull/118/commits/13276190295fb3922dd1e93fee903aa577504d04

    But I am not sure what the NOT_CDS_RETURN or CDS_ONLY macros mean. I guess I should add them to my new functions?

    adinn adinn commented on code on Jul 22, 2026 13:23 UTC
    Code Review
    src/hotspot/share/code/aotCodeCache.hpp:1
    @@ -107,6 +107,7 @@ class AOTCodeEntry {
       uint   _name_offset; // Method's or intrinsic name
       uint   _name_size;
       uint   _code_offset; // Start of code in cache
    +  uint   _embedded_stub_offset; // Start of embedded stubs in StubGenBlobs

    I know @vnkozlov recommended insering this field but I don't really like it. It means every AOTCodeEntry now includes and extra int field even thought the offset is only needed for StubGen stub entries and then only when we are dumping a map.

    The point of adding this field is to avoid having to traverse a StubGen entry's blob, relocs and oop map in order to locate the stub data. That was maybe a good idea when the code was outside of class AOTCodeCache as it reduced fragility. However, now that the traversal code is internal to the class (and now also that we have asserts to discover any errors introduced by a change in format) I think it is a better trade-off to omit this extra field and require method loop_over_embedded_stubs to traverse from the start of the entry to the start of the stub data. We will only do that traversal several hundreds of times when we are dumping a map but we will save an extra word for several thousands of nmethods in every cache.

    @vnkozlov What do you think?

    adinn adinn commented on Jul 22, 2026 13:24 UTC
    Reviewer

    Looks good apart from a question as to whether we want to preserve the offset to the stub data which I am hoping @vnkozlov will address.

    vnkozlov vnkozlov commented on Jul 22, 2026 19:35 UTC
    Contributor

    I like field. How about union?:

       union {
         uint   _embedded_stub_offset; // Start of embedded stubs in StubGenBlobs
    
         uint   _comp_level;  // compilation level
       };
    

    You have to check kind in constructor to assign field to avoid overwriting.

    Delawen Delawen commented on Jul 23, 2026 10:44 UTC
    Author

    Seems to work. @vnkozlov @adinn

    adinn adinn approved these changes on Jul 23, 2026 14:23 UTC
    Approved Reviewer

    Ok, looks good.

    iklam iklam commented on code on Jul 23, 2026 15:50 UTC
    Code Review
    src/hotspot/share/code/aotCodeCache.cpp:1
    @@ -432,6 +432,48 @@ void AOTCodeCache::dump() {
       }
     }
     
    +//This is a helper function that executes a function over each embedded stub available
    +void AOTCodeCache::loop_over_embedded_stubs(const AOTCodeEntry* entry, const embedded_stub_func func) {

    The HotSpot convention is to call this function iterate_embedded_stubs().

    iklam iklam commented on code on Jul 23, 2026 15:54 UTC
    Code Review
    src/hotspot/share/cds/aotMapLogger.cpp:1
    @@ -143,7 +149,20 @@ void AOTMapLogger::log_ac_region() {
                 p2i(entry), AOTCodeCache::get_kind_name(entry->kind()),
                 entry->size(), entry->comp_level(), entry->comp_id(), name);
               break;
    -        default:
    +        case  AOTCodeEntry::Kind::StubGenBlob:
    +          {
    +            BlobId blob_id = (BlobId) entry->id();
    +
    +            //First we log the stub blob
    +            log_debug(aot, map)(PTR_FORMAT ": @@ %-17s %d %d %s",

    For consistency, use "... %-17s %d id=%d %s",

    Also, we should use id=%d and level=%d for the Nmethod and default cases.

    iklam iklam commented on code on Jul 23, 2026 15:58 UTC
    Code Review
    src/hotspot/share/code/aotCodeCache.hpp:1
    @@ -160,6 +168,9 @@ class AOTCodeEntry {
       uint name_size()    const { return _name_size; }
       uint code_offset()  const { return _code_offset; }
     
    +  void set_embedded_stub_offset(const uint off) { _embedded_stub_offset = off; }
    +  uint embedded_stub_offset()  const { return _embedded_stub_offset; }

    These functions should have precond(_kind == StubGenBlo). Similarly, the comp_level() accessor should assert the opposite.

    iklam iklam commented on code on Jul 23, 2026 15:58 UTC
    Code Review
    src/hotspot/share/code/aotCodeCache.hpp:1
    @@ -137,7 +140,12 @@ class AOTCodeEntry {
         _name_size    = name_size;
         _code_offset  = code_offset;
     
    -    _comp_level   = comp_level;
    +    if (_kind == StubGenBlob) {
    +      _embedded_stub_offset = 0;
    +    } else {
    +      _comp_level   = comp_level;

    Extraneous spaces before =.

    vnkozlov vnkozlov commented on Jul 23, 2026 17:44 UTC
    Contributor

    Looks good to me too. I will wait GHA finished to submit our testing too.

    Delawen Delawen commented on Jul 24, 2026 10:12 UTC
    Author

    @vnkozlov ready for your tests

    iklam iklam approved these changes on Jul 24, 2026 16:00 UTC
    Approved Reviewer

    LGTM

    vnkozlov vnkozlov commented on Jul 24, 2026 16:22 UTC
    Contributor

    @vnkozlov ready for your tests

    Submitted.

    vnkozlov vnkozlov approved these changes on Jul 25, 2026 05:55 UTC
    Approved Reviewer

    My testing passed.

    adinn adinn approved these changes on Jul 25, 2026 15:32 UTC
    Approved Reviewer

    good

    Delawen Delawen commented on Jul 27, 2026 09:07 UTC
    Author

    /integrate

    Delawen Delawen commented on Jul 27, 2026 09:08 UTC
    Author

    Hope the failing windows test job does not interfere with integration...

    openjdk[bot] openjdk[bot] commented on Jul 27, 2026 09:09 UTC
    Bot

    <!-- Jmerge command reply message (5089414785) -->
    @Delawen <!-- integration requested: 'c396c4d5b657944a7bb62b6584096a3de4788193' -->
    Your change (at version c396c4d5b657944a7bb62b6584096a3de4788193) is now ready to be sponsored by a Committer.

    Delawen Delawen commented on Jul 27, 2026 09:10 UTC
    Author

    Can someone sponsor me? @adinn @ashu-mehra @iklam @vnkozlov

    adinn adinn commented on Jul 27, 2026 12:18 UTC
    Contributor

    /sponsor

    openjdk[bot] openjdk[bot] commented on Jul 27, 2026 12:19 UTC
    Bot

    <!-- prepush ec0494a48ef17cbf5e3a24ef7f20c99ffbd1bbf7 -->
    Going to push as commit ec0494a48ef17cbf5e3a24ef7f20c99ffbd1bbf7.
    Since your change was applied there have been 371 commits pushed to the premain2 branch:

    c821bad0ebcea325aaf8ea4a76b17c14d2183566: 8388411: [leyden] Increase memory limit for C2 AOT compilations
    558735508c5efce0db1e932ebfee35db22517e2c: Merge
    405120e6356fd37a1f196060e931b472c8efde32: Merge master 07-16-2026
    ... and 368 more: https://git.openjdk.org/leyden/compare/5031301ed5443d85f06522c0a1989d980a23195c...premain2

    Your commit was automatically rebased without conflicts.

    openjdk[bot] openjdk[bot] commented on Jul 27, 2026 12:20 UTC
    Bot

    <!-- Jmerge command reply message (5091187421) -->
    @adinn @Delawen Pushed as commit ec0494a48ef17cbf5e3a24ef7f20c99ffbd1bbf7.

    :bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

    Reviewers
    Assignees
    Delawen Delawen
    Labels
    risk: low confidence: 83.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.7% (MEDIUM) · Higher = larger blast radius
    35.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.3% · Lower = rushed or shallow review
    83.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.0% · Safe to merge
    6.0%
    Repository