From 7bf9f190cd33a7e2f8584299eb889e9df66e0323 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 4 Apr 2014 11:09:41 -0700 Subject: Improve invalid root dumping. The invalid root dumping now attempts to print the root type. Change-Id: Ie821296d569f34909ba6e2705f5c347cd2143a3a --- runtime/gc/collector/mark_sweep.cc | 15 ++++++++------- runtime/gc/collector/mark_sweep.h | 6 +++--- runtime/gc/heap.h | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'runtime/gc') diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index ca2d0bd..944ef8d 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -76,7 +76,7 @@ static constexpr bool kCountMarkedObjects = false; // Turn off kCheckLocks when profiling the GC since it slows the GC down by up to 40%. static constexpr bool kCheckLocks = kDebugLocking; -static constexpr bool kVerifyRoots = kIsDebugBuild; +static constexpr bool kVerifyRootsMarked = kIsDebugBuild; // If true, revoke the rosalloc thread-local buffers at the // checkpoint, as opposed to during the pause. @@ -466,16 +466,17 @@ void MarkSweep::MarkRootCallback(Object** root, void* arg, uint32_t /*thread_id* } void MarkSweep::VerifyRootCallback(const Object* root, void* arg, size_t vreg, - const StackVisitor* visitor) { - reinterpret_cast(arg)->VerifyRoot(root, vreg, visitor); + const StackVisitor* visitor, RootType root_type) { + reinterpret_cast(arg)->VerifyRoot(root, vreg, visitor, root_type); } -void MarkSweep::VerifyRoot(const Object* root, size_t vreg, const StackVisitor* visitor) { +void MarkSweep::VerifyRoot(const Object* root, size_t vreg, const StackVisitor* visitor, + RootType root_type) { // See if the root is on any space bitmap. - if (GetHeap()->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == NULL) { + if (GetHeap()->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == nullptr) { space::LargeObjectSpace* large_object_space = GetHeap()->GetLargeObjectsSpace(); if (!large_object_space->Contains(root)) { - LOG(ERROR) << "Found invalid root: " << root; + LOG(ERROR) << "Found invalid root: " << root << " with type " << root_type; if (visitor != NULL) { LOG(ERROR) << visitor->DescribeLocation() << " in VReg: " << vreg; } @@ -918,7 +919,7 @@ void MarkSweep::ReMarkRoots() { kVisitRootFlagStopLoggingNewRoots | kVisitRootFlagClearRootLog)); timings_.EndSplit(); - if (kVerifyRoots) { + if (kVerifyRootsMarked) { timings_.StartSplit("(Paused)VerifyRoots"); Runtime::Current()->VisitRoots(VerifyRootMarked, this); timings_.EndSplit(); diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h index f1fd546..d49e427 100644 --- a/runtime/gc/collector/mark_sweep.h +++ b/runtime/gc/collector/mark_sweep.h @@ -249,10 +249,10 @@ class MarkSweep : public GarbageCollector { size_t GetThreadCount(bool paused) const; static void VerifyRootCallback(const mirror::Object* root, void* arg, size_t vreg, - const StackVisitor *visitor); + const StackVisitor *visitor, RootType root_type); - void VerifyRoot(const mirror::Object* root, size_t vreg, const StackVisitor* visitor) - NO_THREAD_SAFETY_ANALYSIS; + void VerifyRoot(const mirror::Object* root, size_t vreg, const StackVisitor* visitor, + RootType root_type) NO_THREAD_SAFETY_ANALYSIS; // Push a single reference on a mark stack. void PushOnMarkStack(mirror::Object* obj); diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index ffb4e59..a8989ec 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -115,6 +115,8 @@ enum ProcessState { }; std::ostream& operator<<(std::ostream& os, const ProcessState& process_state); +std::ostream& operator<<(std::ostream& os, const RootType& root_type); + class Heap { public: // If true, measure the total allocation time. -- cgit v1.1