author | coleenp |
Sat, 01 Sep 2012 13:25:18 -0400 | |
changeset 13728 | 882756847a04 |
parent 12369 | 48fd3da4025c |
child 14477 | 95e66ea71f71 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
2 |
* Copyright (c) 1999, 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 "ci/ciField.hpp" |
|
27 |
#include "ci/ciInstance.hpp" |
|
28 |
#include "ci/ciInstanceKlass.hpp" |
|
29 |
#include "ci/ciUtilities.hpp" |
|
30 |
#include "classfile/systemDictionary.hpp" |
|
31 |
#include "memory/allocation.hpp" |
|
32 |
#include "memory/allocation.inline.hpp" |
|
33 |
#include "oops/oop.inline.hpp" |
|
10546 | 34 |
#include "oops/fieldStreams.hpp" |
7397 | 35 |
#include "runtime/fieldDescriptor.hpp" |
1 | 36 |
|
37 |
// ciInstanceKlass |
|
38 |
// |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
39 |
// This class represents a Klass* in the HotSpot virtual machine |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
40 |
// whose Klass part in an InstanceKlass. |
1 | 41 |
|
42 |
// ------------------------------------------------------------------ |
|
43 |
// ciInstanceKlass::ciInstanceKlass |
|
44 |
// |
|
45 |
// Loaded instance klass. |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
46 |
ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
47 |
ciKlass(h_k), _non_static_fields(NULL) |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
48 |
{ |
1 | 49 |
assert(get_Klass()->oop_is_instance(), "wrong type"); |
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
50 |
assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
51 |
InstanceKlass* ik = get_instanceKlass(); |
1 | 52 |
|
53 |
AccessFlags access_flags = ik->access_flags(); |
|
54 |
_flags = ciFlags(access_flags); |
|
55 |
_has_finalizer = access_flags.has_finalizer(); |
|
56 |
_has_subklass = ik->subklass() != NULL; |
|
11407
5399831730cd
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
10546
diff
changeset
|
57 |
_init_state = ik->init_state(); |
1 | 58 |
_nonstatic_field_size = ik->nonstatic_field_size(); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
59 |
_has_nonstatic_fields = ik->has_nonstatic_fields(); |
1 | 60 |
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: |
61 |
||
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
62 |
_implementor = NULL; // we will fill these lazily |
1 | 63 |
|
64 |
Thread *thread = Thread::current(); |
|
65 |
if (ciObjectFactory::is_initialized()) { |
|
66 |
_loader = JNIHandles::make_local(thread, ik->class_loader()); |
|
67 |
_protection_domain = JNIHandles::make_local(thread, |
|
68 |
ik->protection_domain()); |
|
69 |
_is_shared = false; |
|
70 |
} else { |
|
71 |
Handle h_loader(thread, ik->class_loader()); |
|
72 |
Handle h_protection_domain(thread, ik->protection_domain()); |
|
73 |
_loader = JNIHandles::make_global(h_loader); |
|
74 |
_protection_domain = JNIHandles::make_global(h_protection_domain); |
|
75 |
_is_shared = true; |
|
76 |
} |
|
77 |
||
78 |
// Lazy fields get filled in only upon request. |
|
79 |
_super = NULL; |
|
80 |
_java_mirror = NULL; |
|
81 |
||
82 |
if (is_shared()) { |
|
4571 | 83 |
if (h_k() != SystemDictionary::Object_klass()) { |
1 | 84 |
super(); |
85 |
} |
|
86 |
//compute_nonstatic_fields(); // done outside of constructor |
|
87 |
} |
|
88 |
||
89 |
_field_cache = NULL; |
|
90 |
} |
|
91 |
||
92 |
// Version for unloaded classes: |
|
93 |
ciInstanceKlass::ciInstanceKlass(ciSymbol* name, |
|
94 |
jobject loader, jobject protection_domain) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
95 |
: ciKlass(name, T_OBJECT) |
1 | 96 |
{ |
97 |
assert(name->byte_at(0) != '[', "not an instance klass"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
98 |
_init_state = (InstanceKlass::ClassState)0; |
1 | 99 |
_nonstatic_field_size = -1; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
100 |
_has_nonstatic_fields = false; |
1 | 101 |
_nonstatic_fields = NULL; |
102 |
_loader = loader; |
|
103 |
_protection_domain = protection_domain; |
|
104 |
_is_shared = false; |
|
105 |
_super = NULL; |
|
106 |
_java_mirror = NULL; |
|
107 |
_field_cache = NULL; |
|
108 |
} |
|
109 |
||
110 |
||
111 |
||
112 |
// ------------------------------------------------------------------ |
|
113 |
// ciInstanceKlass::compute_shared_is_initialized |
|
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5884
diff
changeset
|
114 |
void ciInstanceKlass::compute_shared_init_state() { |
1 | 115 |
GUARDED_VM_ENTRY( |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
116 |
InstanceKlass* ik = get_instanceKlass(); |
11407
5399831730cd
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
10546
diff
changeset
|
117 |
_init_state = ik->init_state(); |
1 | 118 |
) |
119 |
} |
|
120 |
||
121 |
// ------------------------------------------------------------------ |
|
122 |
// ciInstanceKlass::compute_shared_has_subklass |
|
123 |
bool ciInstanceKlass::compute_shared_has_subklass() { |
|
124 |
GUARDED_VM_ENTRY( |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
125 |
InstanceKlass* ik = get_instanceKlass(); |
1 | 126 |
_has_subklass = ik->subklass() != NULL; |
127 |
return _has_subklass; |
|
128 |
) |
|
129 |
} |
|
130 |
||
131 |
// ------------------------------------------------------------------ |
|
132 |
// ciInstanceKlass::loader |
|
133 |
oop ciInstanceKlass::loader() { |
|
134 |
ASSERT_IN_VM; |
|
135 |
return JNIHandles::resolve(_loader); |
|
136 |
} |
|
137 |
||
138 |
// ------------------------------------------------------------------ |
|
139 |
// ciInstanceKlass::loader_handle |
|
140 |
jobject ciInstanceKlass::loader_handle() { |
|
141 |
return _loader; |
|
142 |
} |
|
143 |
||
144 |
// ------------------------------------------------------------------ |
|
145 |
// ciInstanceKlass::protection_domain |
|
146 |
oop ciInstanceKlass::protection_domain() { |
|
147 |
ASSERT_IN_VM; |
|
148 |
return JNIHandles::resolve(_protection_domain); |
|
149 |
} |
|
150 |
||
151 |
// ------------------------------------------------------------------ |
|
152 |
// ciInstanceKlass::protection_domain_handle |
|
153 |
jobject ciInstanceKlass::protection_domain_handle() { |
|
154 |
return _protection_domain; |
|
155 |
} |
|
156 |
||
157 |
// ------------------------------------------------------------------ |
|
158 |
// ciInstanceKlass::field_cache |
|
159 |
// |
|
160 |
// Get the field cache associated with this klass. |
|
161 |
ciConstantPoolCache* ciInstanceKlass::field_cache() { |
|
162 |
if (is_shared()) { |
|
163 |
return NULL; |
|
164 |
} |
|
165 |
if (_field_cache == NULL) { |
|
166 |
assert(!is_java_lang_Object(), "Object has no fields"); |
|
167 |
Arena* arena = CURRENT_ENV->arena(); |
|
168 |
_field_cache = new (arena) ciConstantPoolCache(arena, 5); |
|
169 |
} |
|
170 |
return _field_cache; |
|
171 |
} |
|
172 |
||
173 |
// ------------------------------------------------------------------ |
|
174 |
// ciInstanceKlass::get_canonical_holder |
|
175 |
// |
|
176 |
ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) { |
|
177 |
#ifdef ASSERT |
|
178 |
if (!(offset >= 0 && offset < layout_helper())) { |
|
179 |
tty->print("*** get_canonical_holder(%d) on ", offset); |
|
180 |
this->print(); |
|
181 |
tty->print_cr(" ***"); |
|
182 |
}; |
|
183 |
assert(offset >= 0 && offset < layout_helper(), "offset must be tame"); |
|
184 |
#endif |
|
185 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
186 |
if (offset < instanceOopDesc::base_offset_in_bytes()) { |
1 | 187 |
// All header offsets belong properly to java/lang/Object. |
188 |
return CURRENT_ENV->Object_klass(); |
|
189 |
} |
|
190 |
||
191 |
ciInstanceKlass* self = this; |
|
192 |
for (;;) { |
|
193 |
assert(self->is_loaded(), "must be loaded to have size"); |
|
194 |
ciInstanceKlass* super = self->super(); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
195 |
if (super == NULL || super->nof_nonstatic_fields() == 0 || |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
196 |
!super->contains_field_offset(offset)) { |
1 | 197 |
return self; |
198 |
} else { |
|
199 |
self = super; // return super->get_canonical_holder(offset) |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
// ------------------------------------------------------------------ |
|
205 |
// ciInstanceKlass::is_java_lang_Object |
|
206 |
// |
|
207 |
// Is this klass java.lang.Object? |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
208 |
bool ciInstanceKlass::is_java_lang_Object() const { |
1 | 209 |
return equals(CURRENT_ENV->Object_klass()); |
210 |
} |
|
211 |
||
212 |
// ------------------------------------------------------------------ |
|
213 |
// ciInstanceKlass::uses_default_loader |
|
214 |
bool ciInstanceKlass::uses_default_loader() { |
|
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
215 |
// Note: We do not need to resolve the handle or enter the VM |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
216 |
// in order to test null-ness. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
217 |
return _loader == NULL; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
218 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
219 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
220 |
// ------------------------------------------------------------------ |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
221 |
// ciInstanceKlass::is_in_package |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
222 |
// |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
223 |
// Is this klass in the given package? |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
224 |
bool ciInstanceKlass::is_in_package(const char* packagename, int len) { |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
225 |
// To avoid class loader mischief, this test always rejects application classes. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
226 |
if (!uses_default_loader()) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
227 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
228 |
GUARDED_VM_ENTRY( |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
229 |
return is_in_package_impl(packagename, len); |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
230 |
) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
231 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
232 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
233 |
bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) { |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
234 |
ASSERT_IN_VM; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
235 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
236 |
// If packagename contains trailing '/' exclude it from the |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
237 |
// prefix-test since we test for it explicitly. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
238 |
if (packagename[len - 1] == '/') |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
239 |
len--; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
240 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
241 |
if (!name()->starts_with(packagename, len)) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
242 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
243 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
244 |
// Test if the class name is something like "java/lang". |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
245 |
if ((len + 1) > name()->utf8_length()) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
246 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
247 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
248 |
// Test for trailing '/' |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
249 |
if ((char) name()->byte_at(len) != '/') |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
250 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
251 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
252 |
// Make sure it's not actually in a subpackage: |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
253 |
if (name()->index_of_at(len+1, "/", 1) >= 0) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
254 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
255 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
256 |
return true; |
1 | 257 |
} |
258 |
||
259 |
// ------------------------------------------------------------------ |
|
260 |
// ciInstanceKlass::print_impl |
|
261 |
// |
|
262 |
// Implementation of the print method. |
|
263 |
void ciInstanceKlass::print_impl(outputStream* st) { |
|
264 |
ciKlass::print_impl(st); |
|
265 |
GUARDED_VM_ENTRY(st->print(" loader=0x%x", (address)loader());) |
|
266 |
if (is_loaded()) { |
|
267 |
st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=", |
|
268 |
bool_to_str(is_initialized()), |
|
269 |
bool_to_str(has_finalizer()), |
|
270 |
bool_to_str(has_subklass()), |
|
271 |
layout_helper()); |
|
272 |
||
273 |
_flags.print_klass_flags(); |
|
274 |
||
275 |
if (_super) { |
|
276 |
st->print(" super="); |
|
277 |
_super->print_name(); |
|
278 |
} |
|
279 |
if (_java_mirror) { |
|
280 |
st->print(" mirror=PRESENT"); |
|
281 |
} |
|
282 |
} else { |
|
283 |
st->print(" loaded=false"); |
|
284 |
} |
|
285 |
} |
|
286 |
||
287 |
// ------------------------------------------------------------------ |
|
288 |
// ciInstanceKlass::super |
|
289 |
// |
|
290 |
// Get the superklass of this klass. |
|
291 |
ciInstanceKlass* ciInstanceKlass::super() { |
|
292 |
assert(is_loaded(), "must be loaded"); |
|
293 |
if (_super == NULL && !is_java_lang_Object()) { |
|
294 |
GUARDED_VM_ENTRY( |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
295 |
Klass* super_klass = get_instanceKlass()->super(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
296 |
_super = CURRENT_ENV->get_instance_klass(super_klass); |
1 | 297 |
) |
298 |
} |
|
299 |
return _super; |
|
300 |
} |
|
301 |
||
302 |
// ------------------------------------------------------------------ |
|
303 |
// ciInstanceKlass::java_mirror |
|
304 |
// |
|
305 |
// Get the instance of java.lang.Class corresponding to this klass. |
|
5884
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5882
diff
changeset
|
306 |
// Cache it on this->_java_mirror. |
1 | 307 |
ciInstance* ciInstanceKlass::java_mirror() { |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8314
diff
changeset
|
308 |
if (is_shared()) { |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8314
diff
changeset
|
309 |
return ciKlass::java_mirror(); |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8314
diff
changeset
|
310 |
} |
1 | 311 |
if (_java_mirror == NULL) { |
5884
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5882
diff
changeset
|
312 |
_java_mirror = ciKlass::java_mirror(); |
1 | 313 |
} |
314 |
return _java_mirror; |
|
315 |
} |
|
316 |
||
317 |
// ------------------------------------------------------------------ |
|
318 |
// ciInstanceKlass::unique_concrete_subklass |
|
319 |
ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { |
|
320 |
if (!is_loaded()) return NULL; // No change if class is not loaded |
|
321 |
if (!is_abstract()) return NULL; // Only applies to abstract classes. |
|
322 |
if (!has_subklass()) return NULL; // Must have at least one subklass. |
|
323 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
324 |
InstanceKlass* ik = get_instanceKlass(); |
1 | 325 |
Klass* up = ik->up_cast_abstract(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
326 |
assert(up->oop_is_instance(), "must be InstanceKlass"); |
1 | 327 |
if (ik == up) { |
328 |
return NULL; |
|
329 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
330 |
return CURRENT_THREAD_ENV->get_instance_klass(up); |
1 | 331 |
} |
332 |
||
333 |
// ------------------------------------------------------------------ |
|
334 |
// ciInstanceKlass::has_finalizable_subclass |
|
335 |
bool ciInstanceKlass::has_finalizable_subclass() { |
|
336 |
if (!is_loaded()) return true; |
|
337 |
VM_ENTRY_MARK; |
|
338 |
return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL; |
|
339 |
} |
|
340 |
||
341 |
// ------------------------------------------------------------------ |
|
342 |
// ciInstanceKlass::get_field_by_offset |
|
343 |
ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) { |
|
344 |
if (!is_static) { |
|
345 |
for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) { |
|
346 |
ciField* field = _nonstatic_fields->at(i); |
|
347 |
int field_off = field->offset_in_bytes(); |
|
348 |
if (field_off == field_offset) |
|
349 |
return field; |
|
350 |
if (field_off > field_offset) |
|
351 |
break; |
|
352 |
// could do binary search or check bins, but probably not worth it |
|
353 |
} |
|
354 |
return NULL; |
|
355 |
} |
|
356 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
357 |
InstanceKlass* k = get_instanceKlass(); |
1 | 358 |
fieldDescriptor fd; |
359 |
if (!k->find_field_from_offset(field_offset, is_static, &fd)) { |
|
360 |
return NULL; |
|
361 |
} |
|
362 |
ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); |
|
363 |
return field; |
|
364 |
} |
|
365 |
||
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
366 |
// ------------------------------------------------------------------ |
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
367 |
// ciInstanceKlass::get_field_by_name |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
368 |
ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
369 |
VM_ENTRY_MARK; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
370 |
InstanceKlass* k = get_instanceKlass(); |
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
371 |
fieldDescriptor fd; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
372 |
Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd); |
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
373 |
if (def == NULL) { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
374 |
return NULL; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
375 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
376 |
ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
377 |
return field; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
378 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
379 |
|
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
380 |
// ------------------------------------------------------------------ |
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
381 |
// ciInstanceKlass::non_static_fields. |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
382 |
|
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
383 |
class NonStaticFieldFiller: public FieldClosure { |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
384 |
GrowableArray<ciField*>* _arr; |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
385 |
ciEnv* _curEnv; |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
386 |
public: |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
387 |
NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) : |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
388 |
_curEnv(curEnv), _arr(arr) |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
389 |
{} |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
390 |
void do_field(fieldDescriptor* fd) { |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
391 |
ciField* field = new (_curEnv->arena()) ciField(fd); |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
392 |
_arr->append(field); |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
393 |
} |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
394 |
}; |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
395 |
|
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
396 |
GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() { |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
397 |
if (_non_static_fields == NULL) { |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
398 |
VM_ENTRY_MARK; |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
399 |
ciEnv* curEnv = ciEnv::current(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
400 |
InstanceKlass* ik = get_instanceKlass(); |
10546 | 401 |
int max_n_fields = ik->java_fields_count(); |
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
402 |
|
6180 | 403 |
Arena* arena = curEnv->arena(); |
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
404 |
_non_static_fields = |
6180 | 405 |
new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL); |
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
406 |
NonStaticFieldFiller filler(curEnv, _non_static_fields); |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
407 |
ik->do_nonstatic_fields(&filler); |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
408 |
} |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
409 |
return _non_static_fields; |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
410 |
} |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
411 |
|
1 | 412 |
static int sort_field_by_offset(ciField** a, ciField** b) { |
413 |
return (*a)->offset_in_bytes() - (*b)->offset_in_bytes(); |
|
414 |
// (no worries about 32-bit overflow...) |
|
415 |
} |
|
416 |
||
417 |
// ------------------------------------------------------------------ |
|
418 |
// ciInstanceKlass::compute_nonstatic_fields |
|
419 |
int ciInstanceKlass::compute_nonstatic_fields() { |
|
420 |
assert(is_loaded(), "must be loaded"); |
|
421 |
||
422 |
if (_nonstatic_fields != NULL) |
|
423 |
return _nonstatic_fields->length(); |
|
424 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
425 |
if (!has_nonstatic_fields()) { |
1 | 426 |
Arena* arena = CURRENT_ENV->arena(); |
427 |
_nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL); |
|
428 |
return 0; |
|
429 |
} |
|
430 |
assert(!is_java_lang_Object(), "bootstrap OK"); |
|
431 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
432 |
// Size in bytes of my fields, including inherited fields. |
591
04d2e26e6d69
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
360
diff
changeset
|
433 |
int fsize = nonstatic_field_size() * heapOopSize; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
434 |
|
1 | 435 |
ciInstanceKlass* super = this->super(); |
436 |
GrowableArray<ciField*>* super_fields = NULL; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
437 |
if (super != NULL && super->has_nonstatic_fields()) { |
591
04d2e26e6d69
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
360
diff
changeset
|
438 |
int super_fsize = super->nonstatic_field_size() * heapOopSize; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
439 |
int super_flen = super->nof_nonstatic_fields(); |
1 | 440 |
super_fields = super->_nonstatic_fields; |
441 |
assert(super_flen == 0 || super_fields != NULL, "first get nof_fields"); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
442 |
// See if I am no larger than my super; if so, I can use his fields. |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
443 |
if (fsize == super_fsize) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
444 |
_nonstatic_fields = super_fields; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
445 |
return super_fields->length(); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
446 |
} |
1 | 447 |
} |
448 |
||
449 |
GrowableArray<ciField*>* fields = NULL; |
|
450 |
GUARDED_VM_ENTRY({ |
|
451 |
fields = compute_nonstatic_fields_impl(super_fields); |
|
452 |
}); |
|
453 |
||
454 |
if (fields == NULL) { |
|
455 |
// This can happen if this class (java.lang.Class) has invisible fields. |
|
456 |
_nonstatic_fields = super_fields; |
|
457 |
return super_fields->length(); |
|
458 |
} |
|
459 |
||
460 |
int flen = fields->length(); |
|
461 |
||
462 |
// Now sort them by offset, ascending. |
|
463 |
// (In principle, they could mix with superclass fields.) |
|
464 |
fields->sort(sort_field_by_offset); |
|
465 |
_nonstatic_fields = fields; |
|
466 |
return flen; |
|
467 |
} |
|
468 |
||
469 |
GrowableArray<ciField*>* |
|
470 |
ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>* |
|
471 |
super_fields) { |
|
472 |
ASSERT_IN_VM; |
|
473 |
Arena* arena = CURRENT_ENV->arena(); |
|
474 |
int flen = 0; |
|
475 |
GrowableArray<ciField*>* fields = NULL; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
476 |
InstanceKlass* k = get_instanceKlass(); |
10546 | 477 |
for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
478 |
if (fs.access_flags().is_static()) continue; |
|
479 |
flen += 1; |
|
480 |
} |
|
1 | 481 |
|
10546 | 482 |
// allocate the array: |
483 |
if (flen == 0) { |
|
484 |
return NULL; // return nothing if none are locally declared |
|
485 |
} |
|
486 |
if (super_fields != NULL) { |
|
487 |
flen += super_fields->length(); |
|
488 |
} |
|
489 |
fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); |
|
490 |
if (super_fields != NULL) { |
|
491 |
fields->appendAll(super_fields); |
|
492 |
} |
|
493 |
||
494 |
for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
|
495 |
if (fs.access_flags().is_static()) continue; |
|
496 |
fieldDescriptor fd; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
497 |
fd.initialize(k, fs.index()); |
10546 | 498 |
ciField* field = new (arena) ciField(&fd); |
499 |
fields->append(field); |
|
1 | 500 |
} |
501 |
assert(fields->length() == flen, "sanity"); |
|
502 |
return fields; |
|
503 |
} |
|
504 |
||
505 |
// ------------------------------------------------------------------ |
|
506 |
// ciInstanceKlass::find_method |
|
507 |
// |
|
508 |
// Find a method in this klass. |
|
509 |
ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) { |
|
510 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
511 |
InstanceKlass* k = get_instanceKlass(); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
512 |
Symbol* name_sym = name->get_symbol(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
513 |
Symbol* sig_sym= signature->get_symbol(); |
1 | 514 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
515 |
Method* m = k->find_method(name_sym, sig_sym); |
1 | 516 |
if (m == NULL) return NULL; |
517 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
518 |
return CURRENT_THREAD_ENV->get_method(m); |
1 | 519 |
} |
520 |
||
521 |
// ------------------------------------------------------------------ |
|
522 |
// ciInstanceKlass::is_leaf_type |
|
523 |
bool ciInstanceKlass::is_leaf_type() { |
|
524 |
assert(is_loaded(), "must be loaded"); |
|
525 |
if (is_shared()) { |
|
526 |
return is_final(); // approximately correct |
|
527 |
} else { |
|
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
528 |
return !_has_subklass && (nof_implementors() == 0); |
1 | 529 |
} |
530 |
} |
|
531 |
||
532 |
// ------------------------------------------------------------------ |
|
533 |
// ciInstanceKlass::implementor |
|
534 |
// |
|
535 |
// Report an implementor of this interface. |
|
536 |
// Note that there are various races here, since my copy |
|
537 |
// of _nof_implementors might be out of date with respect |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
538 |
// to results returned by InstanceKlass::implementor. |
1 | 539 |
// This is OK, since any dependencies we decide to assert |
540 |
// will be checked later under the Compile_lock. |
|
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
541 |
ciInstanceKlass* ciInstanceKlass::implementor() { |
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
542 |
ciInstanceKlass* impl = _implementor; |
1 | 543 |
if (impl == NULL) { |
544 |
// Go into the VM to fetch the implementor. |
|
545 |
{ |
|
546 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
547 |
Klass* k = get_instanceKlass()->implementor(); |
1 | 548 |
if (k != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
549 |
if (k == get_instanceKlass()) { |
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
550 |
// More than one implementors. Use 'this' in this case. |
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
551 |
impl = this; |
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
552 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
553 |
impl = CURRENT_THREAD_ENV->get_instance_klass(k); |
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
554 |
} |
1 | 555 |
} |
556 |
} |
|
557 |
// Memoize this result. |
|
558 |
if (!is_shared()) { |
|
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
559 |
_implementor = impl; |
1 | 560 |
} |
561 |
} |
|
562 |
return impl; |
|
563 |
} |