RFR: JDK-8302335: IGV: Bytecode not showing
Roberto Castañeda Lozano
rcastanedalo at openjdk.org
Wed Feb 15 09:51:47 UTC 2023
On Mon, 13 Feb 2023 15:09:11 GMT, Tobias Holenstein <tholenstein at openjdk.org> wrote:
> Currently, IGV does not show the bytecode of a graph in the "Bytecode" window although the bytecode is present in the XML file.
>
> # Solution
>
> Following is the `<bytecodes>` block of the XML file
>
> <bytecodes>
> <![CDATA[
> 0 iconst_3
> 1 istore_1
> 2 bipush 9
> 4 istore_2
> 5 iload_2
> 6 ifle 34
> 0 bci: 6 BranchData taken(0) displacement(112) not taken(0)
> 9 iconst_2
> 10 istore_3
> 11 iload_3
> 12 iload_2
> 13 if_icmpge 28
> 32 bci: 13 BranchData taken(0) displacement(56) not taken(0)
> 16 iload_1
> 17 istore_1
> 18 iconst_1
> 19 iload_3
> 20 irem
> 21 istore_1
> 22 iinc #3 1
> 25 goto 11
> 64 bci: 25 JumpData taken(0) displacement(-32)
> 28 iinc #2 -1
> 31 goto 5
> 88 bci: 31 JumpData taken(0) displacement(-88)
> 34 return
> ]]>
> </bytecodes>
>
> The problem was that during paring IGV skipped all lines that started with an empty space: This just skipped all bytecodes. We only want to skip bytecode like ` 0 bci: 6 BranchData taken(0) displacement(112) not taken(0)` . Meaning: whitespace - number - exactly two white spaces - and then arbitrary text.
>
> <img width="283" alt="bytecode" src="https://user-images.githubusercontent.com/71546117/218495199-2b02a79c-3065-404c-af57-3f8a603ac499.png">
Good catch! The issue with the more liberal matching of bytecodes proposed in this PR is that bytecode attributes are now also matched and treated as bytecodes, see e.g. the second last line in this screenshot:

Somewhere between JDK 20 b17 and JDK 20 b25 (most likely with the integration of [JDK-8292699](https://bugs.openjdk.org/browse/JDK-8292699)), the indentation in bytecode dumps produced by `BytecodeTracer::print_method_codes()` changed. The change introduced indentation for the bytecodes but did not update the indentation of their attributes, which I guess was unintended. Here is an example:
Before:
0 nofast_aload_0
1 invokevirtual 478 <java/lang/String.isLatin1()Z>
0 bci: 1 VirtualCallData count(5119) nonprofiled_count(0) entries(0)
After:
0 nofast_aload_0
1 invokevirtual 478 <java/lang/String.isLatin1()Z>
0 bci: 1 VirtualCallData count(5119) nonprofiled_count(0) entries(0)
I am not sure about what is the best solution to this, but ideally we would want to support the old and current indentation, and probably also fix and support the proper indentation of bytecode attributes in `BytecodeTracer::print_method_codes()`.
A possible solution from IGV side is to rule out attribute lines, e.g. likes starting with a number then the `bci` keyword such as
` 56 bci: 4 BranchData taken(0) displacement(48)`
or lines starting with non-digits such as
` not taken(5119)`
And so on. Another possible solution is to actually parse these attributes and display them somehow (e.g. as bytecode sub-items), since they actually convey useful information. What do you think?
-------------
Changes requested by rcastanedalo (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12537
More information about the hotspot-compiler-dev
mailing list