RFR: 8253757: Add LLVM-based backend for hsdis

Magnus Ihse Bursie ihse at openjdk.java.net
Mon Nov 23 15:59:07 UTC 2020


On Mon, 26 Oct 2020 11:41:16 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> Some notes (perhaps most to myself) about how this ties into the existing hsdis implementation, and with JDK-8188073 (Capstone porting).
>> 
>> When printing disassembly from hotspot, the current solution tries to locate and load the hsdis library, which prints disassembly using bfd. The reason for using the separate library approach is, as far as I can understand, perhaps a mix of both incompatible licensing for bfd, and a wish to not burden the jvm library with additional bloat which is needed only for debugging.
>> 
>> The Capstone approach, in the prototype patch presented by Jorn in the issue, is to create a new capstonedis library, and dispatch to it instead of hsdis.
>> 
>> The approach used in this patch is to refactor the existing hsdis library into an abstract base class for hsdis backends, with two concrete implementations, one for bfd and one for llvm. 
>> 
>> Unfortunately, I think the resulting code in hsdis.cpp in this patch is hard to read and understand.
>
> I think a proper solution to both this and the Capstone implementation is to provide a proper framework for selecting the hsdis backend as a first step, and refactor the existing bfd implementation as the first such backend. After that, we can add llvm and capstone as alternative hsdis backend implementations.

FWIW, I started working on a framework which would add support for selectable backends for hsdis. Unfortunately it was not as simple as I initially thought, so I had to put it on hold while directing my time to working on the winenv patch instead.

I believe the proper way forward is to get the "selectable hsdis backend" framework in place, and then retrofit this patch to add LLVM support in that framework. If this means that this PR should be closed, or kept open until this is done, I don't know.

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

PR: https://git.openjdk.java.net/jdk/pull/392



More information about the build-dev mailing list