OSDN Git Service

Remove unprotected reads in the instance counting routines.
authorCarl Shapiro <cshapiro@google.com>
Mon, 24 Jan 2011 20:31:09 +0000 (12:31 -0800)
committerCarl Shapiro <cshapiro@google.com>
Mon, 24 Jan 2011 20:31:11 +0000 (12:31 -0800)
commita4313feb23dd454905a3297bdc9ba745e6066a16
treeeaeeaa5a2a56fc6549548eaabd1068d370903e39
parent0eac12e0b26c3cdfa3d16e73cc8d7ebd889c846b
Remove unprotected reads in the instance counting routines.

In the past, the instance counters would read the live bitmap, acquire
the heap lock, and then scan the live bitmap.  Reading the live bitmap
ahead of acquiring the heap lock gives the holder of the heap lock an
opportunity to invalidate the copy of the live bitmap read by the
instance counter routine.  For example, the garbage collector could
swap the mark and live bitmaps before releasing the heap lock.  This
change makes the read of the live bitmap safe by moving it into the
critical section.

Bug: 3271510
Change-Id: Ic02171e9ec3b4d24e83773199f00a18a75707427
vm/alloc/Alloc.c