review (L) for 7017732: move static fields into Class to prepare for perm gen removal

Tom Rodriguez tom.rodriguez at
Tue Feb 8 14:01:38 PST 2011

7017732: move static fields into Class to prepare for perm gen removal

Currently static fields are stored in the instanceKlass but when those
are moved into native memory we'd have to have a new card mark
strategy for static fields.  This could be something like setting a
flag in the instanceKlass and then rescanning every klass during a GC
which seems expensive or marking the card for the java.lang.Class then
making sure to scan the instanceKlass when scanning the Class.  If we
move them into the Class then almost all the existing machinery works
exactly as it always has.  The only execution difference is which
constant is materialized for the field access.

Most of the machinery for static fields is now over in
javaClasses.cpp.  The bootstrap had to change slightly since we don't
have Class until we've loaded a few classes but it all fits into the
existing mirror creation logic.  I also only create mirrors for real
Java classes whereas previously we also created them for internal
klasses we create.

The main implementation oddity is that java.lang.Class instances are
now variably sized.  This required a small change in size_given_klass
and a new instanceMirrorKlass to handle visiting the oops in them.

Performance is unchanged.  Tested with ctw, runthese, nsk jvmti tests
and jbb with the various collectors.

More information about the hotspot-dev mailing list