hotspot/src/share/vm/oops/objArrayKlass.cpp
author coleenp
Sat, 29 Sep 2012 06:40:00 -0400
changeset 13952 e3cf184080bc
parent 13728 882756847a04
child 13961 aeaa21c167d1
permissions -rw-r--r--
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass Summary: Capitalize these metadata types (and objArrayKlass) Reviewed-by: stefank, twisti, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12114
9a825a536095 7123170: JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
sspitsyn
parents: 8297
diff changeset
     2
 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    25
#include "precompiled.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    26
#include "classfile/symbolTable.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    28
#include "classfile/vmSymbols.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    29
#include "gc_implementation/shared/markSweep.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    30
#include "gc_interface/collectedHeap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    31
#include "memory/genOopClosures.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    32
#include "memory/metadataFactory.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    33
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    34
#include "memory/universe.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    35
#include "oops/instanceKlass.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    36
#include "oops/klass.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    37
#include "oops/objArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    38
#include "oops/objArrayKlass.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    39
#include "oops/objArrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    40
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    41
#include "oops/oop.inline2.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7890
diff changeset
    42
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    43
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    44
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    45
#include "utilities/copy.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    46
#ifndef SERIALGC
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    47
#include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    48
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    49
#include "gc_implementation/g1/g1OopClosures.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    50
#include "gc_implementation/g1/g1RemSet.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    51
#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    52
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    53
#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    54
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    55
#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    56
#include "oops/oop.pcgc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    57
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    59
ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    60
  assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(),
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    61
      "array klasses must be same size as InstanceKlass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    62
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    63
  int size = ArrayKlass::static_size(ObjArrayKlass::header_size());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    64
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    65
  return new (loader_data, size, THREAD) ObjArrayKlass(n, klass_handle, name);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    66
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    67
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    68
Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    69
                                                int n, KlassHandle element_klass, TRAPS) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    70
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    71
  // Eagerly allocate the direct array supertype.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    72
  KlassHandle super_klass = KlassHandle();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    73
  if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    74
    KlassHandle element_super (THREAD, element_klass->super());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    75
    if (element_super.not_null()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    76
      // The element type has a direct super.  E.g., String[] has direct super of Object[].
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    77
      super_klass = KlassHandle(THREAD, element_super->array_klass_or_null());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    78
      bool supers_exist = super_klass.not_null();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    79
      // Also, see if the element has secondary supertypes.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    80
      // We need an array type for each.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    81
      Array<Klass*>* element_supers = element_klass->secondary_supers();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    82
      for( int i = element_supers->length()-1; i >= 0; i-- ) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    83
        Klass* elem_super = element_supers->at(i);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    84
        if (Klass::cast(elem_super)->array_klass_or_null() == NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    85
          supers_exist = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    86
          break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    87
        }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    88
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    89
      if (!supers_exist) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    90
        // Oops.  Not allocated yet.  Back out, allocate it, and retry.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    91
#ifndef PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    92
        if (WizardMode) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    93
          tty->print_cr("Must retry array klass creation for depth %d",n);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    94
        }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    95
#endif
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    96
        KlassHandle ek;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    97
        {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    98
          MutexUnlocker mu(MultiArray_lock);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    99
          MutexUnlocker mc(Compile_lock);   // for vtables
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   100
          Klass* sk = element_super->array_klass(CHECK_0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   101
          super_klass = KlassHandle(THREAD, sk);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   102
          for( int i = element_supers->length()-1; i >= 0; i-- ) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   103
            KlassHandle elem_super (THREAD, element_supers->at(i));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   104
            elem_super->array_klass(CHECK_0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   105
          }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   106
          // Now retry from the beginning
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   107
          Klass* klass_oop = element_klass->array_klass(n, CHECK_0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   108
          // Create a handle because the enclosing brace, when locking
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   109
          // can cause a gc.  Better to have this function return a Handle.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   110
          ek = KlassHandle(THREAD, klass_oop);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   111
        }  // re-lock
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   112
        return ek();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   113
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   114
    } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   115
      // The element type is already Object.  Object[] has direct super of Object.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   116
      super_klass = KlassHandle(THREAD, SystemDictionary::Object_klass());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   117
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   118
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   119
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   120
  // Create type name for klass.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   121
  Symbol* name = NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   122
  if (!element_klass->oop_is_instance() ||
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   123
      (name = InstanceKlass::cast(element_klass())->array_name()) == NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   124
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   125
    ResourceMark rm(THREAD);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   126
    char *name_str = element_klass->name()->as_C_string();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   127
    int len = element_klass->name()->utf8_length();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   128
    char *new_str = NEW_RESOURCE_ARRAY(char, len + 4);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   129
    int idx = 0;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   130
    new_str[idx++] = '[';
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   131
    if (element_klass->oop_is_instance()) { // it could be an array or simple type
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   132
      new_str[idx++] = 'L';
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   133
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   134
    memcpy(&new_str[idx], name_str, len * sizeof(char));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   135
    idx += len;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   136
    if (element_klass->oop_is_instance()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   137
      new_str[idx++] = ';';
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   138
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   139
    new_str[idx++] = '\0';
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   140
    name = SymbolTable::new_permanent_symbol(new_str, CHECK_0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   141
    if (element_klass->oop_is_instance()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   142
      InstanceKlass* ik = InstanceKlass::cast(element_klass());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   143
      ik->set_array_name(name);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   144
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   145
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   146
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   147
  // Initialize instance variables
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   148
  ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_0);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   149
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   150
  // Add all classes to our internal class loader list here,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   151
  // including classes in the bootstrap (NULL) class loader.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   152
  // GC walks these as strong roots.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   153
  loader_data->add_class(oak);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   154
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   155
  // Call complete_create_array_klass after all instance variables has been initialized.
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   156
  ArrayKlass::complete_create_array_klass(oak, super_klass, CHECK_0);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   157
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   158
  return oak;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   159
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   160
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   161
ObjArrayKlass::ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name) : ArrayKlass(name) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   162
  this->set_dimension(n);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   163
  this->set_element_klass(element_klass());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   164
  // decrement refcount because object arrays are not explicitly freed.  The
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   165
  // InstanceKlass array_name() keeps the name counted while the klass is
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   166
  // loaded.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   167
  name->decrement_refcount();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   168
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   169
  Klass* bk;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   170
  if (element_klass->oop_is_objArray()) {
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   171
    bk = ObjArrayKlass::cast(element_klass())->bottom_klass();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   172
  } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   173
    bk = element_klass();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   174
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   175
  assert(bk != NULL && (Klass::cast(bk)->oop_is_instance() || Klass::cast(bk)->oop_is_typeArray()), "invalid bottom klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   176
  this->set_bottom_klass(bk);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   177
  this->set_class_loader_data(bk->class_loader_data());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   178
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   179
  this->set_layout_helper(array_layout_helper(T_OBJECT));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   180
  assert(this->oop_is_array(), "sanity");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   181
  assert(this->oop_is_objArray(), "sanity");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   182
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   183
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   184
int ObjArrayKlass::oop_size(oop obj) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  assert(obj->is_objArray(), "must be object array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  return objArrayOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   189
objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  if (length >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    if (length <= arrayOopDesc::max_array_length(T_OBJECT)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      int size = objArrayOopDesc::object_size(length);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   193
      KlassHandle h_k(THREAD, this);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   194
      return (objArrayOop)CollectedHeap::array_allocate(h_k, size, length, CHECK_NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    } else {
3576
4ceec8fb3e18 6850957: Honor -XX:OnOutOfMemoryError when array size exceeds VM limit
martin
parents: 2332
diff changeset
   196
      report_java_out_of_memory("Requested array size exceeds VM limit");
12114
9a825a536095 7123170: JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
sspitsyn
parents: 8297
diff changeset
   197
      JvmtiExport::post_array_size_exhausted();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      THROW_OOP_0(Universe::out_of_memory_error_array_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
static int multi_alloc_counter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   207
oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  int length = *sizes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // Call to lower_dimension uses this pointer, so most be called before a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  // possible GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  KlassHandle h_lower_dimension(THREAD, lower_dimension());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // If length < 0 allocate will throw an exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  objArrayOop array = allocate(length, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  objArrayHandle h_array (THREAD, array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  if (rank > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    if (length != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      for (int index = 0; index < length; index++) {
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   218
        ArrayKlass* ak = ArrayKlass::cast(h_lower_dimension());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
        oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
        h_array->obj_at_put(index, sub_array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      // Since this array dimension has zero length, nothing will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
      // allocated, however the lower dimension values must be checked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      // for illegal values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      for (int i = 0; i < rank - 1; ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        sizes += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
        if (*sizes < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
          THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  return h_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   237
// Either oop or narrowOop depending on UseCompressedOops.
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   238
template <class T> void ObjArrayKlass::do_copy(arrayOop s, T* src,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   239
                               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
   240
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   241
  BarrierSet* bs = Universe::heap()->barrier_set();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   242
  // For performance reasons, we assume we are that the write barrier we
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   243
  // are using has optimized modes for arrays of references.  At least one
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   244
  // of the asserts below will fail if this is not the case.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   245
  assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   246
  assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   247
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   248
  if (s == d) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   249
    // 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
   250
    assert(length > 0, "sanity check");
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 2332
diff changeset
   251
    bs->write_ref_array_pre(dst, length);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   252
    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
   253
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   254
    // We have to make sure all elements conform to the destination array
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   255
    Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   256
    Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   257
    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
   258
      // elements are guaranteed to be subtypes, so no check necessary
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 2332
diff changeset
   259
      bs->write_ref_array_pre(dst, length);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   260
      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
   261
    } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   262
      // 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
   263
      // 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
   264
      T* from = src;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   265
      T* end = from + length;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   266
      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
   267
        // 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
   268
        T element = *from;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   269
        // even slower now
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   270
        bool element_is_null = oopDesc::is_null(element);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   271
        oop new_val = element_is_null ? oop(NULL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   272
                                      : oopDesc::decode_heap_oop_not_null(element);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   273
        if (element_is_null ||
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   274
            Klass::cast((new_val->klass()))->is_subtype_of(bound)) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   275
          bs->write_ref_field_pre(p, new_val);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   276
          *p = *from;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   277
        } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   278
          // 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
   279
          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
   280
          // 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
   281
          // 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
   282
          assert(pd == (size_t)(int)pd, "length field overflow");
4461
c17c526d36ef 6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents: 3579
diff changeset
   283
          bs->write_ref_array((HeapWord*)dst, pd);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   284
          THROW(vmSymbols::java_lang_ArrayStoreException());
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   285
          return;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   286
        }
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
  }
4461
c17c526d36ef 6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents: 3579
diff changeset
   290
  bs->write_ref_array((HeapWord*)dst, length);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   291
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   292
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   293
void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
                               int dst_pos, int length, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  assert(s->is_objArray(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  if (!d->is_objArray()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    THROW(vmSymbols::java_lang_ArrayStoreException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // Check is all offsets and lengths are non negative
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  if (src_pos < 0 || dst_pos < 0 || length < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // Check if the ranges are valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
     || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // Special case. Boundary cases must be checked first
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // This allows the following call: copy_array(s, s.length(), d.length(), 0).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // 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
   314
  // points to the right of the last element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  if (length==0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   318
  if (UseCompressedOops) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   319
    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
   320
    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
   321
    do_copy<narrowOop>(s, src, d, dst, length, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  } else {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   323
    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
   324
    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
   325
    do_copy<oop> (s, src, d, dst, length, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   330
Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   332
  assert(dimension() <= n, "check order of chain");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   333
  int dim = dimension();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   334
  if (dim == n) return this;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   336
  if (higher_dimension() == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    if (or_null)  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    JavaThread *jt = (JavaThread *)THREAD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      MutexLocker mc(Compile_lock, THREAD);   // for vtables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
      // Ensure atomic creation of higher dimensions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
      MutexLocker mu(MultiArray_lock, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
      // Check if another thread beat us
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   347
      if (higher_dimension() == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        // Create multi-dim klass object and link them together
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   350
        Klass* k =
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   351
          ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, CHECK_NULL);
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   352
        ObjArrayKlass* ak = ObjArrayKlass::cast(k);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   353
        ak->set_lower_dimension(this);
7890
7d1d76674e2e 7011386: race in objArrayKlass::array_klass_impl
kvn
parents: 7397
diff changeset
   354
        OrderAccess::storestore();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   355
        set_higher_dimension(ak);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   356
        assert(ak->oop_is_objArray(), "incorrect initialization of ObjArrayKlass");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   363
  ObjArrayKlass *ak = ObjArrayKlass::cast(higher_dimension());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  if (or_null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    return ak->array_klass_or_null(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  return ak->array_klass(n, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   370
Klass* ObjArrayKlass::array_klass_impl(bool or_null, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  return array_klass_impl(or_null, dimension() +  1, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   374
bool ObjArrayKlass::can_be_primary_super_slow() const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   375
  if (!bottom_klass()->can_be_primary_super())
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    // array of interfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    return Klass::can_be_primary_super_slow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   382
GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   384
  Array<Klass*>* elem_supers = Klass::cast(element_klass())->secondary_supers();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   385
  int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  int num_secondaries = num_extra_slots + 2 + num_elem_supers;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  if (num_secondaries == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
    // Must share this for correct bootstrapping!
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   389
    set_secondary_supers(Universe::the_array_interfaces_array());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   390
    return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   392
    GrowableArray<Klass*>* secondaries = new GrowableArray<Klass*>(num_elem_supers+2);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   393
    secondaries->push(SystemDictionary::Cloneable_klass());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   394
    secondaries->push(SystemDictionary::Serializable_klass());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    for (int i = 0; i < num_elem_supers; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   396
      Klass* elem_super = (Klass*) elem_supers->at(i);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   397
      Klass* array_super = elem_super->array_klass_or_null();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      assert(array_super != NULL, "must already have been created");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   399
      secondaries->push(array_super);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   401
    return secondaries;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   405
bool ObjArrayKlass::compute_is_subtype_of(Klass* k) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   406
  if (!k->oop_is_objArray())
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   407
    return ArrayKlass::compute_is_subtype_of(k);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   409
  ObjArrayKlass* oak = ObjArrayKlass::cast(k);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   410
  return element_klass()->is_subtype_of(oak->element_klass());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   413
void ObjArrayKlass::initialize(TRAPS) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   414
  Klass::cast(bottom_klass())->initialize(THREAD);  // dispatches to either InstanceKlass or TypeArrayKlass
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   417
#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
   418
{                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   419
  T* p         = (T*)(a)->base();   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   420
  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
   421
  while (p < end) {                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   422
    do_oop;                         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   423
    p++;                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   424
  }                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   425
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   426
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   427
#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
   428
{                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   429
  T* const l = (T*)(low);           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   430
  T* const h = (T*)(high);          \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   431
  T* p       = (T*)(a)->base();     \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   432
  T* end     = p + (a)->length();   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   433
  if (p < l) p = l;                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   434
  if (end > h) end = h;             \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   435
  while (p < end) {                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   436
    do_oop;                         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   437
    ++p;                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   438
  }                                 \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   439
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   440
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   441
#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
   442
  if (UseCompressedOops) {                           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   443
    ObjArrayKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   444
      a, p, do_oop)                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   445
  } else {                                           \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   446
    ObjArrayKlass_SPECIALIZED_OOP_ITERATE(oop,       \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   447
      a, p, do_oop)                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   448
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   449
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   450
#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
   451
  if (UseCompressedOops) {                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   452
    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
   453
      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
   454
  } else {                                                   \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   455
    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
   456
      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
   457
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   459
void ObjArrayKlass::oop_follow_contents(oop obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  assert (obj->is_array(), "obj must be array");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   461
  MarkSweep::follow_klass(obj->klass());
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   462
  if (UseCompressedOops) {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   463
    objarray_follow_contents<narrowOop>(obj, 0);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   464
  } else {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   465
    objarray_follow_contents<oop>(obj, 0);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   466
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
#ifndef SERIALGC
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   470
void ObjArrayKlass::oop_follow_contents(ParCompactionManager* cm,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
                                        oop obj) {
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   472
  assert(obj->is_array(), "obj must be array");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   473
  PSParallelCompact::follow_klass(cm, obj->klass());
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   474
  if (UseCompressedOops) {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   475
    objarray_follow_contents<narrowOop>(cm, obj, 0);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   476
  } else {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   477
    objarray_follow_contents<oop>(cm, obj, 0);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 4584
diff changeset
   478
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   482
#define if_do_metadata_checked(closure, nv_suffix)                    \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   483
  /* Make sure the non-virtual and the virtual versions match. */     \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   484
  assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   485
      "Inconsistency in do_metadata");                                \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   486
  if (closure->do_metadata##nv_suffix())
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   487
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
                                                                                \
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   490
int ObjArrayKlass::oop_oop_iterate##nv_suffix(oop obj,                          \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
                                              OopClosureType* closure) {        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  assert (obj->is_array(), "obj must be array");                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  objArrayOop a = objArrayOop(obj);                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  /* Get size before changing pointers. */                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  /* Don't call size() or oop_size() since that is a virtual call. */           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  int size = a->object_size();                                                  \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   498
  if_do_metadata_checked(closure, nv_suffix) {                                  \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   499
    closure->do_klass##nv_suffix(obj->klass());                                 \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  }                                                                             \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   501
  ObjArrayKlass_OOP_ITERATE(a, p, (closure)->do_oop##nv_suffix(p))              \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  return size;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
#define ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
                                                                                \
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   507
int ObjArrayKlass::oop_oop_iterate##nv_suffix##_m(oop obj,                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
                                                  OopClosureType* closure,      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
                                                  MemRegion mr) {               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  assert(obj->is_array(), "obj must be array");                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  objArrayOop a  = objArrayOop(obj);                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  /* Get size before changing pointers. */                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  /* Don't call size() or oop_size() since that is a virtual call */            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  int size = a->object_size();                                                  \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   516
  if_do_metadata_checked(closure, nv_suffix) {                                  \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   517
    /* SSS: Do we need to pass down mr here? */                                 \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   518
    closure->do_klass##nv_suffix(a->klass());                                   \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  }                                                                             \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   520
  ObjArrayKlass_BOUNDED_OOP_ITERATE(                                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   521
    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
   522
  return size;                                                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   523
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   524
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   525
// 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
   526
// for objArrayOops.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   527
#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
   528
                                                                                \
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   529
int ObjArrayKlass::oop_oop_iterate_range##nv_suffix(oop obj,                    \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   530
                                                  OopClosureType* closure,      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   531
                                                  int start, int end) {         \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   532
  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
   533
  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
   534
  objArrayOop a  = objArrayOop(obj);                                            \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   535
  /* Get size before changing pointers. */                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   536
  /* 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
   537
  int size = a->object_size();                                                  \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   538
  if (UseCompressedOops) {                                                      \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   539
    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
   540
    /* 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
   541
    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
   542
    MemRegion mr(low, high);                                                    \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   543
    if_do_metadata_checked(closure, nv_suffix) {                                \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   544
      /* SSS: Do we need to pass down mr here? */                               \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   545
      closure->do_klass##nv_suffix(a->klass());                                 \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    }                                                                           \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   547
    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
   548
      a, p, low, high, (closure)->do_oop##nv_suffix(p))                         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  } else {                                                                      \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   550
    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
   551
    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
   552
    MemRegion mr(low, high);                                                    \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   553
    if_do_metadata_checked(closure, nv_suffix) {                                \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   554
      /* SSS: Do we need to pass down mr here? */                               \
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   555
      closure->do_klass##nv_suffix(a->klass());                                 \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    }                                                                           \
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   557
    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
   558
      a, p, low, high, (closure)->do_oop##nv_suffix(p))                         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  return size;                                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   564
ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   566
ALL_OOP_OOP_ITERATE_CLOSURES_2(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
   567
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   568
ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   570
int ObjArrayKlass::oop_adjust_pointers(oop obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  assert(obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  objArrayOop a = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  // Get size before changing pointers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  // Don't call size() or oop_size() since that is a virtual call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  int size = a->object_size();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   576
  MarkSweep::adjust_klass(a->klass());
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   577
  ObjArrayKlass_OOP_ITERATE(a, p, MarkSweep::adjust_pointer(p))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  return size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
#ifndef SERIALGC
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   582
void ObjArrayKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  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
   584
  ObjArrayKlass_OOP_ITERATE( \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   585
    objArrayOop(obj), p, \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   586
    if (PSScavenge::should_scavenge(p)) { \
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   587
      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
   588
    })
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   591
int ObjArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  assert (obj->is_objArray(), "obj must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  objArrayOop a = objArrayOop(obj);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   594
  int size = a->object_size();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   595
  a->update_header(cm);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   596
  ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p))
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   597
  return size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
// JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   603
jint ObjArrayKlass::compute_modifier_flags(TRAPS) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  // The modifier for an objectArray is the same as its element
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  if (element_klass() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    assert(Universe::is_bootstrapping(), "partial objArray only at startup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  }
1430
16aa7ef1ffa1 6700107: java/lang/Class/forName/TooManyDimensions.java crashes with SIGSEGV in c2 compiler with fastdebug
coleenp
parents: 1388
diff changeset
   609
  // Return the flags of the bottom element type.
16aa7ef1ffa1 6700107: java/lang/Class/forName/TooManyDimensions.java crashes with SIGSEGV in c2 compiler with fastdebug
coleenp
parents: 1388
diff changeset
   610
  jint element_flags = Klass::cast(bottom_klass())->compute_modifier_flags(CHECK_0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
                        | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   617
// Printing
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   618
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   619
void ObjArrayKlass::print_on(outputStream* st) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
#ifndef PRODUCT
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   621
  Klass::print_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   622
  st->print(" - instance klass: ");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   623
  element_klass()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   624
  st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   625
#endif //PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   626
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   627
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   628
void ObjArrayKlass::print_value_on(outputStream* st) const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   629
  assert(is_klass(), "must be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   630
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   631
  element_klass()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   632
  st->print("[]");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   633
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   634
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   635
#ifndef PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   637
void ObjArrayKlass::oop_print_on(oop obj, outputStream* st) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   638
  ArrayKlass::oop_print_on(obj, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  assert(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  for(int index = 0; index < print_len; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    st->print(" - %3d : ", index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    oa->obj_at(index)->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
    st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  int remaining = oa->length() - print_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  if (remaining > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 4571
diff changeset
   653
#endif //PRODUCT
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 4571
diff changeset
   654
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   655
static int max_objArray_print_length = 4;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   657
void ObjArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  assert(obj->is_objArray(), "must be objArray");
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   659
  st->print("a ");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  element_klass()->print_value_on(st);
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   661
  int len = objArrayOop(obj)->length();
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   662
  st->print("[%d] ", len);
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   663
  obj->print_address_on(st);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 4571
diff changeset
   664
  if (NOT_PRODUCT(PrintOopAddress ||) PrintMiscellaneous && (WizardMode || Verbose)) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   665
    st->print("{");
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   666
    for (int i = 0; i < len; i++) {
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   667
      if (i > max_objArray_print_length) {
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   668
        st->print("..."); break;
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   669
      }
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   670
      st->print(" "INTPTR_FORMAT, (intptr_t)(void*)objArrayOop(obj)->obj_at(i));
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   671
    }
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   672
    st->print(" }");
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   673
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   676
const char* ObjArrayKlass::internal_name() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  return external_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   680
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   683
void ObjArrayKlass::verify_on(outputStream* st) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   684
  ArrayKlass::verify_on(st);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   685
  guarantee(element_klass()->is_metadata(), "should be in metaspace");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   686
  guarantee(element_klass()->is_klass(), "should be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   687
  guarantee(bottom_klass()->is_metadata(), "should be in metaspace");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   688
  guarantee(bottom_klass()->is_klass(), "should be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   689
  Klass* bk = Klass::cast(bottom_klass());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   690
  guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(),  "invalid bottom klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   691
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   692
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   693
void ObjArrayKlass::oop_verify_on(oop obj, outputStream* st) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   694
  ArrayKlass::oop_verify_on(obj, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  guarantee(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  for(int index = 0; index < oa->length(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    guarantee(oa->obj_at(index)->is_oop_or_null(), "should be oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
}