RFR: 8308903: Print detailed info for Java objects in -Xlog:cds+map [v5]

Calvin Cheung ccheung at openjdk.org
Mon Jul 24 16:05:45 UTC 2023


On Fri, 21 Jul 2023 19:57:12 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> This PR adds detailed printing of oop information with `-Xlog:cds+map+oop=trace`, or simply `-Xlog:cds+map*=trace`. The information is useful for debugging contents of the CDS archived heap objects.
>> 
>> The output looks like `oopDesc::print_on(tty)`, but we need to print the pointers using the locations of the objects at runtime. The examples below show how a `String` references its `value` array.
>> 
>> Example with `-XX:-UseCompressedOops`:
>> 
>> 
>> 0x00000000100001f0: @@ Object java.lang.String
>> 0x00000000100001f0: 0000006ff6ab8d01 88d47c5b00010290 0000000000010000 0000000010000210
>>  - klass: 'java/lang/String' 0x0000000800010290
>>  - ---- fields (total size 4 words):
>>  - private 'hash' 'I' @12 -1999340453 (0x88d47c5b)
>>  - private final 'coder' 'B' @16 0 (0x00)
>>  - private 'hashIsZero' 'Z' @17 false (0x00)
>>  - injected 'flags' 'B' @18 1 (0x01)
>>  - private final 'value' '[B' @24 0x0000000010000210 [B length: 6
>> 0x0000000010000210: @@ Object [B length: 6
>> 0x0000000010000210: 000000693b708001 00000006000024c8 0000574f5252414e
>>  - klass: {type array byte} 0x00000008000024c8
>>  - 0: 4e N
>>  - 1: 41 A
>>  - 2: 52 R
>>  - 3: 52 R
>>  - 4: 4f O
>>  - 5: 57 W
>> 
>> 
>> Example with `-XX:+UseCompressedOops`. Note that the narrorOop is also printed:
>> 
>> 
>> 0x00000007ffc001b8: @@ Object (0xfff80037) java.lang.String
>> 0x00000007ffc001b8: f6ab8d01 0000006f 00010290 88d47c5b 00010000 fff8003a
>>  - klass: 'java/lang/String' 0x0000000800010290
>>  - ---- fields (total size 3 words):
>>  - private 'hash' 'I' @12 -1999340453 (0x88d47c5b)
>>  - private final 'coder' 'B' @16 0 (0x00)
>>  - private 'hashIsZero' 'Z' @17 false (0x00)
>>  - injected 'flags' 'B' @18 1 (0x01)
>>  - private final 'value' '[B' @20 0x00000007ffc001d0 (0xfff8003a) [B length: 6
>> 0x00000007ffc001d0: @@ Object (0xfff8003a) [B length: 6
>> 0x00000007ffc001d0: 3b708001 00000069 000024c8 00000006 5252414e 0000574f
>>  - klass: {type array byte} 0x00000008000024c8
>>  - 0: 4e N
>>  - 1: 41 A
>>  - 2: 52 R
>>  - 3: 52 R
>>  - 4: 4f O
>>  - 5: 57 W
>
> Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Merge branch 'master' into 8308903-cds-map-detailed-info-for-oops
>  - added hints in test case
>  - added test case
>  - Merge branch 'master' into 8308903-cds-map-detailed-info-for-oops
>  - @tstuefe and @matias9927 comments
>  - 8308903: Print detailed info for Java objects in -Xlog:cds+map

Just couple of nits. Looks good.

src/hotspot/share/cds/archiveBuilder.cpp line 1069:

> 1067:         ShouldNotReachHere();
> 1068:       }
> 1069: 

Blank line added by accident?

src/hotspot/share/cds/archiveHeapWriter.cpp line 546:

> 544: 
> 545:   BitMap::idx_t idx = requested_field_addr - (Metadata**) _requested_bottom;
> 546:   return (idx < heap_info->ptrmap()->size()) && (heap_info->ptrmap()->at(idx) == true);

For the second condition, would it be clearer to check for non-null?
    `heap_info->ptrmap()->at(idx) != nullptr`

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

Marked as reviewed by ccheung (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14841#pullrequestreview-1543778440
PR Review Comment: https://git.openjdk.org/jdk/pull/14841#discussion_r1272446560
PR Review Comment: https://git.openjdk.org/jdk/pull/14841#discussion_r1272448723


More information about the hotspot-dev mailing list