Visit image roots for hprof
Bug: 19995360
(cherry picked from commit 0cab5e68f14ee403380664146db6dc7ddfc32064)
Change-Id: I17868bff2a701dc25291d41b9732c6b86f92be08
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 23a7db6..b5d2e15 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -62,7 +62,7 @@
#include "gc/accounting/card_table-inl.h"
#include "gc/heap.h"
#include "gc/space/image_space.h"
-#include "gc/space/space.h"
+#include "gc/space/space-inl.h"
#include "handle_scope-inl.h"
#include "image.h"
#include "instrumentation.h"
@@ -1355,6 +1355,23 @@
VisitConcurrentRoots(callback, arg, flags);
}
+void Runtime::VisitImageRoots(RootCallback* callback, void* arg) {
+ for (auto* space : GetHeap()->GetContinuousSpaces()) {
+ if (space->IsImageSpace()) {
+ auto* image_space = space->AsImageSpace();
+ const auto& image_header = image_space->GetImageHeader();
+ for (size_t i = 0; i < ImageHeader::kImageRootsMax; ++i) {
+ auto* obj = image_header.GetImageRoot(static_cast<ImageHeader::ImageRoot>(i));
+ if (obj != nullptr) {
+ auto* after_obj = obj;
+ callback(&after_obj, arg, RootInfo(kRootStickyClass));
+ CHECK_EQ(after_obj, obj);
+ }
+ }
+ }
+ }
+}
+
mirror::ObjectArray<mirror::ArtMethod>* Runtime::CreateDefaultImt(ClassLinker* cl) {
Thread* self = Thread::Current();
StackHandleScope<1> hs(self);