RFR: 8292921: Rewrite object field printer [v8]
Coleen Phillimore
coleenp at openjdk.org
Wed Sep 7 11:46:40 UTC 2022
On Fri, 2 Sep 2022 08:28:43 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> See this as a RFC rather than a fully ready PR:
>>
>> fieldDescriptor::print_on_for is a bit inconsistent in how it deals with printing the "underlying representation" of the field values. I'd like to change to make it easier to both read output that gets generated in our hs_err files, but also make it easier to understand the code.
>>
>> This started out as a small patch in Generational ZGC to change how the underlying representation was written. Before this patch, the fields in the hs_err files were written with this format:
>>
>> - final 'interruptLock' 'Ljava/lang/Object;' @112 a 'java/lang/Object'{0x000004000f635e80} (5e808a30, 4000f63)
>>
>> and with the suggested change we get:
>>
>> - final 'interruptLock' 'Ljava/lang/Object;' @112 a 'java/lang/Object'{0x000004000f635e80} (0x04000f635e808a30)
>>
>> which makes it much easier to read the colored pointer (0x04000f635e808a30) of the object address (0x000004000f635e80).
>>
>> I think this is good even for the upstream repository, so I'd like to propose that we print the underlying representation as a full hex value without trying to split the value into 4-bytes chunks.
>>
>> There used to be a filter that said that we shouldn't print the underlying bits if the value was a positive, single digit, 4-bytes primitive. I've removed that code, but that will add more logging (esp. of 0 values). So, I'd like to get some feedback on that.
>>
>> A full example of the generated output:
>>
>> java.lang.Class
>> {0x00007ffc36801080} - klass: 'java/lang/Class'
>> - ---- fields (total size 26 words):
>> - private volatile transient 'classRedefinedCount' 'I' @12 0 (0x00000000)
>> - abstract internal 'klass' 'J' @16 2147753408 (0x0000000080041dc0)
>> - abstract internal 'array_klass' 'J' @24 0 (0x0000000000000000)
>> - abstract internal 'oop_size' 'I' @32 26 (0x0000001a)
>> - abstract internal 'static_oop_field_count' 'I' @36 2 (0x00000002)
>> - private volatile transient 'cachedConstructor' 'Ljava/lang/reflect/Constructor;' @40 NULL (0x0000000000000000)
>> - private transient 'name' 'Ljava/lang/String;' @48 NULL (0x0000000000000000)
>> - private transient 'module' 'Ljava/lang/Module;' @56 NULL (0x0000000000000000)
>> - private final 'classLoader' 'Ljava/lang/ClassLoader;' @64 NULL (0x0000000000000000)
>> - private transient 'classData' 'Ljava/lang/Object;' @72 NULL (0x0000000000000000)
>> - private transient 'packageName' 'Ljava/lang/String;' @80 NULL (0x0000000000000000)
>> - private final 'componentType' 'Ljava/lang/Class;' @88 NULL (0x0000000000000000)
>> - private volatile transient 'reflectionData' 'Ljava/lang/ref/SoftReference;' @96 NULL (0x0000000000000000)
>> - private volatile transient 'genericInfo' 'Lsun/reflect/generics/repository/ClassRepository;' @104 NULL (0x0000000000000000)
>> - private volatile transient 'enumConstants' '[Ljava/lang/Object;' @112 NULL (0x0000000000000000)
>> - private volatile transient 'enumConstantDirectory' 'Ljava/util/Map;' @120 NULL (0x0000000000000000)
>> - private volatile transient 'annotationData' 'Ljava/lang/Class$AnnotationData;' @128 NULL (0x0000000000000000)
>> - private volatile transient 'annotationType' 'Lsun/reflect/annotation/AnnotationType;' @136 NULL (0x0000000000000000)
>> - transient 'classValueMap' 'Ljava/lang/ClassValue$ClassValueMap;' @144 NULL (0x0000000000000000)
>> - abstract internal 'protection_domain' 'Ljava/lang/Object;' @152 NULL (0x0000000000000000)
>> - abstract internal 'signers_name' 'Ljava/lang/Object;' @160 NULL (0x0000000000000000)
>> - abstract internal 'source_file' 'Ljava/lang/Object;' @168 NULL (0x0000000000000000)
>> - signature: Ljava/lang/String;
>> - ---- static fields (2):
>> - private static final 'serialVersionUID' 'J' @192 -6849794470754667710 (0xa0f0a4387a3bb342)
>> - static final 'COMPACT_STRINGS' 'Z' @202 false (0x00000000)
>> - private static final 'serialPersistentFields' '[Ljava/io/ObjectStreamField;' @176 NULL (0x0000000000000000)
>> - private static final 'REPL' 'C' @200 65533 (0x0000fffd)
>> - public static final 'CASE_INSENSITIVE_ORDER' 'Ljava/util/Comparator;' @184 NULL (0x0000000000000000)
>> - static final 'LATIN1' 'B' @203 0 (0x00000000)
>> - static final 'UTF16' 'B' @204 1 (0x00000001)
>
> Stefan Karlsson has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:
>
> - Work around clang's warning about using jlong
> - Merge remote-tracking branch 'upstream/master' into 8292921_object_field_printer
> - Guide to integer format specifier suffixes
> - Introduce and use various 0x0... prefixed integer format specifiers
> - Review tsteufe
> - Review dholmes
> - Fix macOS sensitivity to format specifier for jlong
> - Print correct number of bits for small integer types
> - 8292921: Rewrite object field printer
Seems like an improvement. Those non-hex numbers for field addresses were never helpful.
-------------
Marked as reviewed by coleenp (Reviewer).
PR: https://git.openjdk.org/jdk/pull/10028
More information about the hotspot-dev
mailing list