ART: Add allocation callback
Bug: 31684277
Test: m test-art-host
Change-Id: I959f44e23ca5fe55ed678315708895faf0aadb04
diff --git a/runtime/gc/heap-inl.h b/runtime/gc/heap-inl.h
index 83789cc..00adefb 100644
--- a/runtime/gc/heap-inl.h
+++ b/runtime/gc/heap-inl.h
@@ -19,6 +19,7 @@
#include "heap.h"
+#include "allocation_listener.h"
#include "base/time_utils.h"
#include "gc/accounting/card_table-inl.h"
#include "gc/allocation_record.h"
@@ -184,6 +185,12 @@
DCHECK(allocation_records_ != nullptr);
allocation_records_->RecordAllocation(self, &obj, bytes_allocated);
}
+ AllocationListener* l = alloc_listener_.LoadSequentiallyConsistent();
+ if (l != nullptr) {
+ // Same as above. We assume that a listener that was once stored will never be deleted.
+ // Otherwise we'd have to perform this under a lock.
+ l->ObjectAllocated(self, &obj, bytes_allocated);
+ }
} else {
DCHECK(!IsAllocTrackingEnabled());
}