hotspot/src/share/vm/utilities/array.hpp
author minqi
Mon, 12 Nov 2012 14:03:53 -0800
changeset 14477 95e66ea71f71
parent 13728 882756847a04
child 17858 c292f8791cca
permissions -rw-r--r--
6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
     2
 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1623
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1623
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1623
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_UTILITIES_ARRAY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_UTILITIES_ARRAY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "memory/allocation.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    30
#include "memory/metaspace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// correct linkage required to compile w/o warnings
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// (must be on file level - cannot be local)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
extern "C" { typedef int (*ftype)(const void*, const void*); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class ResourceArray: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  int   _length;                                 // the number of array elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  void* _data;                                   // the array memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  int   _nesting;                                // the resource area nesting level
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  ResourceArray() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _length  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    _data    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    DEBUG_ONLY(init_nesting();)
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    50
    // client may call initialize, at most once
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  ResourceArray(size_t esize, int length) {
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    55
    DEBUG_ONLY(_data = NULL);
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    56
    initialize(esize, length);
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    57
  }
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    58
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    59
  void initialize(size_t esize, int length) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    assert(length >= 0, "illegal length");
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
    61
    assert(_data == NULL, "must be new object");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    _length  = length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    _data    = resource_allocate_bytes(esize * length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    DEBUG_ONLY(init_nesting();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  void init_nesting();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // helper functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  void sort     (size_t esize, ftype f);         // sort the array
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  void expand   (size_t esize, int i, int& size);// expand the array to include slot i
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  void remove_at(size_t esize, int i);           // remove the element in slot i
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // standard operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  int  length() const                            { return _length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  bool is_empty() const                          { return length() == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7397
diff changeset
    83
template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  int   _length;                                 // the number of array elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  void* _data;                                   // the array memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  CHeapArray() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    _length  = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    _data    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  CHeapArray(size_t esize, int length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    assert(length >= 0, "illegal length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    _length  = length;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7397
diff changeset
    98
    _data    = (void*) NEW_C_HEAP_ARRAY(char *, esize * length, F);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   101
  void initialize(size_t esize, int length) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   102
    // In debug set array to 0?
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   103
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   104
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void init_nesting();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // helper functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  void sort     (size_t esize, ftype f);         // sort the array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  void expand   (size_t esize, int i, int& size);// expand the array to include slot i
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  void remove_at(size_t esize, int i);           // remove the element in slot i
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // standard operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  int  length() const                            { return _length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool is_empty() const                          { return length() == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
#define define_generic_array(array_name,element_type, base_class)                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  class array_name: public base_class {                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
   protected:                                                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    typedef element_type etype;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    enum { esize = sizeof(etype) };                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    void base_remove_at(size_t size, int i) { base_class::remove_at(size, i); }          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
   public:                                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    /* creation */                                                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    array_name() : base_class()                       {}                                 \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   131
    explicit array_name(const int length) : base_class(esize, length) {}                          \
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   132
    array_name(const int length, const etype fx)      { initialize(length, fx); }        \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   133
    void initialize(const int length)     { base_class::initialize(esize, length); }     \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   134
    void initialize(const int length, const etype fx) {                                  \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   135
      initialize(length);                                                                \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      for (int i = 0; i < length; i++) ((etype*)_data)[i] = fx;                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    /* standard operations */                                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    etype& operator [] (const int i) const {                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      assert(0 <= i && i < length(), "index out of bounds");                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      return ((etype*)_data)[i];                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    int index_of(const etype x) const {                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      int i = length();                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      while (i-- > 0 && ((etype*)_data)[i] != x) ;                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      /* i < 0 || ((etype*)_data)_data[i] == x */                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      return i;                                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    void sort(int f(etype*, etype*))             { base_class::sort(esize, (ftype)f); }  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    bool contains(const etype x) const           { return index_of(x) >= 0; }            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    /* deprecated operations - for compatibility with GrowableArray only */              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    etype  at(const int i) const                 { return (*this)[i]; }                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    void   at_put(const int i, const etype x)    { (*this)[i] = x; }                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    etype* adr_at(const int i)                   { return &(*this)[i]; }                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    int    find(const etype x)                   { return index_of(x); }                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  };                                                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
#define define_array(array_name,element_type)                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  define_generic_array(array_name, element_type, ResourceArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
#define define_stack(stack_name,array_name)                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  class stack_name: public array_name {                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
   protected:                                                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    int _size;                                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    void grow(const int i, const etype fx) {                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      assert(i >= length(), "index too small");                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      if (i >= size()) expand(esize, i, _size);                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
      for (int j = length(); j <= i; j++) ((etype*)_data)[j] = fx;                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      _length = i+1;                                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
   public:                                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    /* creation */                                                                       \
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   181
    stack_name() : array_name()                     { _size = 0; }                       \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   182
    stack_name(const int size)                      { initialize(size); }                \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   183
    stack_name(const int size, const etype fx)      { initialize(size, fx); }            \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   184
    void initialize(const int size, const etype fx) {                                    \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   185
      _size = size;                                                                      \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   186
      array_name::initialize(size, fx);                                                  \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   187
      /* _length == size, allocation and size are the same */                            \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   188
    }                                                                                    \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   189
    void initialize(const int size) {                                                    \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   190
      _size = size;                                                                      \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   191
      array_name::initialize(size);                                                      \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   192
      _length = 0;          /* reset length to zero; _size records the allocation */     \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   193
    }                                                                                    \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    /* standard operations */                                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    int size() const                             { return _size; }                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
                                                                                         \
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   198
    int push(const etype x) {                                                            \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   199
      int len = length();                                                                \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   200
      if (len >= size()) expand(esize, len, _size);                                      \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   201
      ((etype*)_data)[len] = x;                                                          \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   202
      _length = len+1;                                                                   \
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   203
      return len;                                                                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    etype pop() {                                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
      assert(!is_empty(), "stack is empty");                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
      return ((etype*)_data)[--_length];                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    etype top() const {                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      assert(!is_empty(), "stack is empty");                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      return ((etype*)_data)[length() - 1];                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    void push_all(const stack_name* stack) {                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      const int l = stack->length();                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      for (int i = 0; i < l; i++) push(((etype*)(stack->_data))[i]);                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    etype at_grow(const int i, const etype fx) {                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      if (i >= length()) grow(i, fx);                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      return ((etype*)_data)[i];                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    void at_put_grow(const int i, const etype x, const etype fx) {                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      if (i >= length()) grow(i, fx);                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      ((etype*)_data)[i] = x;                                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    void truncate(const int length) {                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      assert(0 <= length && length <= this->length(), "illegal length");                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      _length = length;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    void remove_at(int i)                        { base_remove_at(esize, i); }           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    void remove(etype x)                         { remove_at(index_of(x)); }             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    /* inserts the given element before the element at index i */                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    void insert_before(const int i, const etype el)  {                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      int len = length();                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
      int new_length = len + 1;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      if (new_length >= size()) expand(esize, new_length, _size);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      for (int j = len - 1; j >= i; j--) {                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
        ((etype*)_data)[j + 1] = ((etype*)_data)[j];                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      }                                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
      _length = new_length;                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      at_put(i, el);                                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    /* inserts contents of the given stack before the element at index i */              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    void insert_before(const int i, const stack_name *st) {                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      if (st->length() == 0) return;                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      int len = length();                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      int st_len = st->length();                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      int new_length = len + st_len;                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
      if (new_length >= size()) expand(esize, new_length, _size);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      int j;                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
      for (j = len - 1; j >= i; j--) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
        ((etype*)_data)[j + st_len] = ((etype*)_data)[j];                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      }                                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
      for (j = 0; j < st_len; j++) {                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        ((etype*)_data)[i + j] = ((etype*)st->_data)[j];                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
      }                                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
      _length = new_length;                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    /* deprecated operations - for compatibility with GrowableArray only */              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    int  capacity() const                        { return size(); }                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    void clear()                                 { truncate(0); }                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    void trunc_to(const int length)              { truncate(length); }                   \
1551
b431de37a22c 6770949: minor tweaks before 6655638
jrose
parents: 1
diff changeset
   272
    int  append(const etype x)                   { return push(x); }                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    void appendAll(const stack_name* stack)      { push_all(stack); }                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    etype last() const                           { return top(); }                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  };                                                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
#define define_resource_list(element_type)                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  define_generic_array(element_type##Array, element_type, ResourceArray)                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  define_stack(element_type##List, element_type##Array)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
#define define_resource_pointer_list(element_type)                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  define_generic_array(element_type##Array, element_type *, ResourceArray)               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  define_stack(element_type##List, element_type##Array)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
#define define_c_heap_list(element_type)                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  define_generic_array(element_type##Array, element_type, CHeapArray)                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  define_stack(element_type##List, element_type##Array)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
#define define_c_heap_pointer_list(element_type)                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  define_generic_array(element_type##Array, element_type *, CHeapArray)                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  define_stack(element_type##List, element_type##Array)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// Arrays for basic types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
define_array(boolArray, bool)          define_stack(boolStack, boolArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
define_array(intArray , int )          define_stack(intStack , intArray )
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   299
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   300
// Array for metadata allocation
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   301
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   302
template <typename T>
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   303
class Array: public MetaspaceObj {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   304
  friend class MetadataFactory;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   305
  friend class VMStructs;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   306
  friend class MethodHandleCompiler;           // special case
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   307
protected:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   308
  int _length;                                 // the number of array elements
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   309
  T   _data[1];                                // the array memory
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   310
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   311
  void initialize(int length) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   312
    _length = length;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   313
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   314
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   315
 private:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   316
  // Turn off copy constructor and assignment operator.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   317
  Array(const Array<T>&);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   318
  void operator=(const Array<T>&);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   319
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   320
  void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   321
    size_t word_size = Array::size(length);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   322
    return (void*) Metaspace::allocate(loader_data, word_size, read_only,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   323
                        Metaspace::NonClassType, CHECK_NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   324
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   325
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   326
  static size_t byte_sizeof(int length) { return sizeof(Array<T>) + MAX2(length - 1, 0) * sizeof(T); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   327
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   328
  explicit Array(int length) : _length(length) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   329
    assert(length >= 0, "illegal length");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   330
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   331
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   332
  Array(int length, T init) : _length(length) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   333
    assert(length >= 0, "illegal length");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   334
    for (int i = 0; i < length; i++) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   335
      _data[i] = init;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   336
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   337
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   338
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   339
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   340
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   341
  // standard operations
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   342
  int  length() const                 { return _length; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   343
  T* data()                           { return _data; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   344
  bool is_empty() const               { return length() == 0; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   345
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   346
  int index_of(const T& x) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   347
    int i = length();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   348
    while (i-- > 0 && _data[i] != x) ;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   349
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   350
    return i;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   351
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   352
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   353
  // sort the array.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   354
  bool contains(const T& x) const      { return index_of(x) >= 0; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   355
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13728
diff changeset
   356
  T    at(int i) const                 { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return _data[i]; }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13728
diff changeset
   357
  void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); _data[i] = x; }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13728
diff changeset
   358
  T*   adr_at(const int i)             { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return &_data[i]; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   359
  int  find(const T& x)                { return index_of(x); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   360
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   361
  T at_acquire(const int which)              { return OrderAccess::load_acquire(adr_at(which)); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   362
  void release_at_put(int which, T contents) { OrderAccess::release_store(adr_at(which), contents); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   363
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   364
  static int size(int length) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   365
    return align_size_up(byte_sizeof(length), BytesPerWord) / BytesPerWord;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   366
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   367
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   368
  int size() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   369
    return size(_length);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   370
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   371
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   372
  static int length_offset_in_bytes() { return (int) (offset_of(Array<T>, _length)); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   373
  // Note, this offset don't have to be wordSize aligned.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   374
  static int base_offset_in_bytes() { return (int) (offset_of(Array<T>, _data)); };
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   375
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   376
  // FIXME: How to handle this?
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   377
  void print_value_on(outputStream* st) const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   378
    st->print("Array<T>(" INTPTR_FORMAT ")", this);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   379
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   380
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   381
#ifndef PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   382
  void print(outputStream* st) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   383
     for (int i = 0; i< _length; i++) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   384
       st->print_cr("%d: " INTPTR_FORMAT, i, (intptr_t)at(i));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   385
     }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   386
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   387
  void print() { print(tty); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   388
#endif // PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   389
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   390
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   391
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   392
#endif // SHARE_VM_UTILITIES_ARRAY_HPP