diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2014-03-31 15:14:47 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2014-03-31 17:40:21 -0700 |
commit | 624468cd401cc1ac0dd70c746301e0788a597759 (patch) | |
tree | b21c389d43e25c3d95208c9d2f3f1bc81355a4e5 /runtime/gc | |
parent | cfd5acf281b0c509f86b13d73c6a8dfa3ea9922c (diff) | |
download | art-624468cd401cc1ac0dd70c746301e0788a597759.zip art-624468cd401cc1ac0dd70c746301e0788a597759.tar.gz art-624468cd401cc1ac0dd70c746301e0788a597759.tar.bz2 |
Make the support code for read barriers a bit more general.
Add an option for Baker in addition to Brooks.
Bug: 12687968
Change-Id: I8a31db817ff6686c72951b6534f588228e270b11
Diffstat (limited to 'runtime/gc')
-rw-r--r-- | runtime/gc/collector/mark_sweep.cc | 12 | ||||
-rw-r--r-- | runtime/gc/collector/semi_space-inl.h | 4 | ||||
-rw-r--r-- | runtime/gc/collector/semi_space.cc | 12 | ||||
-rw-r--r-- | runtime/gc/heap-inl.h | 8 | ||||
-rw-r--r-- | runtime/gc/heap.cc | 12 | ||||
-rw-r--r-- | runtime/gc/space/image_space.cc | 6 | ||||
-rw-r--r-- | runtime/gc/space/space_test.h | 4 |
7 files changed, 31 insertions, 27 deletions
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 91ccd64..ca2d0bd 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -343,9 +343,9 @@ void MarkSweep::MarkHeapReferenceCallback(mirror::HeapReference<mirror::Object>* inline void MarkSweep::MarkObjectNonNull(Object* obj) { DCHECK(obj != nullptr); - if (kUseBrooksPointer) { - // Verify all the objects have the correct Brooks pointer installed. - obj->AssertSelfBrooksPointer(); + if (kUseBakerOrBrooksReadBarrier) { + // Verify all the objects have the correct pointer installed. + obj->AssertReadBarrierPointer(); } if (immune_region_.ContainsObject(obj)) { if (kCountMarkedObjects) { @@ -415,9 +415,9 @@ bool MarkSweep::MarkLargeObject(const Object* obj, bool set) { inline bool MarkSweep::MarkObjectParallel(const Object* obj) { DCHECK(obj != nullptr); - if (kUseBrooksPointer) { - // Verify all the objects have the correct Brooks pointer installed. - obj->AssertSelfBrooksPointer(); + if (kUseBakerOrBrooksReadBarrier) { + // Verify all the objects have the correct pointer installed. + obj->AssertReadBarrierPointer(); } if (immune_region_.ContainsObject(obj)) { DCHECK(IsMarked(obj)); diff --git a/runtime/gc/collector/semi_space-inl.h b/runtime/gc/collector/semi_space-inl.h index d60298b..df731ff 100644 --- a/runtime/gc/collector/semi_space-inl.h +++ b/runtime/gc/collector/semi_space-inl.h @@ -45,9 +45,9 @@ inline void SemiSpace::MarkObject( if (obj == nullptr) { return; } - if (kUseBrooksPointer) { + if (kUseBakerOrBrooksReadBarrier) { // Verify all the objects have the correct forward pointer installed. - obj->AssertSelfBrooksPointer(); + obj->AssertReadBarrierPointer(); } if (!immune_region_.ContainsObject(obj)) { if (from_space_->HasAddress(obj)) { diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc index 222bd63..1366858 100644 --- a/runtime/gc/collector/semi_space.cc +++ b/runtime/gc/collector/semi_space.cc @@ -561,11 +561,13 @@ mirror::Object* SemiSpace::MarkNonForwardedObject(mirror::Object* obj) { // references. saved_bytes_ += CopyAvoidingDirtyingPages(reinterpret_cast<void*>(forward_address), obj, object_size); - if (kUseBrooksPointer) { - obj->AssertSelfBrooksPointer(); - DCHECK_EQ(forward_address->GetBrooksPointer(), obj); - forward_address->SetBrooksPointer(forward_address); - forward_address->AssertSelfBrooksPointer(); + if (kUseBakerOrBrooksReadBarrier) { + obj->AssertReadBarrierPointer(); + if (kUseBrooksReadBarrier) { + DCHECK_EQ(forward_address->GetReadBarrierPointer(), obj); + forward_address->SetReadBarrierPointer(forward_address); + } + forward_address->AssertReadBarrierPointer(); } if (to_space_live_bitmap_ != nullptr) { to_space_live_bitmap_->Set(forward_address); diff --git a/runtime/gc/heap-inl.h b/runtime/gc/heap-inl.h index 8bfe793..25f20d6 100644 --- a/runtime/gc/heap-inl.h +++ b/runtime/gc/heap-inl.h @@ -73,9 +73,11 @@ inline mirror::Object* Heap::AllocObjectWithAllocator(Thread* self, mirror::Clas DCHECK_GT(bytes_allocated, 0u); DCHECK_GT(usable_size, 0u); obj->SetClass(klass); - if (kUseBrooksPointer) { - obj->SetBrooksPointer(obj); - obj->AssertSelfBrooksPointer(); + if (kUseBakerOrBrooksReadBarrier) { + if (kUseBrooksReadBarrier) { + obj->SetReadBarrierPointer(obj); + } + obj->AssertReadBarrierPointer(); } if (collector::SemiSpace::kUseRememberedSet && UNLIKELY(allocator == kAllocatorTypeNonMoving)) { // (Note this if statement will be constant folded away for the diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 1a32a9a..bc50668 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -1605,11 +1605,13 @@ class ZygoteCompactingCollector FINAL : public collector::SemiSpace { } // Copy the object over to its new location. memcpy(reinterpret_cast<void*>(forward_address), obj, object_size); - if (kUseBrooksPointer) { - obj->AssertSelfBrooksPointer(); - DCHECK_EQ(forward_address->GetBrooksPointer(), obj); - forward_address->SetBrooksPointer(forward_address); - forward_address->AssertSelfBrooksPointer(); + if (kUseBakerOrBrooksReadBarrier) { + obj->AssertReadBarrierPointer(); + if (kUseBrooksReadBarrier) { + DCHECK_EQ(forward_address->GetReadBarrierPointer(), obj); + forward_address->SetReadBarrierPointer(forward_address); + } + forward_address->AssertReadBarrierPointer(); } return forward_address; } diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index bb52c66..9a2815a 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -166,10 +166,8 @@ void ImageSpace::VerifyImageAllocations() { mirror::Object* obj = reinterpret_cast<mirror::Object*>(current); CHECK(live_bitmap_->Test(obj)); CHECK(obj->GetClass() != nullptr) << "Image object at address " << obj << " has null class"; - if (kUseBrooksPointer) { - CHECK(obj->GetBrooksPointer() == obj) - << "Bad Brooks pointer: obj=" << reinterpret_cast<void*>(obj) - << " brooks_ptr=" << reinterpret_cast<void*>(obj->GetBrooksPointer()); + if (kUseBakerOrBrooksReadBarrier) { + obj->AssertReadBarrierPointer(); } current += RoundUp(obj->SizeOf(), kObjectAlignment); } diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h index 6d3602c..5c735df 100644 --- a/runtime/gc/space/space_test.h +++ b/runtime/gc/space/space_test.h @@ -85,8 +85,8 @@ class SpaceTest : public CommonRuntimeTest { EXPECT_GE(size, SizeOfZeroLengthByteArray()); EXPECT_TRUE(byte_array_class != nullptr); o->SetClass(byte_array_class); - if (kUseBrooksPointer) { - o->SetBrooksPointer(o); + if (kUseBrooksReadBarrier) { + o->SetReadBarrierPointer(o); } mirror::Array* arr = o->AsArray<kVerifyNone>(); size_t header_size = SizeOfZeroLengthByteArray(); |