author | coleenp |
Thu, 28 Aug 2014 11:29:09 -0400 | |
changeset 26412 | 80741eb33ba2 |
parent 26135 | 82b516c550f7 |
child 26927 | b9bd979b7d75 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22794
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22234
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, 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" |
|
29 |
#include "gc_interface/collectedHeap.inline.hpp" |
|
30 |
#include "jvmtifiles/jvmti.h" |
|
31 |
#include "memory/gcLocker.hpp" |
|
32 |
#include "memory/universe.inline.hpp" |
|
33 |
#include "oops/arrayKlass.hpp" |
|
34 |
#include "oops/arrayOop.hpp" |
|
35 |
#include "oops/instanceKlass.hpp" |
|
36 |
#include "oops/objArrayOop.hpp" |
|
37 |
#include "oops/oop.inline.hpp" |
|
1 | 38 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
39 |
int ArrayKlass::static_size(int header_size) { |
1 | 40 |
// size of an array klass object |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
41 |
assert(header_size <= InstanceKlass::header_size(), "bad header size"); |
1 | 42 |
// 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
|
43 |
header_size = InstanceKlass::header_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
44 |
int vtable_len = Universe::base_vtable_size(); |
1 | 45 |
#ifdef _LP64 |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
46 |
int size = header_size + align_object_offset(vtable_len); |
1 | 47 |
#else |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
48 |
int size = header_size + vtable_len; |
1 | 49 |
#endif |
50 |
return align_object_size(size); |
|
51 |
} |
|
52 |
||
53 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
54 |
Klass* ArrayKlass::java_super() const { |
1 | 55 |
if (super() == NULL) return NULL; // bootstrap case |
56 |
// Array klasses have primary supertypes which are not reported to Java. |
|
57 |
// Example super chain: String[][] -> Object[][] -> Object[] -> Object |
|
4571 | 58 |
return SystemDictionary::Object_klass(); |
1 | 59 |
} |
60 |
||
61 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
62 |
oop ArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) { |
1 | 63 |
ShouldNotReachHere(); |
64 |
return NULL; |
|
65 |
} |
|
66 |
||
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22794
diff
changeset
|
67 |
Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const { |
1 | 68 |
// There are no methods in an array klass but the super class (Object) has some |
69 |
assert(super(), "super klass must be present"); |
|
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22794
diff
changeset
|
70 |
return super()->uncached_lookup_method(name, signature, mode); |
1 | 71 |
} |
72 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
73 |
ArrayKlass::ArrayKlass(Symbol* name) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
74 |
set_name(name); |
1 | 75 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
76 |
set_super(Universe::is_bootstrapping() ? (Klass*)NULL : SystemDictionary::Object_klass()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
77 |
set_layout_helper(Klass::_lh_neutral_value); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
78 |
set_dimension(1); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
79 |
set_higher_dimension(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
80 |
set_lower_dimension(NULL); |
1 | 81 |
// Arrays don't add any new methods, so their vtable is the same size as |
82 |
// the vtable of klass Object. |
|
83 |
int vtable_size = Universe::base_vtable_size(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
84 |
set_vtable_length(vtable_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
85 |
set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5) |
1 | 86 |
} |
87 |
||
88 |
||
89 |
// 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
|
90 |
// since a GC can happen. At this point all instance variables of the ArrayKlass must be setup. |
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
91 |
void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, TRAPS) { |
1 | 92 |
ResourceMark rm(THREAD); |
93 |
k->initialize_supers(super_klass(), CHECK); |
|
94 |
k->vtable()->initialize_vtable(false, CHECK); |
|
25326
85b2f2e63e3e
6642881: Improve performance of Class.getClassLoader()
coleenp
parents:
23999
diff
changeset
|
95 |
java_lang_Class::create_mirror(k, Handle(NULL), Handle(NULL), CHECK); |
1 | 96 |
} |
97 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
98 |
GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) { |
1 | 99 |
// interfaces = { cloneable_klass, serializable_klass }; |
100 |
assert(num_extra_slots == 0, "sanity of primitive array type"); |
|
101 |
// Must share this for correct bootstrapping! |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
102 |
set_secondary_supers(Universe::the_array_interfaces_array()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
103 |
return NULL; |
1 | 104 |
} |
105 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
106 |
bool ArrayKlass::compute_is_subtype_of(Klass* k) { |
1 | 107 |
// An array is a subtype of Serializable, Clonable, and Object |
4571 | 108 |
return k == SystemDictionary::Object_klass() |
109 |
|| k == SystemDictionary::Cloneable_klass() |
|
110 |
|| k == SystemDictionary::Serializable_klass(); |
|
1 | 111 |
} |
112 |
||
113 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
114 |
inline intptr_t* ArrayKlass::start_of_vtable() const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
115 |
// all vtables start at the same place, that's why we use InstanceKlass::header_size here |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
116 |
return ((intptr_t*)this) + InstanceKlass::header_size(); |
1 | 117 |
} |
118 |
||
119 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
120 |
klassVtable* ArrayKlass::vtable() const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
121 |
KlassHandle kh(Thread::current(), this); |
1 | 122 |
return new klassVtable(kh, start_of_vtable(), vtable_length() / vtableEntry::size()); |
123 |
} |
|
124 |
||
125 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
126 |
objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) { |
1 | 127 |
if (length < 0) { |
128 |
THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); |
|
129 |
} |
|
130 |
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
|
131 |
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
|
132 |
JvmtiExport::post_array_size_exhausted(); |
1 | 133 |
THROW_OOP_0(Universe::out_of_memory_error_array_size()); |
134 |
} |
|
135 |
int size = objArrayOopDesc::object_size(length); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
136 |
Klass* k = array_klass(n+dimension(), CHECK_0); |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
137 |
ArrayKlass* ak = ArrayKlass::cast(k); |
1 | 138 |
objArrayOop o = |
139 |
(objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_0); |
|
140 |
// initialization to NULL not necessary, area already cleared |
|
141 |
return o; |
|
142 |
} |
|
143 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
144 |
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
|
145 |
Klass* k = this; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
146 |
// 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
|
147 |
while (k != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
148 |
f(k, CHECK); |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
149 |
k = ArrayKlass::cast(k)->higher_dimension(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
150 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
151 |
} |
1 | 152 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
153 |
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
|
154 |
Klass* k = this; |
1 | 155 |
// Iterate over this array klass and all higher dimensions |
156 |
while (k != NULL) { |
|
157 |
f(k); |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
158 |
k = ArrayKlass::cast(k)->higher_dimension(); |
1 | 159 |
} |
160 |
} |
|
161 |
||
162 |
// JVM support |
|
163 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
164 |
jint ArrayKlass::compute_modifier_flags(TRAPS) const { |
1 | 165 |
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
166 |
} |
|
167 |
||
168 |
// JVMTI support |
|
169 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
170 |
jint ArrayKlass::jvmti_class_status() const { |
1 | 171 |
return JVMTI_CLASS_STATUS_ARRAY; |
172 |
} |
|
173 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
174 |
void ArrayKlass::remove_unshareable_info() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
175 |
Klass::remove_unshareable_info(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
176 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
177 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25326
diff
changeset
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
// Klass recreates the component mirror also |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
182 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
183 |
|
1 | 184 |
// Printing |
185 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
186 |
void ArrayKlass::print_on(outputStream* st) const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
187 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
188 |
Klass::print_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
189 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
190 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
191 |
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
|
192 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
193 |
for(int index = 0; index < dimension(); index++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
194 |
st->print("[]"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
195 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
196 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
197 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
198 |
void ArrayKlass::oop_print_on(oop obj, outputStream* st) { |
1 | 199 |
assert(obj->is_array(), "must be array"); |
200 |
Klass::oop_print_on(obj, st); |
|
201 |
st->print_cr(" - length: %d", arrayOop(obj)->length()); |
|
202 |
} |
|
203 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
204 |
|
1 | 205 |
// Verification |
206 |
||
22794
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22234
diff
changeset
|
207 |
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
|
208 |
Klass::verify_on(st); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
209 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
210 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
211 |
void ArrayKlass::oop_verify_on(oop obj, outputStream* st) { |
1 | 212 |
guarantee(obj->is_array(), "must be array"); |
213 |
arrayOop a = arrayOop(obj); |
|
214 |
guarantee(a->length() >= 0, "array with negative length?"); |
|
215 |
} |