summaryrefslogtreecommitdiffstats
path: root/runtime/gc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-04-14 18:12:13 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-14 18:12:13 +0000
commit2ff3c2cd515963ca8ba493c22a24f9e0df4f1bdd (patch)
treed30e8045c9a9d4d5f19fc40c2834cfe89d7c3edd /runtime/gc
parentec0402b0323850b5a1be2b783a7a09516772c611 (diff)
parent9086b65b2ad35dd39a8afc62d535be8217208d08 (diff)
downloadart-2ff3c2cd515963ca8ba493c22a24f9e0df4f1bdd.zip
art-2ff3c2cd515963ca8ba493c22a24f9e0df4f1bdd.tar.gz
art-2ff3c2cd515963ca8ba493c22a24f9e0df4f1bdd.tar.bz2
Merge "Fix valgrind tests"
Diffstat (limited to 'runtime/gc')
-rw-r--r--runtime/gc/collector/mark_sweep.cc26
-rw-r--r--runtime/gc/collector/mark_sweep.h3
-rw-r--r--runtime/gc/space/large_object_space.cc9
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 {