src/share/vm/utilities/growableArray.hpp

changeset 3900
d2a62e0f25eb
parent 3651
ee138854b3a6
child 4037
da91efe96a93
     1.1 --- a/src/share/vm/utilities/growableArray.hpp	Wed Jun 27 15:23:36 2012 +0200
     1.2 +++ b/src/share/vm/utilities/growableArray.hpp	Thu Jun 28 17:03:16 2012 -0400
     1.3 @@ -86,6 +86,9 @@
     1.4                          //   0 means default ResourceArea
     1.5                          //   1 means on C heap
     1.6                          //   otherwise, allocate in _arena
     1.7 +
     1.8 +  MEMFLAGS   _memflags;   // memory type if allocation in C heap
     1.9 +
    1.10  #ifdef ASSERT
    1.11    int    _nesting;      // resource area nesting at creation
    1.12    void   set_nesting();
    1.13 @@ -102,9 +105,14 @@
    1.14  
    1.15    // This GA will use the resource stack for storage if c_heap==false,
    1.16    // Else it will use the C heap.  Use clear_and_deallocate to avoid leaks.
    1.17 -  GenericGrowableArray(int initial_size, int initial_len, bool c_heap) {
    1.18 +  GenericGrowableArray(int initial_size, int initial_len, bool c_heap, MEMFLAGS flags = mtNone) {
    1.19      _len = initial_len;
    1.20      _max = initial_size;
    1.21 +    _memflags = flags;
    1.22 +
    1.23 +    // memory type has to be specified for C heap allocation
    1.24 +    assert(!(c_heap && flags == mtNone), "memory type not specified for C heap object");
    1.25 +
    1.26      assert(_len >= 0 && _len <= _max, "initial_len too big");
    1.27      _arena = (c_heap ? (Arena*)1 : NULL);
    1.28      set_nesting();
    1.29 @@ -121,6 +129,8 @@
    1.30      _max = initial_size;
    1.31      assert(_len >= 0 && _len <= _max, "initial_len too big");
    1.32      _arena = arena;
    1.33 +    _memflags = mtNone;
    1.34 +
    1.35      assert(on_arena(), "arena has taken on reserved value 0 or 1");
    1.36      // Relax next assert to allow object allocation on resource area,
    1.37      // on stack or embedded into an other object.
    1.38 @@ -152,12 +162,14 @@
    1.39      for (int i = 0; i < _max; i++) ::new ((void*)&_data[i]) E();
    1.40    }
    1.41  
    1.42 -  GrowableArray(int initial_size, bool C_heap = false) : GenericGrowableArray(initial_size, 0, C_heap) {
    1.43 +  GrowableArray(int initial_size, bool C_heap = false, MEMFLAGS F = mtInternal)
    1.44 +    : GenericGrowableArray(initial_size, 0, C_heap, F) {
    1.45      _data = (E*)raw_allocate(sizeof(E));
    1.46      for (int i = 0; i < _max; i++) ::new ((void*)&_data[i]) E();
    1.47    }
    1.48  
    1.49 -  GrowableArray(int initial_size, int initial_len, const E& filler, bool C_heap = false) : GenericGrowableArray(initial_size, initial_len, C_heap) {
    1.50 +  GrowableArray(int initial_size, int initial_len, const E& filler, bool C_heap = false, MEMFLAGS memflags = mtInternal)
    1.51 +    : GenericGrowableArray(initial_size, initial_len, C_heap, memflags) {
    1.52      _data = (E*)raw_allocate(sizeof(E));
    1.53      int i = 0;
    1.54      for (; i < _len; i++) ::new ((void*)&_data[i]) E(filler);

mercurial