author | rehn |
Mon, 09 May 2016 22:22:15 +0200 | |
changeset 38259 | b495d1cfe673 |
parent 37248 | 11a660dbbb8e |
child 42636 | aafc434ba580 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
35847
990c61a50f24
8143608: Don't 64-bit align start of InstanceKlass vtable, itable, and nonstatic_oopmap on 32-bit systems
cjplummer
parents:
34666
diff
changeset
|
2 |
* Copyright (c) 1997, 2016, 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:
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 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "classfile/systemDictionary.hpp" |
|
28 |
#include "classfile/vmSymbols.hpp" |
|
30764 | 29 |
#include "gc/shared/collectedHeap.inline.hpp" |
30 |
#include "gc/shared/gcLocker.hpp" |
|
7397 | 31 |
#include "jvmtifiles/jvmti.h" |
37248 | 32 |
#include "memory/resourceArea.hpp" |
7397 | 33 |
#include "memory/universe.inline.hpp" |
34 |
#include "oops/arrayKlass.hpp" |
|
35 |
#include "oops/arrayOop.hpp" |
|
36 |
#include "oops/instanceKlass.hpp" |
|
37 |
#include "oops/objArrayOop.hpp" |
|
38 |
#include "oops/oop.inline.hpp" |
|
1 | 39 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
40 |
int ArrayKlass::static_size(int header_size) { |
1 | 41 |
// size of an array klass object |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
42 |
assert(header_size <= InstanceKlass::header_size(), "bad header size"); |
1 | 43 |
// 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
|
44 |
header_size = InstanceKlass::header_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
45 |
int vtable_len = Universe::base_vtable_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
46 |
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
|
47 |
return align_metadata_size(size); |
1 | 48 |
} |
49 |
||
50 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
51 |
Klass* ArrayKlass::java_super() const { |
1 | 52 |
if (super() == NULL) return NULL; // bootstrap case |
53 |
// Array klasses have primary supertypes which are not reported to Java. |
|
54 |
// Example super chain: String[][] -> Object[][] -> Object[] -> Object |
|
4571 | 55 |
return SystemDictionary::Object_klass(); |
1 | 56 |
} |
57 |
||
58 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
59 |
oop ArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) { |
1 | 60 |
ShouldNotReachHere(); |
61 |
return NULL; |
|
62 |
} |
|
63 |
||
27020 | 64 |
// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined |
65 |
Klass* ArrayKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { |
|
66 |
// There are no fields in an array klass but look to the super class (Object) |
|
67 |
assert(super(), "super klass must be present"); |
|
68 |
return super()->find_field(name, sig, fd); |
|
69 |
} |
|
70 |
||
34666 | 71 |
Method* ArrayKlass::uncached_lookup_method(const Symbol* name, |
72 |
const Symbol* signature, |
|
73 |
OverpassLookupMode overpass_mode) const { |
|
1 | 74 |
// There are no methods in an array klass but the super class (Object) has some |
75 |
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
|
76 |
// 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
|
77 |
// 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
|
78 |
// any overpass methods present. |
f7339cba0a6a
8067480: Crash in klassItable::initialize_itable_for_interface when running vm.runtime.defmeth.StaticMethodsTest.
lfoltan
parents:
27020
diff
changeset
|
79 |
return super()->uncached_lookup_method(name, signature, Klass::skip_overpass); |
1 | 80 |
} |
81 |
||
34666 | 82 |
ArrayKlass::ArrayKlass(Symbol* name) : |
83 |
_dimension(1), |
|
84 |
_higher_dimension(NULL), |
|
35899 | 85 |
_lower_dimension(NULL) { |
86 |
// Arrays don't add any new methods, so their vtable is the same size as |
|
87 |
// the vtable of klass Object. |
|
88 |
set_vtable_length(Universe::base_vtable_size()); |
|
34666 | 89 |
set_name(name); |
90 |
set_super(Universe::is_bootstrapping() ? (Klass*)NULL : SystemDictionary::Object_klass()); |
|
91 |
set_layout_helper(Klass::_lh_neutral_value); |
|
92 |
set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5) |
|
36384 | 93 |
TRACE_INIT_KLASS_ID(this); |
1 | 94 |
} |
95 |
||
96 |
||
97 |
// 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
|
98 |
// since a GC can happen. At this point all instance variables of the ArrayKlass must be setup. |
36508 | 99 |
void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, ModuleEntry* module_entry, TRAPS) { |
1 | 100 |
ResourceMark rm(THREAD); |
101 |
k->initialize_supers(super_klass(), CHECK); |
|
102 |
k->vtable()->initialize_vtable(false, CHECK); |
|
36508 | 103 |
|
104 |
// During bootstrapping, before java.base is defined, the module_entry may not be present yet. |
|
105 |
// These classes will be put on a fixup list and their module fields will be patched once |
|
106 |
// java.base is defined. |
|
107 |
assert((module_entry != NULL) || ((module_entry == NULL) && !ModuleEntryTable::javabase_defined()), |
|
108 |
"module entry not available post java.base definition"); |
|
109 |
oop module = (module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL; |
|
110 |
java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(NULL), CHECK); |
|
1 | 111 |
} |
112 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
113 |
GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) { |
1 | 114 |
// interfaces = { cloneable_klass, serializable_klass }; |
115 |
assert(num_extra_slots == 0, "sanity of primitive array type"); |
|
116 |
// Must share this for correct bootstrapping! |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
117 |
set_secondary_supers(Universe::the_array_interfaces_array()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
118 |
return NULL; |
1 | 119 |
} |
120 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
121 |
bool ArrayKlass::compute_is_subtype_of(Klass* k) { |
1 | 122 |
// An array is a subtype of Serializable, Clonable, and Object |
4571 | 123 |
return k == SystemDictionary::Object_klass() |
124 |
|| k == SystemDictionary::Cloneable_klass() |
|
125 |
|| k == SystemDictionary::Serializable_klass(); |
|
1 | 126 |
} |
127 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
128 |
objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) { |
1 | 129 |
if (length < 0) { |
130 |
THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); |
|
131 |
} |
|
132 |
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
|
133 |
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
|
134 |
JvmtiExport::post_array_size_exhausted(); |
1 | 135 |
THROW_OOP_0(Universe::out_of_memory_error_array_size()); |
136 |
} |
|
137 |
int size = objArrayOopDesc::object_size(length); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
138 |
Klass* k = array_klass(n+dimension(), CHECK_0); |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
139 |
ArrayKlass* ak = ArrayKlass::cast(k); |
1 | 140 |
objArrayOop o = |
141 |
(objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_0); |
|
142 |
// initialization to NULL not necessary, area already cleared |
|
143 |
return o; |
|
144 |
} |
|
145 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
146 |
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
|
147 |
Klass* k = this; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
148 |
// 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
|
149 |
while (k != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
150 |
f(k, CHECK); |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
151 |
k = ArrayKlass::cast(k)->higher_dimension(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
152 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
153 |
} |
1 | 154 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
155 |
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
|
156 |
Klass* k = this; |
1 | 157 |
// Iterate over this array klass and all higher dimensions |
158 |
while (k != NULL) { |
|
159 |
f(k); |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
160 |
k = ArrayKlass::cast(k)->higher_dimension(); |
1 | 161 |
} |
162 |
} |
|
163 |
||
164 |
// JVM support |
|
165 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
166 |
jint ArrayKlass::compute_modifier_flags(TRAPS) const { |
1 | 167 |
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
168 |
} |
|
169 |
||
170 |
// JVMTI support |
|
171 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
172 |
jint ArrayKlass::jvmti_class_status() const { |
1 | 173 |
return JVMTI_CLASS_STATUS_ARRAY; |
174 |
} |
|
175 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
176 |
void ArrayKlass::remove_unshareable_info() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
177 |
Klass::remove_unshareable_info(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
178 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
179 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25326
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
// Klass recreates the component mirror also |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
184 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
185 |
|
1 | 186 |
// Printing |
187 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
188 |
void ArrayKlass::print_on(outputStream* st) const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
189 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
190 |
Klass::print_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
191 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
192 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
193 |
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
|
194 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
195 |
for(int index = 0; index < dimension(); index++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
196 |
st->print("[]"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
197 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
198 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
199 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
200 |
void ArrayKlass::oop_print_on(oop obj, outputStream* st) { |
1 | 201 |
assert(obj->is_array(), "must be array"); |
202 |
Klass::oop_print_on(obj, st); |
|
203 |
st->print_cr(" - length: %d", arrayOop(obj)->length()); |
|
204 |
} |
|
205 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
206 |
|
1 | 207 |
// Verification |
208 |
||
22794
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22234
diff
changeset
|
209 |
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
|
210 |
Klass::verify_on(st); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
211 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
212 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
213 |
void ArrayKlass::oop_verify_on(oop obj, outputStream* st) { |
1 | 214 |
guarantee(obj->is_array(), "must be array"); |
215 |
arrayOop a = arrayOop(obj); |
|
216 |
guarantee(a->length() >= 0, "array with negative length?"); |
|
217 |
} |