src/share/vm/utilities/growableArray.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6973963 Sdiff src/share/vm/utilities

src/share/vm/utilities/growableArray.hpp

Print this page




  80   void   set_nesting();
  81   void   check_nesting();
  82 #else
  83 #define  set_nesting();
  84 #define  check_nesting();
  85 #endif
  86 
  87   // Where are we going to allocate memory?
  88   bool on_C_heap() { return _arena == (Arena*)1; }
  89   bool on_stack () { return _arena == NULL;      }
  90   bool on_arena () { return _arena >  (Arena*)1;  }
  91 
  92   // This GA will use the resource stack for storage if c_heap==false,
  93   // Else it will use the C heap.  Use clear_and_deallocate to avoid leaks.
  94   GenericGrowableArray(int initial_size, int initial_len, bool c_heap) {
  95     _len = initial_len;
  96     _max = initial_size;
  97     assert(_len >= 0 && _len <= _max, "initial_len too big");
  98     _arena = (c_heap ? (Arena*)1 : NULL);
  99     set_nesting();
 100     assert(!c_heap || allocated_on_C_heap(), "growable array must be on C heap if elements are");



 101   }
 102 
 103   // This GA will use the given arena for storage.
 104   // Consider using new(arena) GrowableArray<T> to allocate the header.
 105   GenericGrowableArray(Arena* arena, int initial_size, int initial_len) {
 106     _len = initial_len;
 107     _max = initial_size;
 108     assert(_len >= 0 && _len <= _max, "initial_len too big");
 109     _arena = arena;
 110     assert(on_arena(), "arena has taken on reserved value 0 or 1");




 111   }
 112 
 113   void* raw_allocate(int elementSize);
 114 
 115   // some uses pass the Thread explicitly for speed (4990299 tuning)
 116   void* raw_allocate(Thread* thread, int elementSize) {
 117     assert(on_stack(), "fast ResourceObj path only");
 118     return (void*)resource_allocate_bytes(thread, elementSize * _max);
 119   }
 120 };
 121 
 122 template<class E> class GrowableArray : public GenericGrowableArray {
 123  private:
 124   E*     _data;         // data array
 125 
 126   void grow(int j);
 127   void raw_at_put_grow(int i, const E& p, const E& fill);
 128   void  clear_and_deallocate();
 129  public:
 130   GrowableArray(Thread* thread, int initial_size) : GenericGrowableArray(initial_size, 0, false) {




  80   void   set_nesting();
  81   void   check_nesting();
  82 #else
  83 #define  set_nesting();
  84 #define  check_nesting();
  85 #endif
  86 
  87   // Where are we going to allocate memory?
  88   bool on_C_heap() { return _arena == (Arena*)1; }
  89   bool on_stack () { return _arena == NULL;      }
  90   bool on_arena () { return _arena >  (Arena*)1;  }
  91 
  92   // This GA will use the resource stack for storage if c_heap==false,
  93   // Else it will use the C heap.  Use clear_and_deallocate to avoid leaks.
  94   GenericGrowableArray(int initial_size, int initial_len, bool c_heap) {
  95     _len = initial_len;
  96     _max = initial_size;
  97     assert(_len >= 0 && _len <= _max, "initial_len too big");
  98     _arena = (c_heap ? (Arena*)1 : NULL);
  99     set_nesting();
 100     assert(!on_C_heap() || allocated_on_C_heap(), "growable array must be on C heap if elements are");
 101     assert(!on_stack() ||
 102            (allocated_on_res_area() || allocated_on_stack()),
 103            "growable array must be on stack if elements are not on arena and not on C heap");
 104   }
 105 
 106   // This GA will use the given arena for storage.
 107   // Consider using new(arena) GrowableArray<T> to allocate the header.
 108   GenericGrowableArray(Arena* arena, int initial_size, int initial_len) {
 109     _len = initial_len;
 110     _max = initial_size;
 111     assert(_len >= 0 && _len <= _max, "initial_len too big");
 112     _arena = arena;
 113     assert(on_arena(), "arena has taken on reserved value 0 or 1");
 114     // Relax next assert to allow object allocation on resource area,
 115     // on stack or embedded into an other object.
 116     assert(allocated_on_arena() || allocated_on_stack(),
 117            "growable array must be on arena or on stack if elements are on arena");
 118   }
 119 
 120   void* raw_allocate(int elementSize);
 121 
 122   // some uses pass the Thread explicitly for speed (4990299 tuning)
 123   void* raw_allocate(Thread* thread, int elementSize) {
 124     assert(on_stack(), "fast ResourceObj path only");
 125     return (void*)resource_allocate_bytes(thread, elementSize * _max);
 126   }
 127 };
 128 
 129 template<class E> class GrowableArray : public GenericGrowableArray {
 130  private:
 131   E*     _data;         // data array
 132 
 133   void grow(int j);
 134   void raw_at_put_grow(int i, const E& p, const E& fill);
 135   void  clear_and_deallocate();
 136  public:
 137   GrowableArray(Thread* thread, int initial_size) : GenericGrowableArray(initial_size, 0, false) {


src/share/vm/utilities/growableArray.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File