hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
author never
Wed, 06 Jan 2010 14:22:39 -0800
changeset 4571 80b553bddc26
parent 1 489c9b5090e2
child 4584 e2a449e8cc6f
permissions -rw-r--r--
6914300: ciEnv should export all well known classes Reviewed-by: kvn, twisti
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/_objArrayKlassKlass.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
klassOop objArrayKlassKlass::create_klass(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  objArrayKlassKlass o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  assert(k()->size() == align_object_size(header_size()), "wrong size for object");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  java_lang_Class::create_mirror(k, CHECK_0); // Allocate mirror
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  return k();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
klassOop objArrayKlassKlass::allocate_system_objArray_klass(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  // system_objArrays have no instance klass, so allocate with fake class, then reset to NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  KlassHandle kk(THREAD, Universe::intArrayKlassObj());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  klassOop k = allocate_objArray_klass(1, kk, CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  objArrayKlass* tk = (objArrayKlass*) k->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  tk->set_element_klass(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  tk->set_bottom_klass(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  return k;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
klassOop objArrayKlassKlass::allocate_objArray_klass(int n, KlassHandle element_klass, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  objArrayKlassKlassHandle this_oop(THREAD, as_klassOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  return allocate_objArray_klass_impl(this_oop, n, element_klass, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
klassOop objArrayKlassKlass::allocate_objArray_klass_impl(objArrayKlassKlassHandle this_oop,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
                                                          int n, KlassHandle element_klass, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Eagerly allocate the direct array supertype.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  KlassHandle super_klass = KlassHandle();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  if (!Universe::is_bootstrapping()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    KlassHandle element_super (THREAD, element_klass->super());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    if (element_super.not_null()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      // The element type has a direct super.  E.g., String[] has direct super of Object[].
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      super_klass = KlassHandle(THREAD, element_super->array_klass_or_null());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
      bool supers_exist = super_klass.not_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
      // Also, see if the element has secondary supertypes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
      // We need an array type for each.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
      objArrayHandle element_supers = objArrayHandle(THREAD,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
                                            element_klass->secondary_supers());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      for( int i = element_supers->length()-1; i >= 0; i-- ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
        klassOop elem_super = (klassOop) element_supers->obj_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        if (Klass::cast(elem_super)->array_klass_or_null() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
          supers_exist = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      if (!supers_exist) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        // Oops.  Not allocated yet.  Back out, allocate it, and retry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        if (WizardMode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
          tty->print_cr("Must retry array klass creation for depth %d",n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        KlassHandle ek;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
          MutexUnlocker mu(MultiArray_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
          MutexUnlocker mc(Compile_lock);   // for vtables
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
          klassOop sk = element_super->array_klass(CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
          super_klass = KlassHandle(THREAD, sk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
          for( int i = element_supers->length()-1; i >= 0; i-- ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
            KlassHandle elem_super (THREAD, element_supers->obj_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
            elem_super->array_klass(CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
          // Now retry from the beginning
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
          klassOop klass_oop = element_klass->array_klass(n, CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
          // Create a handle because the enclosing brace, when locking
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
          // can cause a gc.  Better to have this function return a Handle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
          ek = KlassHandle(THREAD, klass_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
        }  // re-lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        return ek();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      // The element type is already Object.  Object[] has direct super of Object.
4571
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 1
diff changeset
   102
      super_klass = KlassHandle(THREAD, SystemDictionary::Object_klass());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Create type name for klass (except for symbol arrays, since symbolKlass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // does not have a name).  This will potentially allocate an object, cause
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // GC, and all other kinds of things.  Hence, this must be done before we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // get a handle to the new objArrayKlass we want to construct.  We cannot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // block while holding a handling to a partly initialized object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  symbolHandle name = symbolHandle();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  if (!element_klass->oop_is_symbol()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    ResourceMark rm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    char *name_str = element_klass->name()->as_C_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    int len = element_klass->name()->utf8_length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    char *new_str = NEW_RESOURCE_ARRAY(char, len + 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    int idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    new_str[idx++] = '[';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    if (element_klass->oop_is_instance()) { // it could be an array or simple type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      new_str[idx++] = 'L';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    memcpy(&new_str[idx], name_str, len * sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    idx += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    if (element_klass->oop_is_instance()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
      new_str[idx++] = ';';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    new_str[idx++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    name = oopFactory::new_symbol_handle(new_str, CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  objArrayKlass o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  arrayKlassHandle k = arrayKlass::base_create_array_klass(o.vtbl_value(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
                                                           objArrayKlass::header_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
                                                          this_oop,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
                                                           CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Initialize instance variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  objArrayKlass* oak = objArrayKlass::cast(k());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  oak->set_dimension(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  oak->set_element_klass(element_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  oak->set_name(name());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  klassOop bk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  if (element_klass->oop_is_objArray()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    bk = objArrayKlass::cast(element_klass())->bottom_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    bk = element_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  assert(bk != NULL && (Klass::cast(bk)->oop_is_instance() || Klass::cast(bk)->oop_is_typeArray()), "invalid bottom klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  oak->set_bottom_klass(bk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  oak->set_layout_helper(array_layout_helper(T_OBJECT));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  assert(oak->oop_is_javaArray(), "sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  assert(oak->oop_is_objArray(), "sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // Call complete_create_array_klass after all instance variables has been initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  arrayKlass::complete_create_array_klass(k, super_klass, CHECK_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  return k();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
void objArrayKlassKlass::oop_follow_contents(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  MarkSweep::mark_and_push(oak->element_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  MarkSweep::mark_and_push(oak->bottom_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  arrayKlassKlass::oop_follow_contents(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
void objArrayKlassKlass::oop_follow_contents(ParCompactionManager* cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
                                             oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  PSParallelCompact::mark_and_push(cm, oak->element_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  PSParallelCompact::mark_and_push(cm, oak->bottom_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  arrayKlassKlass::oop_follow_contents(cm, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
int objArrayKlassKlass::oop_adjust_pointers(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  MarkSweep::adjust_pointer(oak->element_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  MarkSweep::adjust_pointer(oak->bottom_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  return arrayKlassKlass::oop_adjust_pointers(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
int objArrayKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  blk->do_oop(oak->element_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  blk->do_oop(oak->bottom_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  return arrayKlassKlass::oop_oop_iterate(obj, blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
int
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
objArrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  oop* addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  addr = oak->element_klass_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  if (mr.contains(addr)) blk->do_oop(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  addr = oak->bottom_klass_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  if (mr.contains(addr)) blk->do_oop(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  return arrayKlassKlass::oop_oop_iterate(obj, blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
void objArrayKlassKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  assert(obj->blueprint()->oop_is_objArrayKlass(),"must be an obj array klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
void objArrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  assert(obj->blueprint()->oop_is_objArrayKlass(),"must be an obj array klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  PSParallelCompact::adjust_pointer(oak->element_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  PSParallelCompact::adjust_pointer(oak->bottom_klass_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  return arrayKlassKlass::oop_update_pointers(cm, obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
                                            HeapWord* beg_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
                                            HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  oop* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  p = oak->element_klass_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  p = oak->bottom_klass_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  return arrayKlassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
void objArrayKlassKlass::oop_print_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  objArrayKlass* oak = (objArrayKlass*) klassOop(obj)->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  klassKlass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  st->print(" - instance klass: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  oak->element_klass()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
void objArrayKlassKlass::oop_print_value_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  assert(obj->is_klass(), "must be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  objArrayKlass* oak = (objArrayKlass*) klassOop(obj)->klass_part();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  oak->element_klass()->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  st->print("[]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
const char* objArrayKlassKlass::internal_name() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  return "{object array class}";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
void objArrayKlassKlass::oop_verify_on(oop obj, outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  klassKlass::oop_verify_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  guarantee(oak->element_klass()->is_perm(),  "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  guarantee(oak->element_klass()->is_klass(), "should be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  guarantee(oak->bottom_klass()->is_perm(),   "should be in permspace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  guarantee(oak->bottom_klass()->is_klass(),  "should be klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  Klass* bk = Klass::cast(oak->bottom_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(),  "invalid bottom klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
}