1.1 --- a/src/share/vm/utilities/stack.hpp Wed Jun 27 15:23:36 2012 +0200 1.2 +++ b/src/share/vm/utilities/stack.hpp Thu Jun 28 17:03:16 2012 -0400 1.3 @@ -25,6 +25,7 @@ 1.4 #ifndef SHARE_VM_UTILITIES_STACK_HPP 1.5 #define SHARE_VM_UTILITIES_STACK_HPP 1.6 1.7 +#include "memory/allocation.hpp" 1.8 #include "memory/allocation.inline.hpp" 1.9 1.10 // Class Stack (below) grows and shrinks by linking together "segments" which 1.11 @@ -51,11 +52,11 @@ 1.12 // implementation in class Stack assumes that alloc() will terminate the process 1.13 // if the allocation fails. 1.14 1.15 -template <class E> class StackIterator; 1.16 +template <class E, MEMFLAGS F> class StackIterator; 1.17 1.18 // StackBase holds common data/methods that don't depend on the element type, 1.19 // factored out to reduce template code duplication. 1.20 -class StackBase 1.21 +template <MEMFLAGS F> class StackBase 1.22 { 1.23 public: 1.24 size_t segment_size() const { return _seg_size; } // Elements per segment. 1.25 @@ -89,11 +90,11 @@ 1.26 #define inline 1.27 #endif // __GNUC__ 1.28 1.29 -template <class E> 1.30 -class Stack: public StackBase 1.31 +template <class E, MEMFLAGS F> 1.32 +class Stack: public StackBase<F> 1.33 { 1.34 public: 1.35 - friend class StackIterator<E>; 1.36 + friend class StackIterator<E, F>; 1.37 1.38 // segment_size: number of items per segment 1.39 // max_cache_size: maxmium number of *segments* to cache 1.40 @@ -103,15 +104,15 @@ 1.41 size_t max_cache_size = 4, size_t max_size = 0); 1.42 inline ~Stack() { clear(true); } 1.43 1.44 - inline bool is_empty() const { return _cur_seg == NULL; } 1.45 - inline bool is_full() const { return _full_seg_size >= max_size(); } 1.46 + inline bool is_empty() const { return this->_cur_seg == NULL; } 1.47 + inline bool is_full() const { return this->_full_seg_size >= this->max_size(); } 1.48 1.49 // Performance sensitive code should use is_empty() instead of size() == 0 and 1.50 // is_full() instead of size() == max_size(). Using a conditional here allows 1.51 // just one var to be updated when pushing/popping elements instead of two; 1.52 // _full_seg_size is updated only when pushing/popping segments. 1.53 inline size_t size() const { 1.54 - return is_empty() ? 0 : _full_seg_size + _cur_seg_size; 1.55 + return is_empty() ? 0 : this->_full_seg_size + this->_cur_seg_size; 1.56 } 1.57 1.58 inline void push(E elem); 1.59 @@ -161,18 +162,18 @@ 1.60 E* _cache; // Segment cache to avoid ping-ponging. 1.61 }; 1.62 1.63 -template <class E> class ResourceStack: public Stack<E>, public ResourceObj 1.64 +template <class E, MEMFLAGS F> class ResourceStack: public Stack<E, F>, public ResourceObj 1.65 { 1.66 public: 1.67 // If this class becomes widely used, it may make sense to save the Thread 1.68 // and use it when allocating segments. 1.69 - ResourceStack(size_t segment_size = Stack<E>::default_segment_size()): 1.70 - Stack<E>(segment_size, max_uintx) 1.71 +// ResourceStack(size_t segment_size = Stack<E, F>::default_segment_size()): 1.72 + ResourceStack(size_t segment_size): Stack<E, F>(segment_size, max_uintx) 1.73 { } 1.74 1.75 // Set the segment pointers to NULL so the parent dtor does not free them; 1.76 // that must be done by the ResourceMark code. 1.77 - ~ResourceStack() { Stack<E>::reset(true); } 1.78 + ~ResourceStack() { Stack<E, F>::reset(true); } 1.79 1.80 protected: 1.81 virtual E* alloc(size_t bytes); 1.82 @@ -182,13 +183,13 @@ 1.83 void clear(bool clear_cache = false); 1.84 }; 1.85 1.86 -template <class E> 1.87 +template <class E, MEMFLAGS F> 1.88 class StackIterator: public StackObj 1.89 { 1.90 public: 1.91 - StackIterator(Stack<E>& stack): _stack(stack) { sync(); } 1.92 + StackIterator(Stack<E, F>& stack): _stack(stack) { sync(); } 1.93 1.94 - Stack<E>& stack() const { return _stack; } 1.95 + Stack<E, F>& stack() const { return _stack; } 1.96 1.97 bool is_empty() const { return _cur_seg == NULL; } 1.98 1.99 @@ -198,7 +199,7 @@ 1.100 void sync(); // Sync the iterator's state to the stack's current state. 1.101 1.102 private: 1.103 - Stack<E>& _stack; 1.104 + Stack<E, F>& _stack; 1.105 size_t _cur_seg_size; 1.106 E* _cur_seg; 1.107 size_t _full_seg_size;