OSDN Git Service

Move array pinning out of global references table.
authorAndy McFadden <fadden@android.com>
Fri, 21 Aug 2009 19:01:31 +0000 (12:01 -0700)
committerAndy McFadden <fadden@android.com>
Fri, 21 Aug 2009 19:01:31 +0000 (12:01 -0700)
commitc26bb63b50c7a855d25b396b1bf23a3aa6929b48
tree44b5ba2c7090e567be5e3a6593a3dcd062375f9d
parentecd3115415793a6d39d3092bbba569bad77eb765
Move array pinning out of global references table.

We have to pin primitive arrays for certain JNI operations (it's that or
return a copy of the contents).  We don't move objects around in the
virtual heap, so simply creating a global reference is enough to ensure
the correct behavior of the calls.

The global reference implementation is changing in a way that makes
this approach inconvenient, so we now have a separate table for pinned
primitive arrays.

As a bonus, if GREF tracking is enabled, we will scan through the table
when a pin entry is added.  If there are 10 or more entries for the same
array, a complaint is logged.  This should allow us to find mismatched
Get/Release sequences much more easily (before you had to wait until the
global reference table exploded).

We currently scan pin table entries at the same time as the JNI global
references, so they'll still show up in hprof dumps as such.  (Could
also add a new Android-specific hprof root category, but that seems like
more trouble than it's worth.)
vm/Globals.h
vm/Jni.c