src/hotspot/share/oops/arrayKlass.cpp
author lfoltan
Mon, 16 Jul 2018 09:06:33 -0400
changeset 51096 695dff91a997
parent 50882 80abf702eed8
child 51329 9c68699bebe5
permissions -rw-r--r--
8178712: ResourceMark may be missing inside initialize_[vi]table Summary: Clean up use of ResourceMark within initialize_[vi]table. Reviewed-by: ccheung, iklam, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2018, 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: 4571
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4571
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: 4571
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: 6176
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    26
#include "classfile/javaClasses.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    28
#include "classfile/vmSymbols.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28731
diff changeset
    29
#include "gc/shared/collectedHeap.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    30
#include "jvmtifiles/jvmti.h"
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
    31
#include "memory/metaspaceClosure.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 36508
diff changeset
    32
#include "memory/resourceArea.hpp"
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
    33
#include "memory/universe.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    34
#include "oops/arrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    35
#include "oops/arrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    36
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    37
#include "oops/objArrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    38
#include "oops/oop.inline.hpp"
49393
93fe2fc5c093 8199472: Fix non-PCH build after JDK-8199319
simonis
parents: 49359
diff changeset
    39
#include "runtime/handles.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    41
int ArrayKlass::static_size(int header_size) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  // size of an array klass object
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
    43
  assert(header_size <= InstanceKlass::header_size(), "bad header size");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // If this assert fails, see comments in base_create_array_klass.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
    45
  header_size = InstanceKlass::header_size();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
    46
  int vtable_len = Universe::base_vtable_size();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
    47
  int size = header_size + vtable_len;
35898
ddc274f0052f 8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents: 35847
diff changeset
    48
  return align_metadata_size(size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    52
Klass* ArrayKlass::java_super() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  if (super() == NULL)  return NULL;  // bootstrap case
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Array klasses have primary supertypes which are not reported to Java.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Example super chain:  String[][] -> Object[][] -> Object[] -> Object
4571
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 3795
diff changeset
    56
  return SystemDictionary::Object_klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
    60
oop ArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
27020
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    65
// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    66
Klass* ArrayKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    67
  // There are no fields in an array klass but look to the super class (Object)
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    68
  assert(super(), "super klass must be present");
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    69
  return super()->find_field(name, sig, fd);
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    70
}
a7c8010446c2 8036805: Correct linker method lookup.
lfoltan
parents: 26927
diff changeset
    71
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    72
Method* ArrayKlass::uncached_lookup_method(const Symbol* name,
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    73
                                           const Symbol* signature,
50735
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 50304
diff changeset
    74
                                           OverpassLookupMode overpass_mode,
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 50304
diff changeset
    75
                                           PrivateLookupMode private_mode) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // There are no methods in an array klass but the super class (Object) has some
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  assert(super(), "super klass must be present");
28731
f7339cba0a6a 8067480: Crash in klassItable::initialize_itable_for_interface when running vm.runtime.defmeth.StaticMethodsTest.
lfoltan
parents: 27020
diff changeset
    78
  // Always ignore overpass methods in superclasses, although technically the
f7339cba0a6a 8067480: Crash in klassItable::initialize_itable_for_interface when running vm.runtime.defmeth.StaticMethodsTest.
lfoltan
parents: 27020
diff changeset
    79
  // super klass of an array, (j.l.Object) should not have
f7339cba0a6a 8067480: Crash in klassItable::initialize_itable_for_interface when running vm.runtime.defmeth.StaticMethodsTest.
lfoltan
parents: 27020
diff changeset
    80
  // any overpass methods present.
50735
2f2af62dfac7 8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents: 50304
diff changeset
    81
  return super()->uncached_lookup_method(name, signature, Klass::skip_overpass, private_mode);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50735
diff changeset
    84
ArrayKlass::ArrayKlass(Symbol* name, KlassID id) :
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 50735
diff changeset
    85
  Klass(id),
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    86
  _dimension(1),
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    87
  _higher_dimension(NULL),
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35898
diff changeset
    88
  _lower_dimension(NULL) {
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35898
diff changeset
    89
    // Arrays don't add any new methods, so their vtable is the same size as
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35898
diff changeset
    90
    // the vtable of klass Object.
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35898
diff changeset
    91
    set_vtable_length(Universe::base_vtable_size());
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    92
    set_name(name);
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    93
    set_super(Universe::is_bootstrapping() ? (Klass*)NULL : SystemDictionary::Object_klass());
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    94
    set_layout_helper(Klass::_lh_neutral_value);
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 30764
diff changeset
    95
    set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 49948
diff changeset
    96
    JFR_ONLY(INIT_ID(this);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// Initialization of vtables and mirror object is done separatly from base_create_array_klass,
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   101
// since a GC can happen. At this point all instance variables of the ArrayKlass must be setup.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46271
diff changeset
   102
void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) {
49948
ff8dbb56740a 8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents: 49594
diff changeset
   103
  k->initialize_supers(super_klass, NULL, CHECK);
46408
70aab0c2ea8b 8178350: klassVtable and klassItable should be ValueObj
iklam
parents: 46329
diff changeset
   104
  k->vtable().initialize_vtable(false, CHECK);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 36384
diff changeset
   105
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 36384
diff changeset
   106
  // During bootstrapping, before java.base is defined, the module_entry may not be present yet.
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 36384
diff changeset
   107
  // These classes will be put on a fixup list and their module fields will be patched once
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 36384
diff changeset
   108
  // java.base is defined.
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 36384
diff changeset
   109
  assert((module_entry != NULL) || ((module_entry == NULL) && !ModuleEntryTable::javabase_defined()),
42636
aafc434ba580 8169734: Update uses of string "java.base" to macro
rprotacio
parents: 37248
diff changeset
   110
         "module entry not available post " JAVA_BASE_NAME " definition");
46773
fb17cc9a6847 8185717: Make ModuleEntry->module() return an oop not a jobject
hseigel
parents: 46746
diff changeset
   111
  oop module = (module_entry != NULL) ? module_entry->module() : (oop)NULL;
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42639
diff changeset
   112
  java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(), CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
49948
ff8dbb56740a 8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents: 49594
diff changeset
   115
GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
ff8dbb56740a 8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents: 49594
diff changeset
   116
                                                            Array<Klass*>* transitive_interfaces) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // interfaces = { cloneable_klass, serializable_klass };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  assert(num_extra_slots == 0, "sanity of primitive array type");
49948
ff8dbb56740a 8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents: 49594
diff changeset
   119
  assert(transitive_interfaces == NULL, "sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Must share this for correct bootstrapping!
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   121
  set_secondary_supers(Universe::the_array_interfaces_array());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   122
  return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   125
bool ArrayKlass::compute_is_subtype_of(Klass* k) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // An array is a subtype of Serializable, Clonable, and Object
4571
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 3795
diff changeset
   127
  return    k == SystemDictionary::Object_klass()
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 3795
diff changeset
   128
         || k == SystemDictionary::Cloneable_klass()
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 3795
diff changeset
   129
         || k == SystemDictionary::Serializable_klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   132
objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  if (length < 0) {
50304
d5331b94f821 8203881: Print erroneous size in NegativeArraySizeException
goetz
parents: 50113
diff changeset
   134
    THROW_MSG_0(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", length));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  if (length > arrayOopDesc::max_array_length(T_ARRAY)) {
3576
4ceec8fb3e18 6850957: Honor -XX:OnOutOfMemoryError when array size exceeds VM limit
martin
parents: 1
diff changeset
   137
    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: 8921
diff changeset
   138
    JvmtiExport::post_array_size_exhausted();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    THROW_OOP_0(Universe::out_of_memory_error_array_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  int size = objArrayOopDesc::object_size(length);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   142
  Klass* k = array_klass(n+dimension(), CHECK_0);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   143
  ArrayKlass* ak = ArrayKlass::cast(k);
50882
80abf702eed8 8205683: Refactor heap allocation to separate concerns
eosterlund
parents: 50752
diff changeset
   144
  objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
80abf702eed8 8205683: Refactor heap allocation to separate concerns
eosterlund
parents: 50752
diff changeset
   145
                                                                /* do_zero */ true, CHECK_0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // initialization to NULL not necessary, area already cleared
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  return o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   150
void ArrayKlass::array_klasses_do(void f(Klass* k, TRAPS), TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   151
  Klass* k = this;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   152
  // Iterate over this array klass and all higher dimensions
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   153
  while (k != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   154
    f(k, CHECK);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   155
    k = ArrayKlass::cast(k)->higher_dimension();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   156
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   157
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   159
void ArrayKlass::array_klasses_do(void f(Klass* k)) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   160
  Klass* k = this;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // Iterate over this array klass and all higher dimensions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  while (k != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    f(k);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   164
    k = ArrayKlass::cast(k)->higher_dimension();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
// JVM support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   170
jint ArrayKlass::compute_modifier_flags(TRAPS) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
// JVMTI support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   176
jint ArrayKlass::jvmti_class_status() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  return JVMTI_CLASS_STATUS_ARRAY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   180
void ArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   181
  Klass::metaspace_pointers_do(it);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   182
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   183
  ResourceMark rm;
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   184
  log_trace(cds)("Iter(ArrayKlass): %p (%s)", this, external_name());
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   185
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   186
  // need to cast away volatile
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   187
  it->push((Klass**)&_higher_dimension);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   188
  it->push((Klass**)&_lower_dimension);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   189
}
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46408
diff changeset
   190
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   191
void ArrayKlass::remove_unshareable_info() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   192
  Klass::remove_unshareable_info();
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   193
  if (_higher_dimension != NULL) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   194
    ArrayKlass *ak = ArrayKlass::cast(higher_dimension());
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   195
    ak->remove_unshareable_info();
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   196
  }
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   197
}
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   198
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   199
void ArrayKlass::remove_java_mirror() {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   200
  Klass::remove_java_mirror();
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   201
  if (_higher_dimension != NULL) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   202
    ArrayKlass *ak = ArrayKlass::cast(higher_dimension());
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   203
    ak->remove_java_mirror();
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   204
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   205
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   206
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25326
diff changeset
   207
void ArrayKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25326
diff changeset
   208
  assert(loader_data == ClassLoaderData::the_null_class_loader_data(), "array classes belong to null loader");
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25326
diff changeset
   209
  Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   210
  // Klass recreates the component mirror also
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   211
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   212
  if (_higher_dimension != NULL) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   213
    ArrayKlass *ak = ArrayKlass::cast(higher_dimension());
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   214
    ak->restore_unshareable_info(loader_data, protection_domain, CHECK);
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46773
diff changeset
   215
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   216
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   217
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   220
void ArrayKlass::print_on(outputStream* st) const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   221
  assert(is_klass(), "must be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   222
  Klass::print_on(st);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   223
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   224
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   225
void ArrayKlass::print_value_on(outputStream* st) const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   226
  assert(is_klass(), "must be klass");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   227
  for(int index = 0; index < dimension(); index++) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   228
    st->print("[]");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   229
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   230
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   231
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   232
void ArrayKlass::oop_print_on(oop obj, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  assert(obj->is_array(), "must be array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  Klass::oop_print_on(obj, st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  st->print_cr(" - length: %d", arrayOop(obj)->length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   238
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
// Verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
22794
f1c014ad3754 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents: 22234
diff changeset
   241
void ArrayKlass::verify_on(outputStream* st) {
f1c014ad3754 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents: 22234
diff changeset
   242
  Klass::verify_on(st);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   243
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12114
diff changeset
   244
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   245
void ArrayKlass::oop_verify_on(oop obj, outputStream* st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  guarantee(obj->is_array(), "must be array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  arrayOop a = arrayOop(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  guarantee(a->length() >= 0, "array with negative length?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}