diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-04-14 09:35:18 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-04-14 11:06:34 -0700 |
commit | 9086b65b2ad35dd39a8afc62d535be8217208d08 (patch) | |
tree | 3abc6e3297b840289bc240e3a9bc7e61b7a99cbc /runtime/gc | |
parent | 8d20011a9de7cd94bee59db3ae8c0cbbf55911d9 (diff) | |
download | art-9086b65b2ad35dd39a8afc62d535be8217208d08.zip art-9086b65b2ad35dd39a8afc62d535be8217208d08.tar.gz art-9086b65b2ad35dd39a8afc62d535be8217208d08.tar.bz2 |
Fix valgrind tests
Delete large objects in space destructor. Also some cleanup.
Change-Id: I4c4e90149841a156b7a3236201b37683e14890fb
Diffstat (limited to 'runtime/gc')
-rw-r--r-- | runtime/gc/collector/mark_sweep.cc | 26 | ||||
-rw-r--r-- | runtime/gc/collector/mark_sweep.h | 3 | ||||
-rw-r--r-- | runtime/gc/space/large_object_space.cc | 9 |
3 files changed, 18 insertions, 20 deletions
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index ed2e295..bb8d876 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -490,29 +490,21 @@ void MarkSweep::VisitRoots(mirror::CompressedReference<mirror::Object>** roots, class VerifyRootVisitor : public SingleRootVisitor { public: - explicit VerifyRootVisitor(MarkSweep* collector) : collector_(collector) { } - void VisitRoot(mirror::Object* root, const RootInfo& info) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_) { - collector_->VerifyRoot(root, info); - } - - private: - MarkSweep* const collector_; -}; - -void MarkSweep::VerifyRoot(const Object* root, const RootInfo& root_info) { - // See if the root is on any space bitmap. - if (heap_->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == nullptr) { - space::LargeObjectSpace* large_object_space = GetHeap()->GetLargeObjectsSpace(); - if (large_object_space != nullptr && !large_object_space->Contains(root)) { - LOG(ERROR) << "Found invalid root: " << root << " " << root_info; + // See if the root is on any space bitmap. + auto* heap = Runtime::Current()->GetHeap(); + if (heap->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == nullptr) { + space::LargeObjectSpace* large_object_space = heap->GetLargeObjectsSpace(); + if (large_object_space != nullptr && !large_object_space->Contains(root)) { + LOG(ERROR) << "Found invalid root: " << root << " " << info; + } } } -} +}; void MarkSweep::VerifyRoots() { - VerifyRootVisitor visitor(this); + VerifyRootVisitor visitor; Runtime::Current()->GetThreadList()->VisitRoots(&visitor); } diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h index 31cea17..fad3403 100644 --- a/runtime/gc/collector/mark_sweep.h +++ b/runtime/gc/collector/mark_sweep.h @@ -248,9 +248,6 @@ class MarkSweep : public GarbageCollector { // whether or not we care about pauses. size_t GetThreadCount(bool paused) const; - void VerifyRoot(const mirror::Object* root, const RootInfo& root_info) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_); - // Push a single reference on a mark stack. void PushOnMarkStack(mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc index 5c8e4b9..a4a9d80 100644 --- a/runtime/gc/space/large_object_space.cc +++ b/runtime/gc/space/large_object_space.cc @@ -37,6 +37,15 @@ class ValgrindLargeObjectMapSpace FINAL : public LargeObjectMapSpace { explicit ValgrindLargeObjectMapSpace(const std::string& name) : LargeObjectMapSpace(name) { } + ~ValgrindLargeObjectMapSpace() OVERRIDE { + // Keep valgrind happy if there is any large objects such as dex cache arrays which aren't + // freed since they are held live by the class linker. + MutexLock mu(Thread::Current(), lock_); + for (auto& m : mem_maps_) { + delete m.second; + } + } + virtual mirror::Object* Alloc(Thread* self, size_t num_bytes, size_t* bytes_allocated, size_t* usable_size, size_t* bytes_tl_bulk_allocated) OVERRIDE { |