Add VMDebug.getInstancesOfClasses API.
The API can be used to iterate over instances of a given type on the
heap.
The GetInstancesOfClassesBenchmark run on bullhead shows the run time
of the API grows linearly in the number of classes, C, to get instances
of and the number of total instances, N, allocated on the heap.
C N=~2^18 N=~2^19
1 13ms 21ms
2 26ms 43ms
4 53ms 87ms
Bug: 69729799
Test: ./test/testrunner/testrunner.py -t 099-vmdebug -b --host
Change-Id: Ied053d19760e656012e2577776f75a1cc0a14ac3
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 1dcd935..13029fb 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -963,7 +963,11 @@
}
VariableSizedHandleScope hs(Thread::Current());
std::vector<Handle<mirror::Object>> raw_instances;
- Runtime::Current()->GetHeap()->GetInstances(hs, hs.NewHandle(c), max_count, raw_instances);
+ Runtime::Current()->GetHeap()->GetInstances(hs,
+ hs.NewHandle(c),
+ /* use_is_assignable_from */ false,
+ max_count,
+ raw_instances);
for (size_t i = 0; i < raw_instances.size(); ++i) {
instances->push_back(gRegistry->Add(raw_instances[i].Get()));
}