Track jvmti allocations related to object tagging
Object tagging overhead can be significant. We now surface that
overhead via the jvmti-extension for memory use.
Test: ./test.py --host -j40
Bug: 62065509
Change-Id: Id0b98e74d66a1a99ac89186176ade39c922569cd
diff --git a/runtime/openjdkjvmti/ti_allocator.h b/runtime/openjdkjvmti/ti_allocator.h
index aba77ae..35575c3 100644
--- a/runtime/openjdkjvmti/ti_allocator.h
+++ b/runtime/openjdkjvmti/ti_allocator.h
@@ -36,16 +36,27 @@
#include "jvmti.h"
#include <atomic>
+#include <memory>
namespace openjdkjvmti {
+template<typename T>
+class JvmtiAllocator;
+
class AllocUtil {
public:
static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr);
static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem);
static jvmtiError GetGlobalJvmtiAllocationState(jvmtiEnv* env, jlong* total_allocated);
+
private:
+ static void DeallocateImpl(unsigned char* mem);
+ static unsigned char* AllocateImpl(jlong size);
+
static std::atomic<jlong> allocated;
+
+ template <typename T>
+ friend class JvmtiAllocator;
};
} // namespace openjdkjvmti