ClassInlines.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. //This file should not include anything from VM. This is included by both libil2cpp and the codegen headers
  3. #include "il2cpp-config.h"
  4. #include "il2cpp-class-internals.h"
  5. #include "il2cpp-object-internals.h"
  6. namespace il2cpp
  7. {
  8. namespace vm
  9. {
  10. class LIBIL2CPP_CODEGEN_API ClassInlines
  11. {
  12. public:
  13. // we assume that the Il2CppClass's have already been initialized in this case, like in code generation
  14. static inline bool HasParentUnsafe(const Il2CppClass* klass, const Il2CppClass* parent) { return klass->typeHierarchyDepth >= parent->typeHierarchyDepth && klass->typeHierarchy[parent->typeHierarchyDepth - 1] == parent; }
  15. // This function is critical for performance, before optimization it
  16. // caused up to 20% of all CPU usage in code generated by il2cpp
  17. static IL2CPP_FORCE_INLINE Il2CppClass* InitFromCodegen(Il2CppClass *klass)
  18. {
  19. if (klass->initialized_and_no_error)
  20. return klass;
  21. return InitFromCodegenSlow(klass);
  22. }
  23. static IL2CPP_FORCE_INLINE const MethodInfo* InitRgcxFromCodegen(const MethodInfo *method)
  24. {
  25. if (method->rgctx_data)
  26. return method;
  27. return InitRgctxFromCodegenSlow(method);
  28. }
  29. static IL2CPP_NO_INLINE Il2CppClass* InitFromCodegenSlow(Il2CppClass *klass);
  30. static IL2CPP_NO_INLINE Il2CppClass* InitFromCodegenSlow(Il2CppClass *klass, bool throwOnError);
  31. static IL2CPP_NO_INLINE const MethodInfo* InitRgctxFromCodegenSlow(const MethodInfo* method);
  32. static IL2CPP_NO_INLINE const VirtualInvokeData& GetVirtualInvokeData(Il2CppMethodSlot slot, const Il2CppObject* obj);
  33. //internal
  34. static IL2CPP_NO_INLINE const VirtualInvokeData& GetInterfaceInvokeDataFromVTable(Il2CppObject* obj,const Il2CppClass* itf, Il2CppMethodSlot slot);
  35. static IL2CPP_NO_INLINE const VirtualInvokeData* GetInterfaceInvokeDataFromVTable(Il2CppClass* klass, const Il2CppClass* itf, Il2CppMethodSlot slot);
  36. // we don't want this method to get inlined because that makes GetInterfaceInvokeDataFromVTable method itself very large and performance suffers
  37. static IL2CPP_NO_INLINE const VirtualInvokeData& GetInterfaceInvokeDataFromVTableSlowPath(Il2CppObject* obj, const Il2CppClass* itf, Il2CppMethodSlot slot);
  38. static IL2CPP_NO_INLINE const VirtualInvokeData* GetInterfaceInvokeDataFromVTableSlowPath(const Il2CppClass* klass, const Il2CppClass* itf, Il2CppMethodSlot slot);
  39. static IL2CPP_NO_INLINE bool HasParent(const Il2CppClass* klass, const Il2CppClass* parent);
  40. };
  41. }
  42. }