8210246: NMTUtil::_memory_type_names should be in sync with MemoryType
authoriklam
Sat, 01 Sep 2018 12:02:07 -0700
changeset 51617 9720ad0a40b6
parent 51616 b071f4fff1f1
child 51618 54b344d9dd4e
8210246: NMTUtil::_memory_type_names should be in sync with MemoryType Reviewed-by: ccheung, jiangli, coleenp
src/hotspot/share/memory/allocation.hpp
src/hotspot/share/services/nmtCommon.cpp
--- a/src/hotspot/share/memory/allocation.hpp	Sat Sep 01 18:15:27 2018 +0200
+++ b/src/hotspot/share/memory/allocation.hpp	Sat Sep 01 12:02:07 2018 -0700
@@ -107,34 +107,40 @@
 };
 #endif
 
+#define MEMORY_TYPES_DO(f) \
+  /* Memory type by sub systems. It occupies lower byte. */  \
+  f(mtJavaHeap,      "Java Heap")   /* Java heap                                 */ \
+  f(mtClass,         "Class")       /* Java classes                              */ \
+  f(mtThread,        "Thread")      /* thread objects                            */ \
+  f(mtThreadStack,   "Thread Stack")                                                \
+  f(mtCode,          "Code")        /* generated code                            */ \
+  f(mtGC,            "GC")                                                          \
+  f(mtCompiler,      "Compiler")                                                    \
+  f(mtInternal,      "Internal")    /* memory used by VM, but does not belong to */ \
+                                    /* any of above categories, and not used by  */ \
+                                    /* NMT                                       */ \
+  f(mtOther,         "Other")       /* memory not used by VM                     */ \
+  f(mtSymbol,        "Symbol")                                                      \
+  f(mtNMT,           "Native Memory Tracking")  /* memory used by NMT            */ \
+  f(mtClassShared,   "Shared class space")      /* class data sharing            */ \
+  f(mtChunk,         "Arena Chunk") /* chunk that holds content of arenas        */ \
+  f(mtTest,          "Test")        /* Test type for verifying NMT               */ \
+  f(mtTracing,       "Tracing")                                                     \
+  f(mtLogging,       "Logging")                                                     \
+  f(mtArguments,     "Arguments")                                                   \
+  f(mtModule,        "Module")                                                      \
+  f(mtSafepoint,     "Safepoint")                                                   \
+  f(mtNone,          "Unknown")                                                     \
+  //end
+
+#define MEMORY_TYPE_DECLARE_ENUM(type, human_readable) \
+  type,
 
 /*
  * Memory types
  */
 enum MemoryType {
-  // Memory type by sub systems. It occupies lower byte.
-  mtJavaHeap,          // Java heap
-  mtClass,             // memory class for Java classes
-  mtThread,            // memory for thread objects
-  mtThreadStack,
-  mtCode,              // memory for generated code
-  mtGC,                // memory for GC
-  mtCompiler,          // memory for compiler
-  mtInternal,          // memory used by VM, but does not belong to
-                       // any of above categories, and not used for
-                       // native memory tracking
-  mtOther,             // memory not used by VM
-  mtSymbol,            // symbol
-  mtNMT,               // memory used by native memory tracking
-  mtClassShared,       // class data sharing
-  mtChunk,             // chunk that holds content of arenas
-  mtTest,              // Test type for verifying NMT
-  mtTracing,           // memory used for Tracing
-  mtLogging,           // memory for logging
-  mtArguments,         // memory for argument processing
-  mtModule,            // memory for module processing
-  mtSafepoint,         // memory for safepoint support
-  mtNone,              // undefined
+  MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM)
   mt_number_of_types   // number of memory types (mtDontTrack
                        // is not included as validate type)
 };
--- a/src/hotspot/share/services/nmtCommon.cpp	Sat Sep 01 18:15:27 2018 +0200
+++ b/src/hotspot/share/services/nmtCommon.cpp	Sat Sep 01 12:02:07 2018 -0700
@@ -25,27 +25,11 @@
 #include "services/nmtCommon.hpp"
 #include "utilities/globalDefinitions.hpp"
 
+#define MEMORY_TYPE_DECLARE_NAME(type, human_readable) \
+  #human_readable,
+
 const char* NMTUtil::_memory_type_names[] = {
-  "Java Heap",
-  "Class",
-  "Thread",
-  "Thread Stack",
-  "Code",
-  "GC",
-  "Compiler",
-  "Internal",
-  "Other",
-  "Symbol",
-  "Native Memory Tracking",
-  "Shared class space",
-  "Arena Chunk",
-  "Test",
-  "Tracing",
-  "Logging",
-  "Arguments",
-  "Module",
-  "Safepoint",
-  "Unknown"
+  MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_NAME)
 };