author | coleenp |
Sat, 01 Sep 2012 13:25:18 -0400 | |
changeset 13728 | 882756847a04 |
parent 12114 | 9a825a536095 |
child 13952 | e3cf184080bc |
permissions | -rw-r--r-- |
1 | 1 |
/* |
12114
9a825a536095
7123170: JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
sspitsyn
parents:
8921
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, 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 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
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 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
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 |
||
62 |
oop arrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) { |
|
63 |
ShouldNotReachHere(); |
|
64 |
return NULL; |
|
65 |
} |
|
66 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
67 |
Method* arrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) 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"); |
|
70 |
return Klass::cast(super())->uncached_lookup_method(name, signature); |
|
71 |
} |
|
72 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
73 |
arrayKlass::arrayKlass(Symbol* name) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
74 |
set_alloc_size(0); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
75 |
set_name(name); |
1 | 76 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
77 |
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
|
78 |
set_layout_helper(Klass::_lh_neutral_value); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
79 |
set_dimension(1); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
80 |
set_higher_dimension(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
81 |
set_lower_dimension(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
82 |
set_component_mirror(NULL); |
1 | 83 |
// Arrays don't add any new methods, so their vtable is the same size as |
84 |
// the vtable of klass Object. |
|
85 |
int vtable_size = Universe::base_vtable_size(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
86 |
set_vtable_length(vtable_size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
87 |
set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5) |
1 | 88 |
} |
89 |
||
90 |
||
91 |
// Initialization of vtables and mirror object is done separatly from base_create_array_klass, |
|
92 |
// since a GC can happen. At this point all instance variables of the arrayKlass must be setup. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
93 |
void arrayKlass::complete_create_array_klass(arrayKlass* k, KlassHandle super_klass, TRAPS) { |
1 | 94 |
ResourceMark rm(THREAD); |
95 |
k->initialize_supers(super_klass(), CHECK); |
|
96 |
k->vtable()->initialize_vtable(false, CHECK); |
|
97 |
java_lang_Class::create_mirror(k, CHECK); |
|
98 |
} |
|
99 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
100 |
GrowableArray<Klass*>* arrayKlass::compute_secondary_supers(int num_extra_slots) { |
1 | 101 |
// interfaces = { cloneable_klass, serializable_klass }; |
102 |
assert(num_extra_slots == 0, "sanity of primitive array type"); |
|
103 |
// Must share this for correct bootstrapping! |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
104 |
set_secondary_supers(Universe::the_array_interfaces_array()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
105 |
return NULL; |
1 | 106 |
} |
107 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
108 |
bool arrayKlass::compute_is_subtype_of(Klass* k) { |
1 | 109 |
// An array is a subtype of Serializable, Clonable, and Object |
4571 | 110 |
return k == SystemDictionary::Object_klass() |
111 |
|| k == SystemDictionary::Cloneable_klass() |
|
112 |
|| k == SystemDictionary::Serializable_klass(); |
|
1 | 113 |
} |
114 |
||
115 |
||
116 |
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
|
117 |
// 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
|
118 |
return ((intptr_t*)this) + InstanceKlass::header_size(); |
1 | 119 |
} |
120 |
||
121 |
||
122 |
klassVtable* arrayKlass::vtable() const { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
123 |
KlassHandle kh(Thread::current(), this); |
1 | 124 |
return new klassVtable(kh, start_of_vtable(), vtable_length() / vtableEntry::size()); |
125 |
} |
|
126 |
||
127 |
||
128 |
objArrayOop arrayKlass::allocate_arrayArray(int n, int length, TRAPS) { |
|
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); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
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 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
146 |
void arrayKlass::array_klasses_do(void f(Klass* k, TRAPS), TRAPS) { |
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); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
151 |
k = arrayKlass::cast(k)->higher_dimension(); |
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 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
155 |
void arrayKlass::array_klasses_do(void f(Klass* k)) { |
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); |
|
160 |
k = arrayKlass::cast(k)->higher_dimension(); |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
165 |
void arrayKlass::with_array_klasses_do(void f(Klass* k)) { |
1 | 166 |
array_klasses_do(f); |
167 |
} |
|
168 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
169 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
170 |
// GC support |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
171 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
172 |
void arrayKlass::oops_do(OopClosure* cl) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
173 |
Klass::oops_do(cl); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
174 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
175 |
cl->do_oop(adr_component_mirror()); |
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 |
|
1 | 178 |
// JVM support |
179 |
||
180 |
jint arrayKlass::compute_modifier_flags(TRAPS) const { |
|
181 |
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
|
182 |
} |
|
183 |
||
184 |
// JVMTI support |
|
185 |
||
186 |
jint arrayKlass::jvmti_class_status() const { |
|
187 |
return JVMTI_CLASS_STATUS_ARRAY; |
|
188 |
} |
|
189 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
190 |
void arrayKlass::remove_unshareable_info() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
191 |
Klass::remove_unshareable_info(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
192 |
// Clear the java mirror |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
193 |
set_component_mirror(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
194 |
} |
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 |
void arrayKlass::restore_unshareable_info(TRAPS) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
197 |
Klass::restore_unshareable_info(CHECK); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
198 |
// Klass recreates the component mirror also |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
199 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
200 |
|
1 | 201 |
// Printing |
202 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
203 |
void arrayKlass::print_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
204 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
205 |
Klass::print_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
206 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
207 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
208 |
void arrayKlass::print_value_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
209 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
210 |
for(int index = 0; index < dimension(); index++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
211 |
st->print("[]"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
212 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
213 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
214 |
|
1 | 215 |
void arrayKlass::oop_print_on(oop obj, outputStream* st) { |
216 |
assert(obj->is_array(), "must be array"); |
|
217 |
Klass::oop_print_on(obj, st); |
|
218 |
st->print_cr(" - length: %d", arrayOop(obj)->length()); |
|
219 |
} |
|
220 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
221 |
|
1 | 222 |
// Verification |
223 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
224 |
void arrayKlass::verify_on(outputStream* st) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
225 |
Klass::verify_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
226 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
227 |
if (component_mirror() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
228 |
guarantee(component_mirror()->klass() != NULL, "should have a class"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
229 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
230 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12114
diff
changeset
|
231 |
|
1 | 232 |
void arrayKlass::oop_verify_on(oop obj, outputStream* st) { |
233 |
guarantee(obj->is_array(), "must be array"); |
|
234 |
arrayOop a = arrayOop(obj); |
|
235 |
guarantee(a->length() >= 0, "array with negative length?"); |
|
236 |
} |