RFR: 8359120: Improve warning message when fail to load hsdis library [v2]

Taizo Kurashige tkurashige at openjdk.org
Mon Jun 23 12:01:32 UTC 2025


On Thu, 19 Jun 2025 09:30:42 GMT, Manuel Hässig <mhaessig at openjdk.org> wrote:

> Thank you for working on this. I have been confused by this myself and think this is a great improvement. I do have a few comments and questions, though.
> 
> Currently, I do not understand exactly how your new message is only printed when hsdis is not loaded. Do we only emit a MachCode section if hsdis is not loaded?

Thank you for your comment!

Yes, my research shows that we only emit a MachCode section if hsdis is not loaded.

`is_abstract()` in [src/hotspot/share/compiler/disassembler.hpp#L83](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/compiler/disassembler.hpp#L83C1-L88C4) determines if hsdis is not loaded. `is_abstract()` returns true if loading hsdis fails.


  static bool is_abstract() {
    if (!_tried_to_load_library) {
      load_library();
    }
    return ! _library_usable;
  }


There are three direct processes to output the MachCode section:

1. [src/hotspot/share/compiler/abstractDisassembler.cpp#L355](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/compiler/abstractDisassembler.cpp#L355) 
2. [src/hotspot/share/code/nmethod.cpp#L3494](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/code/nmethod.cpp#L3494) 
3. [src/hotspot/share/code/nmethod.cpp#L3528](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/code/nmethod.cpp#L3528)
  
  
1. is called when `is_abstract()` at [src/hotspot/share/compiler/disassembler.cpp#L889](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/compiler/disassembler.cpp#L889) returns true.

For example, if loading hsdis fails to load and hs_err occurs

2. is called when `is_abstract()` at [src/hotspot/share/code/nmethod.cpp#L3444](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/code/nmethod.cpp#L3444) returns true and `compressed_with_comments` at [src/hotspot/share/code/nmethod.cpp#L3445](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/code/nmethod.cpp#L3445C14-L3445C38) is false.

For example, if only `-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly` is specified

3. is called when `is_abstract()` at [src/hotspot/share/code/nmethod.cpp#L3444](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/code/nmethod.cpp#L3444) returns true and `compressed_with_comments` at [src/hotspot/share/code/nmethod.cpp#L3445](https://github.com/openjdk/jdk/blob/fe7ec312590ed9f70e6caad4ef454123138bbbcf/src/hotspot/share/code/nmethod.cpp#L3445C14-L3445C38) is true.

For example, `-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -XX:PrintAssemblyOptions=show-comment:off,show-block-comment:off` is specified

> src/hotspot/share/compiler/disassembler.cpp line 841:
> 
>> 839:                                           os::dll_lookup(_library, decode_instructions_virtual_name));
>> 840:   }
>> 841:   _tried_to_load_library = true;
> 
> Personally, I would leave this warning. It does not hurt, and perhaps someone is depending on it to detect if hsdis is installed correctly.

I thought your comment made sense.
I fixed it.

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

PR Comment: https://git.openjdk.org/jdk/pull/25726#issuecomment-2996199553
PR Review Comment: https://git.openjdk.org/jdk/pull/25726#discussion_r2161446105


More information about the hotspot-compiler-dev mailing list