author | coleenp |
Wed, 13 Nov 2019 08:23:23 -0500 | |
changeset 59056 | 15936b142f86 |
parent 58722 | cba8afa5cfed |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53152 | 2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
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 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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 | 29 |
#include "classfile/systemDictionary.hpp" |
30 |
#include "classfile/vmSymbols.hpp" |
|
30764 | 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 | 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 | 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 | 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 | 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 | 44 |
#include "runtime/handles.inline.hpp" |
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 | 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 | 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 | 130 |
assert(module != NULL, "No module entry for array"); |
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 | 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 | 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 | 169 |
assert(obj->is_objArray(), "must be object array"); |
170 |
return objArrayOop(obj)->object_size(); |
|
171 |
} |
|
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 | 178 |
} |
179 |
||
180 |
static int multi_alloc_counter = 0; |
|
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 | 183 |
int length = *sizes; |
184 |
// Call to lower_dimension uses this pointer, so most be called before a |
|
185 |
// possible GC |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
186 |
Klass* ld_klass = lower_dimension(); |
1 | 187 |
// If length < 0 allocate will throw an exception. |
188 |
objArrayOop array = allocate(length, CHECK_NULL); |
|
189 |
objArrayHandle h_array (THREAD, array); |
|
190 |
if (rank > 1) { |
|
191 |
if (length != 0) { |
|
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 | 194 |
oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL); |
195 |
h_array->obj_at_put(index, sub_array); |
|
196 |
} |
|
197 |
} else { |
|
198 |
// Since this array dimension has zero length, nothing will be |
|
199 |
// allocated, however the lower dimension values must be checked |
|
200 |
// for illegal values. |
|
201 |
for (int i = 0; i < rank - 1; ++i) { |
|
202 |
sizes += 1; |
|
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 | 205 |
} |
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
return h_array(); |
|
210 |
} |
|
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 | 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 | 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 | 230 |
ResourceMark rm(THREAD); |
231 |
stringStream ss; |
|
232 |
if (!bound->is_subtype_of(stype)) { |
|
233 |
ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]", |
|
234 |
stype->external_name(), bound->external_name()); |
|
235 |
} else { |
|
236 |
// oop_arraycopy should return the index in the source array that |
|
237 |
// contains the problematic oop. |
|
238 |
ss.print("arraycopy: element type mismatch: can not cast one of the elements" |
|
239 |
" of %s[] to the type of the destination array, %s", |
|
240 |
stype->external_name(), bound->external_name()); |
|
241 |
} |
|
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 | 249 |
int dst_pos, int length, TRAPS) { |
250 |
assert(s->is_objArray(), "must be obj array"); |
|
251 |
||
252 |
if (!d->is_objArray()) { |
|
50601 | 253 |
ResourceMark rm(THREAD); |
254 |
stringStream ss; |
|
255 |
if (d->is_typeArray()) { |
|
256 |
ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]", |
|
257 |
type2name_tab[ArrayKlass::cast(d->klass())->element_type()]); |
|
258 |
} else { |
|
259 |
ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name()); |
|
260 |
} |
|
261 |
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); |
|
1 | 262 |
} |
263 |
||
264 |
// Check is all offsets and lengths are non negative |
|
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 | 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 | 279 |
} |
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 | 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 | 294 |
} |
295 |
||
296 |
// Special case. Boundary cases must be checked first |
|
297 |
// This allows the following call: copy_array(s, s.length(), d.length(), 0). |
|
298 |
// This is correct, since the position is supposed to be an 'in between point', i.e., s.length(), |
|
299 |
// points to the right of the last element. |
|
300 |
if (length==0) { |
|
301 |
return; |
|
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 | 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 | 319 |
} |
320 |
} |
|
321 |
||
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 | 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 | 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 | 331 |
if (or_null) return NULL; |
1 | 332 |
|
333 |
ResourceMark rm; |
|
334 |
JavaThread *jt = (JavaThread *)THREAD; |
|
335 |
{ |
|
336 |
// Ensure atomic creation of higher dimensions |
|
337 |
MutexLocker mu(MultiArray_lock, THREAD); |
|
338 |
||
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 | 341 |
|
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 | 350 |
} |
351 |
} |
|
352 |
} |
|
353 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
354 |
ObjArrayKlass *ak = ObjArrayKlass::cast(higher_dimension()); |
1 | 355 |
if (or_null) { |
356 |
return ak->array_klass_or_null(n); |
|
357 |
} |
|
57745 | 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 | 360 |
} |
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 | 364 |
} |
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 | 368 |
// array of interfaces |
369 |
return false; |
|
370 |
else |
|
371 |
return Klass::can_be_primary_super_slow(); |
|
372 |
} |
|
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 | 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 | 380 |
int num_secondaries = num_extra_slots + 2 + num_elem_supers; |
381 |
if (num_secondaries == 2) { |
|
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 | 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 | 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 | 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 | 394 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
395 |
return secondaries; |
1 | 396 |
} |
397 |
} |
|
398 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
399 |
void ObjArrayKlass::initialize(TRAPS) { |
14488 | 400 |
bottom_klass()->initialize(THREAD); // dispatches to either InstanceKlass or TypeArrayKlass |
1 | 401 |
} |
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 | 409 |
// JVM support |
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 | 412 |
// The modifier for an objectArray is the same as its element |
413 |
if (element_klass() == NULL) { |
|
414 |
assert(Universe::is_bootstrapping(), "partial objArray only at startup"); |
|
415 |
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
|
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 | 418 |
jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0); |
1 | 419 |
|
420 |
return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) |
|
421 |
| (JVM_ACC_ABSTRACT | JVM_ACC_FINAL); |
|
422 |
} |
|
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 | 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 | 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 | 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 | 457 |
assert(obj->is_objArray(), "must be objArray"); |
458 |
objArrayOop oa = objArrayOop(obj); |
|
459 |
int print_len = MIN2((intx) oa->length(), MaxElementPrintSize); |
|
460 |
for(int index = 0; index < print_len; index++) { |
|
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 | 468 |
} |
469 |
int remaining = oa->length() - print_len; |
|
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 | 472 |
} |
473 |
} |
|
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 | 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 | 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 | 488 |
} |
489 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
490 |
const char* ObjArrayKlass::internal_name() const { |
1 | 491 |
return external_name(); |
492 |
} |
|
493 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
494 |
|
1 | 495 |
// Verification |
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 | 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 | 507 |
guarantee(obj->is_objArray(), "must be objArray"); |
508 |
objArrayOop oa = objArrayOop(obj); |
|
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 | 511 |
} |
512 |
} |