What are the variables 'shadow $ _klass_' and 'shadow $ _monitor_' for java.lang.Object?

It appears that in the latest Android update (SDK 21) two new variables were added to java.lang.Object :

 private transient Class<?> shadow$_klass_; private transient int shadow$_monitor_; 

I noticed that shadow$_monitor_ briefly used in hashCode() :

 public int hashCode() { int lockWord = shadow$_monitor_; final int lockWordMask = 0xC0000000; // Top 2 bits. final int lockWordStateHash = 0x80000000; // Top 2 bits are value 2 (kStateHash). if ((lockWord & lockWordMask) == lockWordStateHash) { return lockWord & ~lockWordMask; } return System.identityHashCode(this); } 

But otherwise there is no reference to them. Are they somehow related to GC in art? or some kind of native material?

+56
java android android-5.0-lollipop art-runtime
Nov 14 '14 at 3:55
source share
1 answer

They are really affiliated with the GC. It seems they were added to support Brooks pointers. I found some information about Brooks pointers here :

The idea is that each object on the heap has one additional link field. This field points to the object itself or, as soon as the object is copied to a new location, to this new location. This will allow us to evacuate objects simultaneously with mutator flows.

See, in particular, these two commits:

libcore: a7c69f785f7d1b07b7da22cfb9150c584ee143f4

art: 9d04a20bde1b1855cefc64aebc1a44e253b1a13b

+26
Nov 21 '14 at 10:14
source share
β€” -



All Articles