< prev index next >

src/share/vm/services/nmtCommon.hpp

Print this page
rev 12121 : 8167650: NMT should check for invalid MEMFLAGS
Reviewed-by:

@@ -53,20 +53,23 @@
 // A few common utilities for native memory tracking
 class NMTUtil : AllStatic {
  public:
   // Map memory type to index
   static inline int flag_to_index(MEMFLAGS flag) {
+    assert(flag >= 0 && flag < mt_number_of_types, "Invalid flag value %d.", (int)flag);
     return (flag & 0xff);
   }
 
   // Map memory type to human readable name
   static const char* flag_to_name(MEMFLAGS flag) {
+    assert(flag >= 0 && flag < mt_number_of_types, "Invalid flag value %d.", (int)flag);
     return _memory_type_names[flag_to_index(flag)];
   }
 
   // Map an index to memory type
   static MEMFLAGS index_to_flag(int index) {
+    assert(index >= 0 && index < (int) mt_number_of_types, "Invalid index value %d.", index);
     return (MEMFLAGS)index;
   }
 
   // Memory size scale
   static const char* scale_name(size_t scale);
< prev index next >