[code-reflection] RFR: OpWriter block naming align with block indexes [v2]
Paul Sandoz
psandoz at openjdk.org
Mon May 27 15:24:12 UTC 2024
On Mon, 27 May 2024 06:17:38 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> I propose to change OpWriter block naming conventions to be aligned with block indexes.
>>
>> It is very hard to debug when there is no connection between debugged body and available prints provided by OpWriter.
>> This patch composes block name as composition of block indexes from super-parent-body block index down the actual block index. With fallback to the `block__<counter>` In case the block is not a part of a body.
>>
>> This is and example of such print:
>>
>> %0 : java.util.function.IntUnaryOperator = lambda @loc="88:31" (%1 : int)int -> {
>> %2 : Var<int> = var %1 @"i" @loc="88:31";
>> %3 : int = var.load %2 @loc="89:17";
>> %4 : int = constant @"0" @loc="89:21";
>> %5 : boolean = gt %3 %4 @loc="89:17";
>> cbranch %5 ^block_0_1 ^block_0_2;
>>
>> ^block_0_1:
>> %6 : java.util.function.IntUnaryOperator = lambda @loc="90:38" (%7 : int)int -> {
>> %8 : Var<int> = var %7 @"ii" @loc="90:38";
>> %9 : int = var.load %8 @loc="91:25";
>> %10 : int = constant @"0" @loc="91:30";
>> %11 : boolean = lt %9 %10 @loc="91:25";
>> cbranch %11 ^block_0_1_1 ^block_0_1_2;
>>
>> ^block_0_1_1:
>> %12 : int = constant @"2" @loc="92:32";
>> %13 : int = var.load %8 @loc="92:36";
>> %14 : int = mul %12 %13 @loc="92:32";
>> %15 : int = constant @"1" @loc="92:41";
>> %16 : int = sub %14 %15 @loc="92:32";
>> return %16 @loc="92:25";
>>
>> ^block_0_1_2:
>> %17 : int = var.load %8 @loc="94:32";
>> return %17 @loc="94:25";
>>
>> ^block_0_1_3:
>> return @loc="90:38";
>> };
>> %18 : Var<java.util.function.IntUnaryOperator> = var %6 @"o" @loc="90:17";
>> %19 : java.util.function.IntUnaryOperator = var.load %18 @loc="97:24";
>> %20 : int = constant @"2" @loc="97:37";
>> %21 : int = var.load %2 @loc="97:41";
>> %22 : int = mul %20 %21 @loc="97:37";
>> %23 : int = invoke %19 %22 @"java.util.function.IntUnaryOperator::applyAsInt(int)int" @loc="97:24";
>> return %23 @loc="97:17";
>>
>> ^block_0_2:
>> %24 : java.util.function.IntUnaryOperator = lambda @loc="99:38" (%25 : int)int -> {
>> %26 : Var<int> = var %25 @"ii" @loc="99:38";
>> %27 : int = var.load %26 @loc="100:25";
>> %28 : int = constant @"0" @loc="100:30";
>> ...
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> applied suggested changes
Marked as reviewed by psandoz (Lead).
src/java.base/share/classes/java/lang/reflect/code/writer/OpWriter.java line 64:
> 62: public String apply(CodeItem codeItem) {
> 63: return switch (codeItem) {
> 64: case Block block -> gn.computeIfAbsent(block, _b -> name(block));
Suggestion:
case Block block -> gn.computeIfAbsent(block, _b -> name(_b));
Or replace with method reference to static method?
-------------
PR Review: https://git.openjdk.org/babylon/pull/91#pullrequestreview-2081145986
PR Review Comment: https://git.openjdk.org/babylon/pull/91#discussion_r1616183228
More information about the babylon-dev
mailing list