Profiler.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <stdint.h>
  3. #include "il2cpp-config.h"
  4. namespace il2cpp
  5. {
  6. namespace vm
  7. {
  8. #if IL2CPP_ENABLE_PROFILER
  9. class LIBIL2CPP_CODEGEN_API Profiler
  10. {
  11. // exported
  12. public:
  13. static void Install(Il2CppProfiler *prof, Il2CppProfileFunc shutdownCallback);
  14. static void SetEvents(Il2CppProfileFlags events);
  15. static void InstallEnterLeave(Il2CppProfileMethodFunc enter, Il2CppProfileMethodFunc fleave);
  16. static void InstallAllocation(Il2CppProfileAllocFunc callback);
  17. static void InstallGC(Il2CppProfileGCFunc callback, Il2CppProfileGCResizeFunc heap_resize_callback);
  18. static void InstallFileIO(Il2CppProfileFileIOFunc callback);
  19. static void InstallThread(Il2CppProfileThreadFunc start, Il2CppProfileThreadFunc end);
  20. // internal
  21. public:
  22. static void Allocation(Il2CppObject *obj, Il2CppClass *klass);
  23. static void MethodEnter(const MethodInfo *method);
  24. static void MethodExit(const MethodInfo *method);
  25. static void GCEvent(Il2CppGCEvent eventType);
  26. static void GCHeapResize(int64_t newSize);
  27. static void FileIO(Il2CppProfileFileIOKind kind, int count);
  28. static void ThreadStart(unsigned long tid);
  29. static void ThreadEnd(unsigned long tid);
  30. static Il2CppProfileFlags s_profilerEvents;
  31. static inline bool ProfileAllocations()
  32. {
  33. return (s_profilerEvents & IL2CPP_PROFILE_ALLOCATIONS) != 0;
  34. }
  35. static inline bool ProfileFileIO()
  36. {
  37. return (s_profilerEvents & IL2CPP_PROFILE_FILEIO) != 0;
  38. }
  39. static void Shutdown();
  40. private:
  41. };
  42. #endif
  43. } /* namespace vm */
  44. } /* namespace il2cpp */