Improve dump output.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Fri, 28 Apr 2023 09:44:08 +0000 (12:44 +0300)
committerGleb Balykov/Advanced System SW Lab /SRR/Staff Engineer/Samsung Electronics <g.balykov@samsung.com>
Mon, 22 May 2023 14:06:25 +0000 (17:06 +0300)
Prevent dump output for unused `loaded class`/`class name` related information.
Move `loaded class` metadata gathering related code execution to proper place
(will be right before dump output message forming at first usage of class).

src/info/classinfo.cpp
src/info/classinfo.h
src/trace/commontrace.cpp
src/trace/memorytrace.cpp

index 05c90ef..a6f5aa1 100644 (file)
@@ -610,6 +610,9 @@ HRESULT ClassInfo::Initialize(
         }
     }
 
+    if (this->moduleId)
+        this->needPrintLoadFinished = true;
+
     this->isInitialized = true;
     return hrReturn;
 }
index 8c35cc8..5d33d82 100644 (file)
@@ -44,7 +44,9 @@ struct ClassInfo : public MappedInfo<ClassID>
     String    arrayBrackets;
     String    fullName;
     bool      isInitialized;
+    bool      needPrintLoadFinished;
     bool      isNamePrinted;
+    HRESULT   hrStatus;
 
 public:
     static HRESULT GetClassNameFromMetaData(
index dee5a93..d433341 100644 (file)
@@ -998,14 +998,9 @@ HRESULT CommonTrace::ClassLoadFinished(
     {
         auto storage_lock = m_classStorage.lock();
         ClassInfo &classInfo = storage_lock->Get(classId);
-        hr = classInfo.Initialize(m_profiler, *storage_lock);
-
-        TRACE().DumpClassLoadFinished(classInfo, hrStatus);
-        if (!classInfo.isNamePrinted)
-        {
-            TRACE().DumpClassName(classInfo);
-            classInfo.isNamePrinted = true;
-        }
+        // Note, we don't initialize class related data here, since we will initialize it later at this class object allocation or GC related work.
+        // hrStatus - HRESULT that indicates whether the class loaded successfully, must be stored here, since it can be received in this callback only.
+        classInfo.hrStatus = hrStatus;
     }
     catch (const std::exception &e)
     {
index 46cd045..38799b3 100644 (file)
@@ -156,6 +156,11 @@ HRESULT MemoryTrace::InitAllocInfoByTypes(AllocTable &allocInfoByTypes) noexcept
             }
 
             _ASSERTE(objInfo.type != nullptr);
+            if (objInfo.type->needPrintLoadFinished)
+            {
+                TRACE().DumpClassLoadFinished(*objInfo.type, objInfo.type->hrStatus);
+                objInfo.type->needPrintLoadFinished = false;
+            }
             if (!objInfo.type->isNamePrinted)
             {
                 TRACE().DumpClassName(*objInfo.type);
@@ -204,6 +209,11 @@ HRESULT MemoryTrace::ObjectAllocated(
         }
 
         _ASSERTE(objInfo.type != nullptr);
+        if (objInfo.type->needPrintLoadFinished)
+        {
+            TRACE().DumpClassLoadFinished(*objInfo.type, objInfo.type->hrStatus);
+            objInfo.type->needPrintLoadFinished = false;
+        }
         if (!objInfo.type->isNamePrinted)
         {
             TRACE().DumpClassName(*objInfo.type);