Isolating the GC code from the jvm to run on external accelerator

Andrew Haley aph at redhat.com
Tue May 5 13:59:29 UTC 2020


On 5/5/20 1:50 PM, Ofir Gordon wrote:
> Do you maybe know any tutorial / documentation / explaination that
> describes the mechanism behind the way that the gc finds the pointers in an
> object's fields?

No. There may be, but I know of none.

> I can see that it happaens somehow by partition of the object to "chuncks"
> in the class "classLoaderData" (if I understood correctly), but I wish to
> understand the complete process.

It's not hard once you know where to look.

I put a breakpoint on InstanceKlass::oop_oop_iterate_reverse() and
then:

(gdb) p print()
com.sun.tools.javac.tree.JCTree$JCMethodDecl {0x000000080010a0f8}
 - instance size:     8
 - klass size:        122
 - access:            public synchronized
 - state:             fully_initialized
 - name:              'com/sun/tools/javac/tree/JCTree$JCMethodDecl'
 - super:             'com/sun/tools/javac/tree/JCTree'
 - sub:
 - arrays:            NULL
 - methods:           Array<T>(0x00007fff7def1648)
 - method ordering:   Array<T>(0x00007fff7f800058)
 - default_methods:   Array<T>(0x0000000000000000)
 - local interfaces:  Array<T>(0x00007fff7def0df8)
 - trans. interfaces: Array<T>(0x00007fff7def28f8)
 - constants:         constant pool [173] {0x00007fff7def07c8} for 'com/sun/tools/javac/tree/JCTree$JCMethodDecl' cache=0x00007fff7dacf5e8
 - class loader data:  loader data: 0x00007ffff04bfbf0 for instance a 'jdk/internal/loader/ClassLoaders$AppClassLoader'{0x000000008306ec38}
 - unsafe anonymous host class:        NULL
 - source file:       'JCTree.java'
 - class annotations:       Array<T>(0x0000000000000000)
 - class type annotations:  Array<T>(0x0000000000000000)
 - field annotations:       Array<T>(0x0000000000000000)
 - field type annotations:  Array<T>(0x0000000000000000)
 - inner classes:     Array<T>(0x00007fff7def2898)
 - nest members:     Array<T>(0x00007fff7f800070)
 - java mirror:       a 'java/lang/Class'{0x0000000083325bc0} = 'com/sun/tools/javac/tree/JCTree$JCMethodDecl'
 - vtable length      35  (start addr: 0x000000080010a2e8)
 - itable length      23 (start addr: 0x000000080010a400)
 - ---- static fields (0 words):
 - ---- non-static fields (13 words):
 - public 'pos' 'I' @12
 - public 'type' 'Lcom/sun/tools/javac/code/Type;' @16
 - public 'completesNormally' 'Z' @20
 - public 'mods' 'Lcom/sun/tools/javac/tree/JCTree$JCModifiers;' @24
 - public 'name' 'Lcom/sun/tools/javac/util/Name;' @28
 - public 'restype' 'Lcom/sun/tools/javac/tree/JCTree$JCExpression;' @32
 - public strict 'typarams' 'Lcom/sun/tools/javac/util/List;' @36
 - public 'recvparam' 'Lcom/sun/tools/javac/tree/JCTree$JCVariableDecl;' @40
 - public strict 'params' 'Lcom/sun/tools/javac/util/List;' @44
 - public strict 'thrown' 'Lcom/sun/tools/javac/util/List;' @48
 - public 'body' 'Lcom/sun/tools/javac/tree/JCTree$JCBlock;' @52
 - public 'defaultValue' 'Lcom/sun/tools/javac/tree/JCTree$JCExpression;' @56
 - public 'sym' 'Lcom/sun/tools/javac/code/Symbol$MethodSymbol;' @60
 - non-static oop maps: 16-16 24-60

(gdb) up
#8  OopOopIterateBackwardsDispatch<G1ScanEvacuatedObjClosure>::Table::oop_oop_iterate_backwards<InstanceKlass, unsigned int> (
    cl=0x7fff900041c0, obj=0x83962958, k=0x80010a0f8) at /local/jdk-jdk/src/hotspot/share/memory/iterator.inline.hpp:360
(gdb) up
#9  0x00007ffff5a826e8 in OopIteratorClosureDispatch::oop_oop_iterate_backwards<G1ScanEvacuatedObjClosure> (cl=0x7fff900041c0,
    obj=0x83962958, klass=0x80010a0f8) at /local/jdk-jdk/src/hotspot/share/memory/iterator.inline.hpp:425
(gdb) up
#10 0x00007ffff5a82578 in oopDesc::oop_iterate_backwards<G1ScanEvacuatedObjClosure> (this=0x83962958, cl=0x7fff900041c0)
    at /local/jdk-jdk/src/hotspot/share/oops/oop.inline.hpp:408
(gdb) call pp(this)

"Executing pp"
com.sun.tools.javac.tree.JCTree$JCMethodDecl
{0x0000000083962958} - klass: 'com/sun/tools/javac/tree/JCTree$JCMethodDecl'
 - ---- fields (total size 8 words):
 - public 'pos' 'I' @12  20847 (516f)
 - public 'type' 'Lcom/sun/tools/javac/code/Type;' @16  NULL
 (0)
 - public 'completesNormally' 'Z' @20  false
 - public 'mods' 'Lcom/sun/tools/javac/tree/JCTree$JCModifiers;' @24  a 'com/sun/tools/javac/tree/JCTree$JCModifiers'{0x0000000084aea580} (1095d4b0)
 - public 'name' 'Lcom/sun/tools/javac/util/Name;' @28  a 'com/sun/tools/javac/util/SharedNameTable$NameImpl'{0x0000000084aea0c8} (1095d419)
 - public 'restype' 'Lcom/sun/tools/javac/tree/JCTree$JCExpression;' @32  a 'com/sun/tools/javac/tree/JCTree$JCIdent'{0x0000000084aea5c0} (1095d4b8)
 - public strict 'typarams' 'Lcom/sun/tools/javac/util/List;' @36  a 'com/sun/tools/javac/util/List$1'{0x00000000820005b0} (104000b6)
 - public 'recvparam' 'Lcom/sun/tools/javac/tree/JCTree$JCVariableDecl;' @40  NULL
 (0)
 - public strict 'params' 'Lcom/sun/tools/javac/util/List;' @44  a 'com/sun/tools/javac/util/List'{0x0000000084aea788} (1095d4f1)
 - public strict 'thrown' 'Lcom/sun/tools/javac/util/List;' @48  a 'com/sun/tools/javac/util/List$1'{0x00000000820005b0} (104000b6)
 - public 'body' 'Lcom/sun/tools/javac/tree/JCTree$JCBlock;' @52  a 'com/sun/tools/javac/tree/JCTree$JCBlock'{0x0000000084aeb290} (1095d652)
 - public 'defaultValue' 'Lcom/sun/tools/javac/tree/JCTree$JCExpression;' @56  NULL
 (0)
 - public 'sym' 'Lcom/sun/tools/javac/code/Symbol$MethodSymbol;' @60  NULL
 (0)

The crucial information is the oopMap in the Klass JCTree$JCMethodDecl.

This line:

 - non-static oop maps: 16-16 24-60

... tells you that the fields at offsets 6-16 and 24-60 are oops, so must
be scanned. Any other fields in the object are ignored. If you look at the
named fields in the object, this is so.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671




More information about the hotspot-gc-dev mailing list