Global lock levels.
Introduce the notion of the mutators/GC being a shared-exclusive (aka
reader-writer) lock. Introduce globally ordered locks, analysable by
annotalysis, statically at compile time. Add locking attributes to
methods.
More subtly, remove the heap_lock_ and split between various locks that
are held for smaller periods (where work doesn't get blocked). Remove
buggy Dalvik style thread transitions. Make GC use CMS in all cases when
concurrent is enabled. Fix bug where suspend counts rather than debug
suspend counts were sent to JDWP. Move the PathClassLoader to
WellKnownClasses. In debugger refactor calls to send request and
possibly suspend. Break apart different VmWait thread states. Move
identity hash code to a shared method.
Change-Id: Icdbfc3ce3fcccd14341860ac7305d8e97b51f5c6
diff --git a/src/heap_bitmap.h b/src/heap_bitmap.h
index 4333199..98b42b3 100644
--- a/src/heap_bitmap.h
+++ b/src/heap_bitmap.h
@@ -25,13 +25,15 @@
class HeapBitmap {
public:
- bool Test(const Object* obj) {
+ bool Test(const Object* obj)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_) {
SpaceBitmap* bitmap = GetSpaceBitmap(obj);
DCHECK(bitmap != NULL);
return bitmap->Test(obj);
}
- void Clear(const Object* obj) {
+ void Clear(const Object* obj)
+ EXCLUSIVE_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_) {
SpaceBitmap* bitmap = GetSpaceBitmap(obj);
DCHECK(bitmap != NULL)
<< "tried to clear object "
@@ -40,7 +42,8 @@
return bitmap->Clear(obj);
}
- void Set(const Object* obj) {
+ void Set(const Object* obj)
+ EXCLUSIVE_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_) {
SpaceBitmap* bitmap = GetSpaceBitmap(obj);
DCHECK(bitmap != NULL)
<< "tried to mark object "
@@ -59,7 +62,8 @@
return NULL;
}
- void Walk(SpaceBitmap::Callback* callback, void* arg) {
+ void Walk(SpaceBitmap::Callback* callback, void* arg)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_) {
// TODO: C++0x auto
for (Bitmaps::iterator cur = bitmaps_.begin(); cur != bitmaps_.end(); ++cur) {
(*cur)->Walk(callback, arg);
@@ -67,7 +71,8 @@
}
// Find and replace a bitmap pointer, this is used by for the bitmap swapping in the GC.
- void ReplaceBitmap(SpaceBitmap* old_bitmap, SpaceBitmap* new_bitmap);
+ void ReplaceBitmap(SpaceBitmap* old_bitmap, SpaceBitmap* new_bitmap)
+ EXCLUSIVE_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_);
HeapBitmap(Heap* heap) : heap_(heap) {