< prev index next >

src/share/vm/services/nmtCommon.hpp

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


  43   NMT_off     = 0x00,
  44   NMT_minimal = 0x01,
  45   NMT_summary = 0x02,
  46   NMT_detail  = 0x03
  47 };
  48 
  49 // Number of stack frames to capture. This is a
  50 // build time decision.
  51 const int NMT_TrackingStackDepth = 4;
  52 
  53 // A few common utilities for native memory tracking
  54 class NMTUtil : AllStatic {
  55  public:
  56   // Map memory type to index
  57   static inline int flag_to_index(MEMFLAGS flag) {
  58     return (flag & 0xff);
  59   }
  60 
  61   // Map memory type to human readable name
  62   static const char* flag_to_name(MEMFLAGS flag) {
  63     return _memory_type_names[flag_to_index(flag)];


  64   }
  65 
  66   // Map an index to memory type
  67   static MEMFLAGS index_to_flag(int index) {

  68     return (MEMFLAGS)index;
  69   }
  70 
  71   // Memory size scale
  72   static const char* scale_name(size_t scale);
  73   static size_t scale_from_name(const char* scale);
  74 
  75   // Translate memory size in specified scale
  76   static size_t amount_in_scale(size_t amount, size_t scale) {
  77     return (amount + scale / 2) / scale;
  78   }
  79  private:
  80   static const char* _memory_type_names[mt_number_of_types];
  81 };
  82 
  83 
  84 #endif


  43   NMT_off     = 0x00,
  44   NMT_minimal = 0x01,
  45   NMT_summary = 0x02,
  46   NMT_detail  = 0x03
  47 };
  48 
  49 // Number of stack frames to capture. This is a
  50 // build time decision.
  51 const int NMT_TrackingStackDepth = 4;
  52 
  53 // A few common utilities for native memory tracking
  54 class NMTUtil : AllStatic {
  55  public:
  56   // Map memory type to index
  57   static inline int flag_to_index(MEMFLAGS flag) {
  58     return (flag & 0xff);
  59   }
  60 
  61   // Map memory type to human readable name
  62   static const char* flag_to_name(MEMFLAGS flag) {
  63     int index = flag_to_index(flag);
  64     assert(index >= 0 && index < mt_number_of_types, "Index out of bound.");
  65     return _memory_type_names[index];
  66   }
  67 
  68   // Map an index to memory type
  69   static MEMFLAGS index_to_flag(int index) {
  70     assert(index >= 0 && index < mt_number_of_types, "Index out of bound.");
  71     return (MEMFLAGS)index;
  72   }
  73 
  74   // Memory size scale
  75   static const char* scale_name(size_t scale);
  76   static size_t scale_from_name(const char* scale);
  77 
  78   // Translate memory size in specified scale
  79   static size_t amount_in_scale(size_t amount, size_t scale) {
  80     return (amount + scale / 2) / scale;
  81   }
  82  private:
  83   static const char* _memory_type_names[mt_number_of_types];
  84 };
  85 
  86 
  87 #endif
< prev index next >