< prev index next >

src/share/vm/utilities/nativeCallStack.hpp

Print this page
rev 7876 : [mq]: nmtfix


  40  *   ....
  41  *   NativeCallStack here;
  42  *   here.print_on(tty);
  43  *   ....
  44  *
  45  * However, there are a couple of restrictions on this class. If the restrictions are
  46  * not strictly followed, it may break native memory tracking badly.
  47  *
  48  * 1. Number of stack frames to capture, is defined by native memory tracking.
  49  *    This number has impacts on how much memory to be used by native
  50  *    memory tracking.
  51  * 2. The class is strict stack object, no heap or virtual memory can be allocated
  52  *    from it.
  53  */
  54 class NativeCallStack : public StackObj {
  55  public:
  56   static const NativeCallStack EMPTY_STACK;
  57 
  58  private:
  59   address   _stack[NMT_TrackingStackDepth];
  60   int       _hash_value;
  61 
  62  public:
  63   NativeCallStack(int toSkip = 0, bool fillStack = false);
  64   NativeCallStack(address* pc, int frameCount);
  65 
  66 
  67   // if it is an empty stack
  68   inline bool is_empty() const {
  69     return _stack[0] == NULL;
  70   }
  71 
  72   // number of stack frames captured
  73   int frames() const;
  74 
  75   inline int compare(const NativeCallStack& other) const {
  76     return memcmp(_stack, other._stack, sizeof(_stack));
  77   }
  78 
  79   inline bool equals(const NativeCallStack& other) const {
  80     // compare hash values
  81     if (hash() != other.hash()) return false;
  82     // compare each frame
  83     return compare(other) == 0;
  84   }
  85 
  86   inline address get_frame(int index) const {
  87     assert(index >= 0 && index < NMT_TrackingStackDepth, "Index out of bound");
  88     return _stack[index];
  89   }
  90 
  91   // Hash code. Any better algorithm?
  92   int hash() const;
  93 
  94   void print_on(outputStream* out) const;
  95   void print_on(outputStream* out, int indent) const;
  96 };
  97 
  98 #endif


  40  *   ....
  41  *   NativeCallStack here;
  42  *   here.print_on(tty);
  43  *   ....
  44  *
  45  * However, there are a couple of restrictions on this class. If the restrictions are
  46  * not strictly followed, it may break native memory tracking badly.
  47  *
  48  * 1. Number of stack frames to capture, is defined by native memory tracking.
  49  *    This number has impacts on how much memory to be used by native
  50  *    memory tracking.
  51  * 2. The class is strict stack object, no heap or virtual memory can be allocated
  52  *    from it.
  53  */
  54 class NativeCallStack : public StackObj {
  55  public:
  56   static const NativeCallStack EMPTY_STACK;
  57 
  58  private:
  59   address       _stack[NMT_TrackingStackDepth];
  60   unsigned int  _hash_value;
  61 
  62  public:
  63   NativeCallStack(int toSkip = 0, bool fillStack = false);
  64   NativeCallStack(address* pc, int frameCount);
  65 
  66 
  67   // if it is an empty stack
  68   inline bool is_empty() const {
  69     return _stack[0] == NULL;
  70   }
  71 
  72   // number of stack frames captured
  73   int frames() const;
  74 
  75   inline int compare(const NativeCallStack& other) const {
  76     return memcmp(_stack, other._stack, sizeof(_stack));
  77   }
  78 
  79   inline bool equals(const NativeCallStack& other) const {
  80     // compare hash values
  81     if (hash() != other.hash()) return false;
  82     // compare each frame
  83     return compare(other) == 0;
  84   }
  85 
  86   inline address get_frame(int index) const {
  87     assert(index >= 0 && index < NMT_TrackingStackDepth, "Index out of bound");
  88     return _stack[index];
  89   }
  90 
  91   // Hash code. Any better algorithm?
  92   unsigned int hash() const;
  93 
  94   void print_on(outputStream* out) const;
  95   void print_on(outputStream* out, int indent) const;
  96 };
  97 
  98 #endif
< prev index next >