hotspot/src/share/vm/oops/objArrayKlass.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 360 21d113ecbf6a
permissions -rw-r--r--
Initial load
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
                               int dst_pos, int length, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  assert(s->is_objArray(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  if (!d->is_objArray()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    THROW(vmSymbols::java_lang_ArrayStoreException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // Check is all offsets and lengths are non negative
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  if (src_pos < 0 || dst_pos < 0 || length < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Check if the ranges are valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
     || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Special case. Boundary cases must be checked first
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // This allows the following call: copy_array(s, s.length(), d.length(), 0).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // 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
   104
  // points to the right of the last element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  if (length==0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  oop* const src = objArrayOop(s)->obj_at_addr(src_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  oop* const dst = objArrayOop(d)->obj_at_addr(dst_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  const size_t word_len = length * HeapWordsPerOop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // For performance reasons, we assume we are using a card marking write
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // barrier. The assert will fail if this is not the case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  BarrierSet* bs = Universe::heap()->barrier_set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  if (s == d) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    // since source and destination are equal we do not need conversion checks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    assert(length > 0, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    Copy::conjoint_oops_atomic(src, dst, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    // We have to make sure all elements conform to the destination array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    klassOop bound = objArrayKlass::cast(d->klass())->element_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    klassOop stype = objArrayKlass::cast(s->klass())->element_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      // elements are guaranteed to be subtypes, so no check necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
      Copy::conjoint_oops_atomic(src, dst, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      // slow case: need individual subtype checks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      // note: don't use obj_at_put below because it includes a redundant store check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
      oop* from = src;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      oop* end = from + length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
      for (oop* p = dst; from < end; from++, p++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
        oop element = *from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
        if (element == NULL || Klass::cast(element->klass())->is_subtype_of(bound)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
          *p = element;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
          // We must do a barrier to cover the partial copy.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
          const size_t done_word_len = pointer_delta(p, dst, oopSize) *
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
                                       HeapWordsPerOop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
          bs->write_ref_array(MemRegion((HeapWord*)dst, done_word_len));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
          THROW(vmSymbols::java_lang_ArrayStoreException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
          return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  bs->write_ref_array(MemRegion((HeapWord*)dst, word_len));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
klassOop objArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  objArrayKlassHandle h_this(THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  return array_klass_impl(h_this, or_null, n, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
klassOop objArrayKlass::array_klass_impl(objArrayKlassHandle this_oop, bool or_null, int n, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  assert(this_oop->dimension() <= n, "check order of chain");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  int dimension = this_oop->dimension();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  if (dimension == n)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    return this_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  objArrayKlassHandle ak (THREAD, this_oop->higher_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  if (ak.is_null()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    if (or_null)  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    JavaThread *jt = (JavaThread *)THREAD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      MutexLocker mc(Compile_lock, THREAD);   // for vtables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      // Ensure atomic creation of higher dimensions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
      MutexLocker mu(MultiArray_lock, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      // Check if another thread beat us
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      ak = objArrayKlassHandle(THREAD, this_oop->higher_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      if( ak.is_null() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
        // Create multi-dim klass object and link them together
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        klassOop new_klass =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
          objArrayKlassKlass::cast(Universe::objArrayKlassKlassObj())->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
          allocate_objArray_klass(dimension + 1, this_oop, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        ak = objArrayKlassHandle(THREAD, new_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        this_oop->set_higher_dimension(ak());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
        ak->set_lower_dimension(this_oop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
        assert(ak->oop_is_objArray(), "incorrect initialization of objArrayKlass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  if (or_null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    return ak->array_klass_or_null(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  return ak->array_klass(n, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
klassOop objArrayKlass::array_klass_impl(bool or_null, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  return array_klass_impl(or_null, dimension() +  1, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
bool objArrayKlass::can_be_primary_super_slow() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  if (!bottom_klass()->klass_part()->can_be_primary_super())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    // array of interfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    return Klass::can_be_primary_super_slow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
objArrayOop objArrayKlass::compute_secondary_supers(int num_extra_slots, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  objArrayOop es = Klass::cast(element_klass())->secondary_supers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  objArrayHandle elem_supers (THREAD, es);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  int num_elem_supers = elem_supers.is_null() ? 0 : elem_supers->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  int num_secondaries = num_extra_slots + 2 + num_elem_supers;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  if (num_secondaries == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    // Must share this for correct bootstrapping!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    return Universe::the_array_interfaces_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    objArrayOop sec_oop = oopFactory::new_system_objArray(num_secondaries, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    objArrayHandle secondaries(THREAD, sec_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    secondaries->obj_at_put(num_extra_slots+0, SystemDictionary::cloneable_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    secondaries->obj_at_put(num_extra_slots+1, SystemDictionary::serializable_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    for (int i = 0; i < num_elem_supers; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      klassOop elem_super = (klassOop) elem_supers->obj_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      klassOop array_super = elem_super->klass_part()->array_klass_or_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      assert(array_super != NULL, "must already have been created");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      secondaries->obj_at_put(num_extra_slots+2+i, array_super);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    return secondaries();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
bool objArrayKlass::compute_is_subtype_of(klassOop k) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  if (!k->klass_part()->oop_is_objArray())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    return arrayKlass::compute_is_subtype_of(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  objArrayKlass* oak = objArrayKlass::cast(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  return element_klass()->klass_part()->is_subtype_of(oak->element_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
void objArrayKlass::initialize(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  Klass::cast(bottom_klass())->initialize(THREAD);  // dispatches to either instanceKlass or typeArrayKlass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
void objArrayKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  assert (obj->is_array(), "obj must be array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  arrayOop a = arrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  a->follow_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  oop* base      = (oop*)a->base(T_OBJECT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  oop* const end = base + a->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  while (base < end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    if (*base != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
      // we call mark_and_follow here to avoid excessive marking stack usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
      MarkSweep::mark_and_follow(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
void objArrayKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
                                        oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  assert (obj->is_array(), "obj must be array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  arrayOop a = arrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  a->follow_header(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  oop* base      = (oop*)a->base(T_OBJECT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  oop* const end = base + a->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  while (base < end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    if (*base != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      // we call mark_and_follow here to avoid excessive marking stack usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      PSParallelCompact::mark_and_follow(cm, base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
#define invoke_closure_on(base, closure, nv_suffix) {                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  if (*(base) != NULL) {                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    (closure)->do_oop##nv_suffix(base);                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  }                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
int objArrayKlass::oop_oop_iterate##nv_suffix(oop obj,                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
                                              OopClosureType* closure) {        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  assert (obj->is_array(), "obj must be array");                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  objArrayOop a = objArrayOop(obj);                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  /* Get size before changing pointers. */                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  /* Don't call size() or oop_size() since that is a virtual call. */           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  int size = a->object_size();                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  if (closure->do_header()) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    a->oop_iterate_header(closure);                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  oop* base               = a->base();                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  oop* const end          = base + a->length();                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  const intx field_offset = PrefetchFieldsAhead;                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  if (field_offset > 0) {                                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    while (base < end) {                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      prefetch_beyond(base, end, field_offset, closure->prefetch_style());      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      invoke_closure_on(base, closure, nv_suffix);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
      base++;                                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    }                                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  } else {                                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    while (base < end) {                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      invoke_closure_on(base, closure, nv_suffix);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      base++;                                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    }                                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  return size;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
int objArrayKlass::oop_oop_iterate##nv_suffix##_m(oop obj,                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
                                                  OopClosureType* closure,      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
                                                  MemRegion mr) {               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  assert(obj->is_array(), "obj must be array");                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  objArrayOop a  = objArrayOop(obj);                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  /* Get size before changing pointers. */                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  /* Don't call size() or oop_size() since that is a virtual call */            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  int size = a->object_size();                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  if (closure->do_header()) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    a->oop_iterate_header(closure, mr);                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  oop* bottom = (oop*)mr.start();                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  oop* top    = (oop*)mr.end();                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  oop* base = a->base();                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  oop* end    = base + a->length();                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  if (base < bottom) {                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    base = bottom;                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  if (end > top) {                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    end = top;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  const intx field_offset = PrefetchFieldsAhead;                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  if (field_offset > 0) {                                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    while (base < end) {                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
      prefetch_beyond(base, end, field_offset, closure->prefetch_style());      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      invoke_closure_on(base, closure, nv_suffix);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      base++;                                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    }                                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  } else {                                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    while (base < end) {                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      invoke_closure_on(base, closure, nv_suffix);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      base++;                                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    }                                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  return size;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
int objArrayKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  assert(obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  objArrayOop a = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  int size = a->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  a->adjust_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  oop* base      = a->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  oop* const end = base + a->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  while (base < end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    MarkSweep::adjust_pointer(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    base++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
void objArrayKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  assert(!pm->depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  assert(obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  // Compute oop range
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  oop* curr = objArrayOop(obj)->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  oop* end = curr + objArrayOop(obj)->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  //  assert(align_object_size(end - (oop*)obj) == oop_size(obj), "checking size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  assert(align_object_size(pointer_delta(end, obj, sizeof(oop*)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
                                  == oop_size(obj), "checking size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  // Iterate over oops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  while (curr < end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    if (PSScavenge::should_scavenge(*curr)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
      pm->claim_or_forward_breadth(curr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    ++curr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
void objArrayKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  assert(pm->depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  assert(obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // Compute oop range
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  oop* curr = objArrayOop(obj)->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  oop* end = curr + objArrayOop(obj)->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  //  assert(align_object_size(end - (oop*)obj) == oop_size(obj), "checking size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  assert(align_object_size(pointer_delta(end, obj, sizeof(oop*)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
                                  == oop_size(obj), "checking size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // Iterate over oops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  while (curr < end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    if (PSScavenge::should_scavenge(*curr)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
      pm->claim_or_forward_depth(curr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    ++curr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  assert (obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  objArrayOop a = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  oop* const base = a->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  oop* const beg_oop = base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  oop* const end_oop = base + a->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    PSParallelCompact::adjust_pointer(cur_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  return a->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
                                       HeapWord* beg_addr, HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  assert (obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  objArrayOop a = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  oop* const base = a->base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  oop* const beg_oop = MAX2((oop*)beg_addr, base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  oop* const end_oop = MIN2((oop*)end_addr, base + a->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    PSParallelCompact::adjust_pointer(cur_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  return a->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
// JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
jint objArrayKlass::compute_modifier_flags(TRAPS) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // The modifier for an objectArray is the same as its element
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  if (element_klass() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    assert(Universe::is_bootstrapping(), "partial objArray only at startup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // Recurse down the element list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  jint element_flags = Klass::cast(element_klass())->compute_modifier_flags(CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
                        | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
void objArrayKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  arrayKlass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  assert(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  for(int index = 0; index < print_len; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    st->print(" - %3d : ", index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    oa->obj_at(index)->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  int remaining = oa->length() - print_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  if (remaining > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
void objArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  assert(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  element_klass()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  st->print("a [%d] ", objArrayOop(obj)->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  as_klassOop()->klass()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
const char* objArrayKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  return external_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
void objArrayKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  arrayKlass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  guarantee(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  for(int index = 0; index < oa->length(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    guarantee(oa->obj_at(index)->is_oop_or_null(), "should be oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
void objArrayKlass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  /* $$$ move into remembered set verification?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  RememberedSet::verify_old_oop(obj, p, allow_dirty, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
}