src/hotspot/share/oops/objArrayKlass.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 58722 cba8afa5cfed
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53152
08db5aa02f7b 8216189: Remove Klass::compute_is_subtype_of
redestad
parents: 52619
diff changeset
     2
 * Copyright (c) 1997, 2019, 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"
38094
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
    26
#include "classfile/moduleEntry.hpp"
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
    27
#include "classfile/packageEntry.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    28
#include "classfile/symbolTable.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    29
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    30
#include "classfile/vmSymbols.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    31
#include "gc/shared/collectedHeap.inline.hpp"
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 24351
diff changeset
    32
#include "memory/iterator.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    33
#include "memory/metadataFactory.hpp"
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
    34
#include "memory/metaspaceClosure.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    35
#include "memory/resourceArea.hpp"
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47998
diff changeset
    36
#include "memory/universe.hpp"
40887
8d35e19f5548 8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents: 38094
diff changeset
    37
#include "oops/arrayKlass.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    38
#include "oops/instanceKlass.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    39
#include "oops/klass.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    40
#include "oops/objArrayKlass.inline.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27680
diff changeset
    41
#include "oops/objArrayOop.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    42
#include "oops/oop.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7890
diff changeset
    43
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    44
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    45
#include "runtime/mutexLocker.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14588
diff changeset
    46
#include "utilities/macros.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    48
ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS) {
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    49
  assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(),
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    50
      "array klasses must be same size as InstanceKlass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    51
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    52
  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
    53
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    54
  return new (loader_data, size, THREAD) ObjArrayKlass(n, k, name);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    55
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    56
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    57
Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    58
                                                int n, Klass* element_klass, TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    59
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    60
  // Eagerly allocate the direct array supertype.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    61
  Klass* super_klass = NULL;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    62
  if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    63
    Klass* element_super = element_klass->super();
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    64
    if (element_super != NULL) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    65
      // The element type has a direct super.  E.g., String[] has direct super of Object[].
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    66
      super_klass = element_super->array_klass_or_null();
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    67
      bool supers_exist = super_klass != NULL;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    68
      // Also, see if the element has secondary supertypes.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    69
      // We need an array type for each.
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51268
diff changeset
    70
      const Array<Klass*>* element_supers = element_klass->secondary_supers();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    71
      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
    72
        Klass* elem_super = element_supers->at(i);
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13961
diff changeset
    73
        if (elem_super->array_klass_or_null() == NULL) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    74
          supers_exist = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    75
          break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    76
        }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    77
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    78
      if (!supers_exist) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    79
        // Oops.  Not allocated yet.  Back out, allocate it, and retry.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    80
        Klass* ek = NULL;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    81
        {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    82
          MutexUnlocker mu(MultiArray_lock);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    83
          super_klass = element_super->array_klass(CHECK_0);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    84
          for( int i = element_supers->length()-1; i >= 0; i-- ) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    85
            Klass* elem_super = element_supers->at(i);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    86
            elem_super->array_klass(CHECK_0);
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
          // Now retry from the beginning
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    89
          ek = element_klass->array_klass(n, CHECK_0);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    90
        }  // re-lock
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    91
        return ek;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    92
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    93
    } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    94
      // The element type is already Object.  Object[] has direct super of Object.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
    95
      super_klass = SystemDictionary::Object_klass();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    96
    }
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
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
    99
  // Create type name for klass.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   100
  Symbol* name = NULL;
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   101
  if (!element_klass->is_instance_klass() ||
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   102
      (name = InstanceKlass::cast(element_klass)->array_name()) == NULL) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   103
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   104
    ResourceMark rm(THREAD);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   105
    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
   106
    int len = element_klass->name()->utf8_length();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   107
    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
   108
    int idx = 0;
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58177
diff changeset
   109
    new_str[idx++] = JVM_SIGNATURE_ARRAY;
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   110
    if (element_klass->is_instance_klass()) { // it could be an array or simple type
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58177
diff changeset
   111
      new_str[idx++] = JVM_SIGNATURE_CLASS;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   112
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   113
    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
   114
    idx += len;
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   115
    if (element_klass->is_instance_klass()) {
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58177
diff changeset
   116
      new_str[idx++] = JVM_SIGNATURE_ENDCLASS;
13728
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
    new_str[idx++] = '\0';
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54761
diff changeset
   119
    name = SymbolTable::new_permanent_symbol(new_str);
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   120
    if (element_klass->is_instance_klass()) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   121
      InstanceKlass* ik = InstanceKlass::cast(element_klass);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   122
      ik->set_array_name(name);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   123
    }
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
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   126
  // Initialize instance variables
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   127
  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
   128
38094
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   129
  ModuleEntry* module = oak->module();
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 33611
diff changeset
   130
  assert(module != NULL, "No module entry for array");
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 33611
diff changeset
   131
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   132
  // Call complete_create_array_klass after all instance variables has been initialized.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 33611
diff changeset
   133
  ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_0);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   134
54761
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   135
  // Add all classes to our internal class loader list here,
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   136
  // including classes in the bootstrap (NULL) class loader.
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   137
  // Do this step after creating the mirror so that if the
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   138
  // mirror creation fails, loaded_classes_do() doesn't find
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   139
  // an array class without a mirror.
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   140
  loader_data->add_class(oak);
a5b33a664b4f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
hseigel
parents: 53152
diff changeset
   141
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   142
  return oak;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   143
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   144
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50601
diff changeset
   145
ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, ID) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   146
  this->set_dimension(n);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   147
  this->set_element_klass(element_klass);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   148
  // 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
   149
  // 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
   150
  // loaded.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   151
  name->decrement_refcount();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   152
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   153
  Klass* bk;
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   154
  if (element_klass->is_objArray_klass()) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   155
    bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   156
  } else {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   157
    bk = element_klass;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   158
  }
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   159
  assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   160
  this->set_bottom_klass(bk);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   161
  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
   162
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   163
  this->set_layout_helper(array_layout_helper(T_OBJECT));
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   164
  assert(this->is_array_klass(), "sanity");
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   165
  assert(this->is_objArray_klass(), "sanity");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   166
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   167
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   168
int ObjArrayKlass::oop_size(oop obj) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  assert(obj->is_objArray(), "must be object array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  return objArrayOop(obj)->object_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   173
objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51349
diff changeset
   174
  check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_0);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51349
diff changeset
   175
  int size = objArrayOopDesc::object_size(length);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51349
diff changeset
   176
  return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51349
diff changeset
   177
                                                       /* do_zero */ true, THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
static int multi_alloc_counter = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   182
oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  int length = *sizes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // Call to lower_dimension uses this pointer, so most be called before a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // possible GC
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   186
  Klass* ld_klass = lower_dimension();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // If length < 0 allocate will throw an exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  objArrayOop array = allocate(length, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  objArrayHandle h_array (THREAD, array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  if (rank > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    if (length != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      for (int index = 0; index < length; index++) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 40887
diff changeset
   193
        ArrayKlass* ak = ArrayKlass::cast(ld_klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
        oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
        h_array->obj_at_put(index, sub_array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      // Since this array dimension has zero length, nothing will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      // allocated, however the lower dimension values must be checked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      // for illegal values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
      for (int i = 0; i < rank - 1; ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        sizes += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
        if (*sizes < 0) {
50304
d5331b94f821 8203881: Print erroneous size in NegativeArraySizeException
goetz
parents: 50094
diff changeset
   204
          THROW_MSG_0(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", *sizes));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  return h_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   212
// Either oop or narrowOop depending on UseCompressedOops.
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   213
void ObjArrayKlass::do_copy(arrayOop s, size_t src_offset,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   214
                            arrayOop d, size_t dst_offset, int length, TRAPS) {
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 57745
diff changeset
   215
  if (s == d) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   216
    // 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
   217
    assert(length > 0, "sanity check");
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   218
    ArrayAccess<>::oop_arraycopy(s, src_offset, d, dst_offset, length);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   219
  } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   220
    // 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
   221
    Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   222
    Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13961
diff changeset
   223
    if (stype == bound || stype->is_subtype_of(bound)) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   224
      // elements are guaranteed to be subtypes, so no check necessary
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   225
      ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   226
    } else {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   227
      // 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
   228
      // note: don't use obj_at_put below because it includes a redundant store check
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   229
      if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) {
50601
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   230
        ResourceMark rm(THREAD);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   231
        stringStream ss;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   232
        if (!bound->is_subtype_of(stype)) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   233
          ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]",
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   234
                   stype->external_name(), bound->external_name());
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   235
        } else {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   236
          // oop_arraycopy should return the index in the source array that
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   237
          // contains the problematic oop.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   238
          ss.print("arraycopy: element type mismatch: can not cast one of the elements"
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   239
                   " of %s[] to the type of the destination array, %s",
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   240
                   stype->external_name(), bound->external_name());
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   241
        }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   242
        THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string());
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   243
      }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   244
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   245
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   246
}
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   247
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   248
void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
                               int dst_pos, int length, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  assert(s->is_objArray(), "must be obj array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  if (!d->is_objArray()) {
50601
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   253
    ResourceMark rm(THREAD);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   254
    stringStream ss;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   255
    if (d->is_typeArray()) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   256
      ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]",
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   257
               type2name_tab[ArrayKlass::cast(d->klass())->element_type()]);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   258
    } else {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   259
      ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name());
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   260
    }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   261
    THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  // Check is all offsets and lengths are non negative
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  if (src_pos < 0 || dst_pos < 0 || length < 0) {
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   266
    // Pass specific exception reason.
50601
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   267
    ResourceMark rm(THREAD);
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   268
    stringStream ss;
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   269
    if (src_pos < 0) {
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   270
      ss.print("arraycopy: source index %d out of bounds for object array[%d]",
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   271
               src_pos, s->length());
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   272
    } else if (dst_pos < 0) {
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   273
      ss.print("arraycopy: destination index %d out of bounds for object array[%d]",
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   274
               dst_pos, d->length());
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   275
    } else {
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   276
      ss.print("arraycopy: length %d is negative", length);
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   277
    }
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   278
    THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  // Check if the ranges are valid
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   281
  if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) ||
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   282
      (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) {
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   283
    // Pass specific exception reason.
50601
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents: 50389
diff changeset
   284
    ResourceMark rm(THREAD);
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   285
    stringStream ss;
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   286
    if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   287
      ss.print("arraycopy: last source index %u out of bounds for object array[%d]",
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   288
               (unsigned int) length + (unsigned int) src_pos, s->length());
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   289
    } else {
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   290
      ss.print("arraycopy: last destination index %u out of bounds for object array[%d]",
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   291
               (unsigned int) length + (unsigned int) dst_pos, d->length());
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   292
    }
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49948
diff changeset
   293
    THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // Special case. Boundary cases must be checked first
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  // This allows the following call: copy_array(s, s.length(), d.length(), 0).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  // 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
   299
  // points to the right of the last element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  if (length==0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   303
  if (UseCompressedOops) {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   304
    size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   305
    size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   306
    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
51349
343f580476d6 8204969: Asserts in objArrayKlass.cpp need to use _raw variants of obj_addr_at()
rkennke
parents: 51329
diff changeset
   307
           objArrayOop(s)->obj_at_addr_raw<narrowOop>(src_pos), "sanity");
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   308
    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
51349
343f580476d6 8204969: Asserts in objArrayKlass.cpp need to use _raw variants of obj_addr_at()
rkennke
parents: 51329
diff changeset
   309
           objArrayOop(d)->obj_at_addr_raw<narrowOop>(dst_pos), "sanity");
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   310
    do_copy(s, src_offset, d, dst_offset, length, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  } else {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   312
    size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   313
    size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   314
    assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
51349
343f580476d6 8204969: Asserts in objArrayKlass.cpp need to use _raw variants of obj_addr_at()
rkennke
parents: 51329
diff changeset
   315
           objArrayOop(s)->obj_at_addr_raw<oop>(src_pos), "sanity");
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   316
    assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
51349
343f580476d6 8204969: Asserts in objArrayKlass.cpp need to use _raw variants of obj_addr_at()
rkennke
parents: 51329
diff changeset
   317
           objArrayOop(d)->obj_at_addr_raw<oop>(dst_pos), "sanity");
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50304
diff changeset
   318
    do_copy(s, src_offset, d, dst_offset, length, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   323
Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   325
  assert(dimension() <= n, "check order of chain");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   326
  int dim = dimension();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   327
  if (dim == n) return this;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
40887
8d35e19f5548 8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents: 38094
diff changeset
   329
  // lock-free read needs acquire semantics
8d35e19f5548 8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents: 38094
diff changeset
   330
  if (higher_dimension_acquire() == NULL) {
57745
789e967c2731 5103339: Strengthen NoSafepointVerifier
coleenp
parents: 54847
diff changeset
   331
    if (or_null) return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    JavaThread *jt = (JavaThread *)THREAD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      // Ensure atomic creation of higher dimensions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      MutexLocker mu(MultiArray_lock, THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      // Check if another thread beat us
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   340
      if (higher_dimension() == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        // 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
   343
        Klass* k =
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   344
          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
   345
        ObjArrayKlass* ak = ObjArrayKlass::cast(k);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   346
        ak->set_lower_dimension(this);
40887
8d35e19f5548 8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents: 38094
diff changeset
   347
        // use 'release' to pair with lock-free load
8d35e19f5548 8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents: 38094
diff changeset
   348
        release_set_higher_dimension(ak);
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   349
        assert(ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   354
  ObjArrayKlass *ak = ObjArrayKlass::cast(higher_dimension());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  if (or_null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    return ak->array_klass_or_null(n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  }
57745
789e967c2731 5103339: Strengthen NoSafepointVerifier
coleenp
parents: 54847
diff changeset
   358
  THREAD->check_possible_safepoint();
27680
8ecc0871c18e 8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents: 26316
diff changeset
   359
  return ak->array_klass(n, THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   362
Klass* ObjArrayKlass::array_klass_impl(bool or_null, TRAPS) {
27680
8ecc0871c18e 8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents: 26316
diff changeset
   363
  return array_klass_impl(or_null, dimension() +  1, THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   366
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
   367
  if (!bottom_klass()->can_be_primary_super())
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    // array of interfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    return Klass::can_be_primary_super_slow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
49948
ff8dbb56740a 8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents: 49658
diff changeset
   374
GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots,
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51268
diff changeset
   375
                                                               Array<InstanceKlass*>* transitive_interfaces) {
49948
ff8dbb56740a 8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents: 49658
diff changeset
   376
  assert(transitive_interfaces == NULL, "sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51268
diff changeset
   378
  const Array<Klass*>* elem_supers = element_klass()->secondary_supers();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   379
  int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  int num_secondaries = num_extra_slots + 2 + num_elem_supers;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  if (num_secondaries == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    // Must share this for correct bootstrapping!
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   383
    set_secondary_supers(Universe::the_array_interfaces_array());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   384
    return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   386
    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
   387
    secondaries->push(SystemDictionary::Cloneable_klass());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   388
    secondaries->push(SystemDictionary::Serializable_klass());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    for (int i = 0; i < num_elem_supers; i++) {
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51268
diff changeset
   390
      Klass* elem_super = elem_supers->at(i);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   391
      Klass* array_super = elem_super->array_klass_or_null();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
      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
   393
      secondaries->push(array_super);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   395
    return secondaries;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   399
void ObjArrayKlass::initialize(TRAPS) {
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13961
diff changeset
   400
  bottom_klass()->initialize(THREAD);  // dispatches to either InstanceKlass or TypeArrayKlass
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
   403
void ObjArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
   404
  ArrayKlass::metaspace_pointers_do(it);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
   405
  it->push(&_element_klass);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
   406
  it->push(&_bottom_klass);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
   407
}
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46329
diff changeset
   408
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
// JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   411
jint ObjArrayKlass::compute_modifier_flags(TRAPS) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // The modifier for an objectArray is the same as its element
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  if (element_klass() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    assert(Universe::is_bootstrapping(), "partial objArray only at startup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  }
1430
16aa7ef1ffa1 6700107: java/lang/Class/forName/TooManyDimensions.java crashes with SIGSEGV in c2 compiler with fastdebug
coleenp
parents: 1388
diff changeset
   417
  // Return the flags of the bottom element type.
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13961
diff changeset
   418
  jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
                        | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
38094
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   424
ModuleEntry* ObjArrayKlass::module() const {
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   425
  assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   426
  // The array is defined in the module of its bottom class
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   427
  return bottom_klass()->module();
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   428
}
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   429
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   430
PackageEntry* ObjArrayKlass::package() const {
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   431
  assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   432
  return bottom_klass()->package();
46977cd73d86 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents: 37190
diff changeset
   433
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   435
// Printing
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   436
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   437
void ObjArrayKlass::print_on(outputStream* st) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
#ifndef PRODUCT
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   439
  Klass::print_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   440
  st->print(" - instance klass: ");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   441
  element_klass()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   442
  st->cr();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   443
#endif //PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   444
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   445
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   446
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
   447
  assert(is_klass(), "must be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   448
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   449
  element_klass()->print_value_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   450
  st->print("[]");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   451
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   452
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   453
#ifndef PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   455
void ObjArrayKlass::oop_print_on(oop obj, outputStream* st) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   456
  ArrayKlass::oop_print_on(obj, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  assert(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  for(int index = 0; index < print_len; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    st->print(" - %3d : ", index);
51268
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   462
    if (oa->obj_at(index) != NULL) {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   463
      oa->obj_at(index)->print_value_on(st);
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   464
      st->cr();
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   465
    } else {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   466
      st->print_cr("NULL");
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   467
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  int remaining = oa->length() - print_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  if (remaining > 0) {
13922
ab7d352debe6 8000227: [obj|type]ArrayKlass::oop_print_on prints one line to tty instead of the provided output stream
stefank
parents: 13728
diff changeset
   471
    st->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 4571
diff changeset
   475
#endif //PRODUCT
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 4571
diff changeset
   476
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   477
void ObjArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  assert(obj->is_objArray(), "must be objArray");
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   479
  st->print("a ");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  element_klass()->print_value_on(st);
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   481
  int len = objArrayOop(obj)->length();
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1430
diff changeset
   482
  st->print("[%d] ", len);
51268
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   483
  if (obj != NULL) {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   484
    obj->print_address_on(st);
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   485
  } else {
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   486
    st->print_cr("NULL");
4ac20e5f96ce 8202171: Some oopDesc functions compare this with NULL
hseigel
parents: 50882
diff changeset
   487
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   490
const char* ObjArrayKlass::internal_name() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  return external_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   494
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
22794
f1c014ad3754 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents: 22234
diff changeset
   497
void ObjArrayKlass::verify_on(outputStream* st) {
f1c014ad3754 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents: 22234
diff changeset
   498
  ArrayKlass::verify_on(st);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   499
  guarantee(element_klass()->is_klass(), "should be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   500
  guarantee(bottom_klass()->is_klass(), "should be klass");
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13961
diff changeset
   501
  Klass* bk = bottom_klass();
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 31592
diff changeset
   502
  guarantee(bk->is_instance_klass() || bk->is_typeArray_klass(),  "invalid bottom klass");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   503
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12379
diff changeset
   504
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   505
void ObjArrayKlass::oop_verify_on(oop obj, outputStream* st) {
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   506
  ArrayKlass::oop_verify_on(obj, st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  guarantee(obj->is_objArray(), "must be objArray");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  objArrayOop oa = objArrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  for(int index = 0; index < oa->length(); index++) {
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46746
diff changeset
   510
    guarantee(oopDesc::is_oop_or_null(oa->obj_at(index)), "should be oop");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
}