hotspot/src/share/vm/oops/objArrayKlass.cpp
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
child 1374 4c24294029a9
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_objArrayKlass.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
int objArrayKlass::oop_size(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  assert(obj->is_objArray(), "must be object array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  return objArrayOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
objArrayOop objArrayKlass::allocate(int length, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  if (length >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    if (length <= arrayOopDesc::max_array_length(T_OBJECT)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
      int size = objArrayOopDesc::object_size(length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
      KlassHandle h_k(THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
      objArrayOop a = (objArrayOop)CollectedHeap::array_allocate(h_k, size, length, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
      assert(a->is_parsable(), "Can't publish unless parsable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
      return a;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
      THROW_OOP_0(Universe::out_of_memory_error_array_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
static int multi_alloc_counter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
oop objArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  int length = *sizes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // Call to lower_dimension uses this pointer, so most be called before a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // possible GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  KlassHandle h_lower_dimension(THREAD, lower_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // If length < 0 allocate will throw an exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  objArrayOop array = allocate(length, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  assert(array->is_parsable(), "Don't handlize unless parsable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  objArrayHandle h_array (THREAD, array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  if (rank > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    if (length != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      for (int index = 0; index < length; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
        arrayKlass* ak = arrayKlass::cast(h_lower_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
        oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        assert(sub_array->is_parsable(), "Don't publish until parsable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        h_array->obj_at_put(index, sub_array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      // Since this array dimension has zero length, nothing will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
      // allocated, however the lower dimension values must be checked
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      // for illegal values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      for (int i = 0; i < rank - 1; ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        sizes += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        if (*sizes < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
          THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  return h_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    83
// Either oop or narrowOop depending on UseCompressedOops.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    84
template <class T> void objArrayKlass::do_copy(arrayOop s, T* src,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    85
                               arrayOop d, T* dst, int length, TRAPS) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    86
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    87
  const size_t word_len = objArrayOopDesc::array_size(length);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    88
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    89
  // For performance reasons, we assume we are using a card marking write
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    90
  // barrier. The assert will fail if this is not the case.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    91
  BarrierSet* bs = Universe::heap()->barrier_set();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    92
  assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    93
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    94
  if (s == d) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    95
    // since source and destination are equal we do not need conversion checks.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    96
    assert(length > 0, "sanity check");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    97
    Copy::conjoint_oops_atomic(src, dst, length);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    98
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    99
    // We have to make sure all elements conform to the destination array
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   100
    klassOop bound = objArrayKlass::cast(d->klass())->element_klass();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   101
    klassOop stype = objArrayKlass::cast(s->klass())->element_klass();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   102
    if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   103
      // elements are guaranteed to be subtypes, so no check necessary
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   104
      Copy::conjoint_oops_atomic(src, dst, length);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   105
    } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   106
      // slow case: need individual subtype checks
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   107
      // note: don't use obj_at_put below because it includes a redundant store check
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   108
      T* from = src;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   109
      T* end = from + length;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
      for (T* p = dst; from < end; from++, p++) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   111
        // XXX this is going to be slow.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   112
        T element = *from;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   113
        if (oopDesc::is_null(element) ||
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   114
            Klass::cast(oopDesc::decode_heap_oop_not_null(element)->klass())->is_subtype_of(bound)) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   115
          *p = *from;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   116
        } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   117
          // We must do a barrier to cover the partial copy.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   118
          const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   119
          // pointer delta is scaled to number of elements (length field in
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   120
          // objArrayOop) which we assume is 32 bit.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   121
          assert(pd == (size_t)(int)pd, "length field overflow");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   122
          const size_t done_word_len = objArrayOopDesc::array_size((int)pd);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   123
          bs->write_ref_array(MemRegion((HeapWord*)dst, done_word_len));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   124
          THROW(vmSymbols::java_lang_ArrayStoreException());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   125
          return;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   126
        }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   127
      }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   128
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   129
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   130
  bs->write_ref_array(MemRegion((HeapWord*)dst, word_len));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   131
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   132
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
                               int dst_pos, int length, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  assert(s->is_objArray(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  if (!d->is_objArray()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    THROW(vmSymbols::java_lang_ArrayStoreException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Check is all offsets and lengths are non negative
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  if (src_pos < 0 || dst_pos < 0 || length < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // Check if the ranges are valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
     || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Special case. Boundary cases must be checked first
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // This allows the following call: copy_array(s, s.length(), d.length(), 0).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // points to the right of the last element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  if (length==0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   158
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   159
    narrowOop* const src = objArrayOop(s)->obj_at_addr<narrowOop>(src_pos);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   160
    narrowOop* const dst = objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   161
    do_copy<narrowOop>(s, src, d, dst, length, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  } else {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   163
    oop* const src = objArrayOop(s)->obj_at_addr<oop>(src_pos);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   164
    oop* const dst = objArrayOop(d)->obj_at_addr<oop>(dst_pos);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   165
    do_copy<oop> (s, src, d, dst, length, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
klassOop objArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  objArrayKlassHandle h_this(THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  return array_klass_impl(h_this, or_null, n, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
klassOop objArrayKlass::array_klass_impl(objArrayKlassHandle this_oop, bool or_null, int n, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  assert(this_oop->dimension() <= n, "check order of chain");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  int dimension = this_oop->dimension();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  if (dimension == n)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    return this_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  objArrayKlassHandle ak (THREAD, this_oop->higher_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  if (ak.is_null()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    if (or_null)  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    JavaThread *jt = (JavaThread *)THREAD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      MutexLocker mc(Compile_lock, THREAD);   // for vtables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      // Ensure atomic creation of higher dimensions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      MutexLocker mu(MultiArray_lock, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      // Check if another thread beat us
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      ak = objArrayKlassHandle(THREAD, this_oop->higher_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      if( ak.is_null() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
        // Create multi-dim klass object and link them together
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
        klassOop new_klass =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
          objArrayKlassKlass::cast(Universe::objArrayKlassKlassObj())->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
          allocate_objArray_klass(dimension + 1, this_oop, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        ak = objArrayKlassHandle(THREAD, new_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
        this_oop->set_higher_dimension(ak());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
        ak->set_lower_dimension(this_oop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
        assert(ak->oop_is_objArray(), "incorrect initialization of objArrayKlass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  if (or_null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    return ak->array_klass_or_null(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  return ak->array_klass(n, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
klassOop objArrayKlass::array_klass_impl(bool or_null, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  return array_klass_impl(or_null, dimension() +  1, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
bool objArrayKlass::can_be_primary_super_slow() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  if (!bottom_klass()->klass_part()->can_be_primary_super())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    // array of interfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    return Klass::can_be_primary_super_slow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
objArrayOop objArrayKlass::compute_secondary_supers(int num_extra_slots, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  objArrayOop es = Klass::cast(element_klass())->secondary_supers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  objArrayHandle elem_supers (THREAD, es);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  int num_elem_supers = elem_supers.is_null() ? 0 : elem_supers->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  int num_secondaries = num_extra_slots + 2 + num_elem_supers;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  if (num_secondaries == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    // Must share this for correct bootstrapping!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    return Universe::the_array_interfaces_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    objArrayOop sec_oop = oopFactory::new_system_objArray(num_secondaries, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    objArrayHandle secondaries(THREAD, sec_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    secondaries->obj_at_put(num_extra_slots+0, SystemDictionary::cloneable_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    secondaries->obj_at_put(num_extra_slots+1, SystemDictionary::serializable_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    for (int i = 0; i < num_elem_supers; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
      klassOop elem_super = (klassOop) elem_supers->obj_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      klassOop array_super = elem_super->klass_part()->array_klass_or_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
      assert(array_super != NULL, "must already have been created");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      secondaries->obj_at_put(num_extra_slots+2+i, array_super);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    return secondaries();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
bool objArrayKlass::compute_is_subtype_of(klassOop k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  if (!k->klass_part()->oop_is_objArray())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    return arrayKlass::compute_is_subtype_of(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  objArrayKlass* oak = objArrayKlass::cast(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  return element_klass()->klass_part()->is_subtype_of(oak->element_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
void objArrayKlass::initialize(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  Klass::cast(bottom_klass())->initialize(THREAD);  // dispatches to either instanceKlass or typeArrayKlass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   266
#define ObjArrayKlass_SPECIALIZED_OOP_ITERATE(T, a, p, do_oop) \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   267
{                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   268
  T* p         = (T*)(a)->base();   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   269
  T* const end = p + (a)->length(); \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   270
  while (p < end) {                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   271
    do_oop;                         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   272
    p++;                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   273
  }                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   274
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   275
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   276
#define ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(T, a, p, low, high, do_oop) \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   277
{                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   278
  T* const l = (T*)(low);           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   279
  T* const h = (T*)(high);          \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   280
  T* p       = (T*)(a)->base();     \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   281
  T* end     = p + (a)->length();   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   282
  if (p < l) p = l;                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   283
  if (end > h) end = h;             \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   284
  while (p < end) {                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   285
    do_oop;                         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   286
    ++p;                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   287
  }                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   288
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   289
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   290
#define ObjArrayKlass_OOP_ITERATE(a, p, do_oop)      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   291
  if (UseCompressedOops) {                           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   292
    ObjArrayKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   293
      a, p, do_oop)                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   294
  } else {                                           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   295
    ObjArrayKlass_SPECIALIZED_OOP_ITERATE(oop,       \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   296
      a, p, do_oop)                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   297
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   298
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   299
#define ObjArrayKlass_BOUNDED_OOP_ITERATE(a, p, low, high, do_oop) \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   300
  if (UseCompressedOops) {                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   301
    ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   302
      a, p, low, high, do_oop)                               \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   303
  } else {                                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   304
    ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,       \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   305
      a, p, low, high, do_oop)                               \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   306
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
void objArrayKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  assert (obj->is_array(), "obj must be array");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   310
  objArrayOop a = objArrayOop(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  a->follow_header();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   312
  ObjArrayKlass_OOP_ITERATE( \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   313
    a, p, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   314
    /* we call mark_and_follow here to avoid excessive marking stack usage */ \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   315
    MarkSweep::mark_and_follow(p))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
void objArrayKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
                                        oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  assert (obj->is_array(), "obj must be array");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   322
  objArrayOop a = objArrayOop(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  a->follow_header(cm);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   324
  ObjArrayKlass_OOP_ITERATE( \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   325
    a, p, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   326
    /* we call mark_and_follow here to avoid excessive marking stack usage */ \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   327
    PSParallelCompact::mark_and_follow(cm, p))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
int objArrayKlass::oop_oop_iterate##nv_suffix(oop obj,                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
                                              OopClosureType* closure) {        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  assert (obj->is_array(), "obj must be array");                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  objArrayOop a = objArrayOop(obj);                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  /* Get size before changing pointers. */                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  /* Don't call size() or oop_size() since that is a virtual call. */           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  int size = a->object_size();                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  if (closure->do_header()) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    a->oop_iterate_header(closure);                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  }                                                                             \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   344
  ObjArrayKlass_OOP_ITERATE(a, p, (closure)->do_oop##nv_suffix(p))              \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  return size;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
int objArrayKlass::oop_oop_iterate##nv_suffix##_m(oop obj,                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
                                                  OopClosureType* closure,      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
                                                  MemRegion mr) {               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  assert(obj->is_array(), "obj must be array");                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  objArrayOop a  = objArrayOop(obj);                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  /* Get size before changing pointers. */                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  /* Don't call size() or oop_size() since that is a virtual call */            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  int size = a->object_size();                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  if (closure->do_header()) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    a->oop_iterate_header(closure, mr);                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  }                                                                             \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   362
  ObjArrayKlass_BOUNDED_OOP_ITERATE(                                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   363
    a, p, mr.start(), mr.end(), (closure)->do_oop##nv_suffix(p))                \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   364
  return size;                                                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   365
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   366
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   367
// Like oop_oop_iterate but only iterates over a specified range and only used
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   368
// for objArrayOops.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   369
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r(OopClosureType, nv_suffix)         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   370
                                                                                \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   371
int objArrayKlass::oop_oop_iterate_range##nv_suffix(oop obj,                    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   372
                                                  OopClosureType* closure,      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   373
                                                  int start, int end) {         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   374
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   375
  assert(obj->is_array(), "obj must be array");                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   376
  objArrayOop a  = objArrayOop(obj);                                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   377
  /* Get size before changing pointers. */                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   378
  /* Don't call size() or oop_size() since that is a virtual call */            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   379
  int size = a->object_size();                                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   380
  if (UseCompressedOops) {                                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   381
    HeapWord* low = start == 0 ? (HeapWord*)a : (HeapWord*)a->obj_at_addr<narrowOop>(start);\
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   382
    /* this might be wierd if end needs to be aligned on HeapWord boundary */   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   383
    HeapWord* high = (HeapWord*)((narrowOop*)a->base() + end);                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   384
    MemRegion mr(low, high);                                                    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   385
    if (closure->do_header()) {                                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   386
      a->oop_iterate_header(closure, mr);                                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    }                                                                           \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   388
    ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop,                    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   389
      a, p, low, high, (closure)->do_oop##nv_suffix(p))                         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  } else {                                                                      \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   391
    HeapWord* low = start == 0 ? (HeapWord*)a : (HeapWord*)a->obj_at_addr<oop>(start);  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   392
    HeapWord* high = (HeapWord*)((oop*)a->base() + end);                        \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   393
    MemRegion mr(low, high);                                                    \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   394
    if (closure->do_header()) {                                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   395
      a->oop_iterate_header(closure, mr);                                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    }                                                                           \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   397
    ObjArrayKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,                          \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   398
      a, p, low, high, (closure)->do_oop##nv_suffix(p))                         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  return size;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   407
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   408
ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
int objArrayKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  assert(obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  objArrayOop a = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  int size = a->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  a->adjust_header();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   417
  ObjArrayKlass_OOP_ITERATE(a, p, MarkSweep::adjust_pointer(p))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
void objArrayKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  assert(!pm->depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  assert(obj->is_objArray(), "obj must be obj array");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   425
  ObjArrayKlass_OOP_ITERATE( \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   426
    objArrayOop(obj), p, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   427
    if (PSScavenge::should_scavenge(p)) { \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   428
      pm->claim_or_forward_breadth(p); \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   429
    })
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
void objArrayKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  assert(pm->depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  assert(obj->is_objArray(), "obj must be obj array");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   435
  ObjArrayKlass_OOP_ITERATE( \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   436
    objArrayOop(obj), p, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   437
    if (PSScavenge::should_scavenge(p)) { \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   438
      pm->claim_or_forward_depth(p); \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   439
    })
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  assert (obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  objArrayOop a = objArrayOop(obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   445
  ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  return a->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
                                       HeapWord* beg_addr, HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  assert (obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  objArrayOop a = objArrayOop(obj);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   453
  ObjArrayKlass_BOUNDED_OOP_ITERATE( \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   454
     a, p, beg_addr, end_addr, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   455
     PSParallelCompact::adjust_pointer(p))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  return a->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
// JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
jint objArrayKlass::compute_modifier_flags(TRAPS) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  // The modifier for an objectArray is the same as its element
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  if (element_klass() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    assert(Universe::is_bootstrapping(), "partial objArray only at startup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  // Recurse down the element list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  jint element_flags = Klass::cast(element_klass())->compute_modifier_flags(CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
                        | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
void objArrayKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  arrayKlass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  assert(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  for(int index = 0; index < print_len; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    st->print(" - %3d : ", index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    oa->obj_at(index)->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  int remaining = oa->length() - print_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  if (remaining > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
void objArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  assert(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  element_klass()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  st->print("a [%d] ", objArrayOop(obj)->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  as_klassOop()->klass()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
const char* objArrayKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  return external_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
void objArrayKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  arrayKlass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  guarantee(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  for(int index = 0; index < oa->length(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    guarantee(oa->obj_at(index)->is_oop_or_null(), "should be oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
void objArrayKlass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  /* $$$ move into remembered set verification?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  RememberedSet::verify_old_oop(obj, p, allow_dirty, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
}
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   525
void objArrayKlass::oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty) {}