ART: Add allocation callback
Bug: 31684277
Test: m test-art-host
Change-Id: I959f44e23ca5fe55ed678315708895faf0aadb04
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 678edff..5e17a52 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -57,6 +57,7 @@
namespace gc {
+class AllocationListener;
class AllocRecordObjectMap;
class ReferenceProcessor;
class TaskProcessor;
@@ -784,6 +785,12 @@
HomogeneousSpaceCompactResult PerformHomogeneousSpaceCompact() REQUIRES(!*gc_complete_lock_);
bool SupportHomogeneousSpaceCompactAndCollectorTransitions() const;
+ // Install an allocation listener.
+ void SetAllocationListener(AllocationListener* l);
+ // Remove an allocation listener. Note: the listener must not be deleted, as for performance
+ // reasons, we assume it stays valid when we read it (so that we don't require a lock).
+ void RemoveAllocationListener();
+
private:
class ConcurrentGCTask;
class CollectorTransitionTask;
@@ -1352,6 +1359,9 @@
// Boot image spaces.
std::vector<space::ImageSpace*> boot_image_spaces_;
+ // An installed allocation listener.
+ Atomic<AllocationListener*> alloc_listener_;
+
friend class CollectorTransitionTask;
friend class collector::GarbageCollector;
friend class collector::MarkCompact;