author | iklam |
Fri, 20 Jul 2018 12:19:28 -0700 | |
changeset 51180 | b7eb9cc56277 |
parent 49738 | a7bc87a63dd8 |
child 51379 | 802f7e5e7e6b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49192
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
48614
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, 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" |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
29 |
#include "ci/ciUtilities.inline.hpp" |
7397 | 30 |
#include "classfile/systemDictionary.hpp" |
31 |
#include "memory/allocation.hpp" |
|
32 |
#include "memory/allocation.inline.hpp" |
|
37248 | 33 |
#include "memory/resourceArea.hpp" |
7397 | 34 |
#include "oops/oop.inline.hpp" |
10546 | 35 |
#include "oops/fieldStreams.hpp" |
7397 | 36 |
#include "runtime/fieldDescriptor.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
37 |
#include "runtime/handles.inline.hpp" |
49192
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
48614
diff
changeset
|
38 |
#include "runtime/jniHandles.inline.hpp" |
1 | 39 |
|
40 |
// ciInstanceKlass |
|
41 |
// |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
42 |
// 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
|
43 |
// whose Klass part in an InstanceKlass. |
1 | 44 |
|
47887
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
45 |
|
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
46 |
// ------------------------------------------------------------------ |
1 | 47 |
// ciInstanceKlass::ciInstanceKlass |
48 |
// |
|
49 |
// Loaded instance klass. |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
41669
diff
changeset
|
50 |
ciInstanceKlass::ciInstanceKlass(Klass* k) : |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
41669
diff
changeset
|
51 |
ciKlass(k) |
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
52 |
{ |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31519
diff
changeset
|
53 |
assert(get_Klass()->is_instance_klass(), "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
|
54 |
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
|
55 |
InstanceKlass* ik = get_instanceKlass(); |
1 | 56 |
|
57 |
AccessFlags access_flags = ik->access_flags(); |
|
58 |
_flags = ciFlags(access_flags); |
|
59 |
_has_finalizer = access_flags.has_finalizer(); |
|
60 |
_has_subklass = ik->subklass() != NULL; |
|
11407
5399831730cd
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
10546
diff
changeset
|
61 |
_init_state = ik->init_state(); |
1 | 62 |
_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
|
63 |
_has_nonstatic_fields = ik->has_nonstatic_fields(); |
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
37248
diff
changeset
|
64 |
_has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods(); |
31519
bb26c50aadd0
8087218: Constant fold loads from final instance fields in VM anonymous classes
vlivanov
parents:
31037
diff
changeset
|
65 |
_is_anonymous = ik->is_anonymous(); |
1 | 66 |
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
67 |
_has_injected_fields = -1; |
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
68 |
_implementor = NULL; // we will fill these lazily |
1 | 69 |
|
48614
c39ae979ca35
8191567: Refactor ciInstanceKlass G1 keep alive barrier to use Access API.
eosterlund
parents:
47887
diff
changeset
|
70 |
// Ensure that the metadata wrapped by the ciMetadata is kept alive by GC. |
c39ae979ca35
8191567: Refactor ciInstanceKlass G1 keep alive barrier to use Access API.
eosterlund
parents:
47887
diff
changeset
|
71 |
// This is primarily useful for metadata which is considered as weak roots |
c39ae979ca35
8191567: Refactor ciInstanceKlass G1 keep alive barrier to use Access API.
eosterlund
parents:
47887
diff
changeset
|
72 |
// by the GC but need to be strong roots if reachable from a current compilation. |
c39ae979ca35
8191567: Refactor ciInstanceKlass G1 keep alive barrier to use Access API.
eosterlund
parents:
47887
diff
changeset
|
73 |
// InstanceKlass are created for both weak and strong metadata. Ensuring this metadata |
c39ae979ca35
8191567: Refactor ciInstanceKlass G1 keep alive barrier to use Access API.
eosterlund
parents:
47887
diff
changeset
|
74 |
// alive covers the cases where there are weak roots without performance cost. |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49449
diff
changeset
|
75 |
oop holder = ik->holder_phantom(); |
47887
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
76 |
if (ik->is_anonymous()) { |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
77 |
// Though ciInstanceKlass records class loader oop, it's not enough to keep |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
78 |
// VM anonymous classes alive (loader == NULL). Klass holder should be used instead. |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
79 |
// It is enough to record a ciObject, since cached elements are never removed |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
80 |
// during ciObjectFactory lifetime. ciObjectFactory itself is created for |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
81 |
// every compilation and lives for the whole duration of the compilation. |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
82 |
assert(holder != NULL, "holder of anonymous class is the mirror which is never null"); |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
83 |
(void)CURRENT_ENV->get_object(holder); |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
84 |
} |
e20d8f168bb6
8190891: Clean up G1 barrier code in compiler interface (ci)
coleenp
parents:
47551
diff
changeset
|
85 |
|
1 | 86 |
Thread *thread = Thread::current(); |
87 |
if (ciObjectFactory::is_initialized()) { |
|
88 |
_loader = JNIHandles::make_local(thread, ik->class_loader()); |
|
89 |
_protection_domain = JNIHandles::make_local(thread, |
|
90 |
ik->protection_domain()); |
|
91 |
_is_shared = false; |
|
92 |
} else { |
|
93 |
Handle h_loader(thread, ik->class_loader()); |
|
94 |
Handle h_protection_domain(thread, ik->protection_domain()); |
|
95 |
_loader = JNIHandles::make_global(h_loader); |
|
96 |
_protection_domain = JNIHandles::make_global(h_protection_domain); |
|
97 |
_is_shared = true; |
|
98 |
} |
|
99 |
||
100 |
// Lazy fields get filled in only upon request. |
|
101 |
_super = NULL; |
|
102 |
_java_mirror = NULL; |
|
103 |
||
104 |
if (is_shared()) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
41669
diff
changeset
|
105 |
if (k != SystemDictionary::Object_klass()) { |
1 | 106 |
super(); |
107 |
} |
|
108 |
//compute_nonstatic_fields(); // done outside of constructor |
|
109 |
} |
|
110 |
||
111 |
_field_cache = NULL; |
|
112 |
} |
|
113 |
||
114 |
// Version for unloaded classes: |
|
115 |
ciInstanceKlass::ciInstanceKlass(ciSymbol* name, |
|
116 |
jobject loader, jobject protection_domain) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
117 |
: ciKlass(name, T_OBJECT) |
1 | 118 |
{ |
119 |
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
|
120 |
_init_state = (InstanceKlass::ClassState)0; |
1 | 121 |
_nonstatic_field_size = -1; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
122 |
_has_nonstatic_fields = false; |
1 | 123 |
_nonstatic_fields = NULL; |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
124 |
_has_injected_fields = -1; |
31519
bb26c50aadd0
8087218: Constant fold loads from final instance fields in VM anonymous classes
vlivanov
parents:
31037
diff
changeset
|
125 |
_is_anonymous = false; |
1 | 126 |
_loader = loader; |
127 |
_protection_domain = protection_domain; |
|
128 |
_is_shared = false; |
|
129 |
_super = NULL; |
|
130 |
_java_mirror = NULL; |
|
131 |
_field_cache = NULL; |
|
132 |
} |
|
133 |
||
134 |
||
135 |
||
136 |
// ------------------------------------------------------------------ |
|
137 |
// ciInstanceKlass::compute_shared_is_initialized |
|
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5884
diff
changeset
|
138 |
void ciInstanceKlass::compute_shared_init_state() { |
1 | 139 |
GUARDED_VM_ENTRY( |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
140 |
InstanceKlass* ik = get_instanceKlass(); |
11407
5399831730cd
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
10546
diff
changeset
|
141 |
_init_state = ik->init_state(); |
1 | 142 |
) |
143 |
} |
|
144 |
||
145 |
// ------------------------------------------------------------------ |
|
146 |
// ciInstanceKlass::compute_shared_has_subklass |
|
147 |
bool ciInstanceKlass::compute_shared_has_subklass() { |
|
148 |
GUARDED_VM_ENTRY( |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
149 |
InstanceKlass* ik = get_instanceKlass(); |
1 | 150 |
_has_subklass = ik->subklass() != NULL; |
151 |
return _has_subklass; |
|
152 |
) |
|
153 |
} |
|
154 |
||
155 |
// ------------------------------------------------------------------ |
|
156 |
// ciInstanceKlass::loader |
|
157 |
oop ciInstanceKlass::loader() { |
|
158 |
ASSERT_IN_VM; |
|
159 |
return JNIHandles::resolve(_loader); |
|
160 |
} |
|
161 |
||
162 |
// ------------------------------------------------------------------ |
|
163 |
// ciInstanceKlass::loader_handle |
|
164 |
jobject ciInstanceKlass::loader_handle() { |
|
165 |
return _loader; |
|
166 |
} |
|
167 |
||
168 |
// ------------------------------------------------------------------ |
|
169 |
// ciInstanceKlass::protection_domain |
|
170 |
oop ciInstanceKlass::protection_domain() { |
|
171 |
ASSERT_IN_VM; |
|
172 |
return JNIHandles::resolve(_protection_domain); |
|
173 |
} |
|
174 |
||
175 |
// ------------------------------------------------------------------ |
|
176 |
// ciInstanceKlass::protection_domain_handle |
|
177 |
jobject ciInstanceKlass::protection_domain_handle() { |
|
178 |
return _protection_domain; |
|
179 |
} |
|
180 |
||
181 |
// ------------------------------------------------------------------ |
|
182 |
// ciInstanceKlass::field_cache |
|
183 |
// |
|
184 |
// Get the field cache associated with this klass. |
|
185 |
ciConstantPoolCache* ciInstanceKlass::field_cache() { |
|
186 |
if (is_shared()) { |
|
187 |
return NULL; |
|
188 |
} |
|
189 |
if (_field_cache == NULL) { |
|
190 |
assert(!is_java_lang_Object(), "Object has no fields"); |
|
191 |
Arena* arena = CURRENT_ENV->arena(); |
|
192 |
_field_cache = new (arena) ciConstantPoolCache(arena, 5); |
|
193 |
} |
|
194 |
return _field_cache; |
|
195 |
} |
|
196 |
||
197 |
// ------------------------------------------------------------------ |
|
198 |
// ciInstanceKlass::get_canonical_holder |
|
199 |
// |
|
200 |
ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) { |
|
201 |
#ifdef ASSERT |
|
202 |
if (!(offset >= 0 && offset < layout_helper())) { |
|
203 |
tty->print("*** get_canonical_holder(%d) on ", offset); |
|
204 |
this->print(); |
|
205 |
tty->print_cr(" ***"); |
|
206 |
}; |
|
207 |
assert(offset >= 0 && offset < layout_helper(), "offset must be tame"); |
|
208 |
#endif |
|
209 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
210 |
if (offset < instanceOopDesc::base_offset_in_bytes()) { |
1 | 211 |
// All header offsets belong properly to java/lang/Object. |
212 |
return CURRENT_ENV->Object_klass(); |
|
213 |
} |
|
214 |
||
215 |
ciInstanceKlass* self = this; |
|
216 |
for (;;) { |
|
217 |
assert(self->is_loaded(), "must be loaded to have size"); |
|
218 |
ciInstanceKlass* super = self->super(); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
219 |
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
|
220 |
!super->contains_field_offset(offset)) { |
1 | 221 |
return self; |
222 |
} else { |
|
223 |
self = super; // return super->get_canonical_holder(offset) |
|
224 |
} |
|
225 |
} |
|
226 |
} |
|
227 |
||
228 |
// ------------------------------------------------------------------ |
|
229 |
// ciInstanceKlass::is_java_lang_Object |
|
230 |
// |
|
231 |
// Is this klass java.lang.Object? |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
232 |
bool ciInstanceKlass::is_java_lang_Object() const { |
1 | 233 |
return equals(CURRENT_ENV->Object_klass()); |
234 |
} |
|
235 |
||
236 |
// ------------------------------------------------------------------ |
|
237 |
// ciInstanceKlass::uses_default_loader |
|
17383 | 238 |
bool ciInstanceKlass::uses_default_loader() const { |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
239 |
// 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
|
240 |
// in order to test null-ness. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
241 |
return _loader == NULL; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
242 |
} |
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 |
// ------------------------------------------------------------------ |
17383 | 245 |
|
246 |
/** |
|
247 |
* Return basic type of boxed value for box klass or T_OBJECT if not. |
|
248 |
*/ |
|
249 |
BasicType ciInstanceKlass::box_klass_type() const { |
|
250 |
if (uses_default_loader() && is_loaded()) { |
|
251 |
return SystemDictionary::box_klass_type(get_Klass()); |
|
252 |
} else { |
|
253 |
return T_OBJECT; |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
/** |
|
258 |
* Is this boxing klass? |
|
259 |
*/ |
|
260 |
bool ciInstanceKlass::is_box_klass() const { |
|
261 |
return is_java_primitive(box_klass_type()); |
|
262 |
} |
|
263 |
||
264 |
/** |
|
265 |
* Is this boxed value offset? |
|
266 |
*/ |
|
267 |
bool ciInstanceKlass::is_boxed_value_offset(int offset) const { |
|
268 |
BasicType bt = box_klass_type(); |
|
269 |
return is_java_primitive(bt) && |
|
270 |
(offset == java_lang_boxing_object::value_offset_in_bytes(bt)); |
|
271 |
} |
|
272 |
||
273 |
// ------------------------------------------------------------------ |
|
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
274 |
// ciInstanceKlass::is_in_package |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
275 |
// |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
276 |
// Is this klass in the given package? |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
277 |
bool ciInstanceKlass::is_in_package(const char* packagename, int len) { |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
278 |
// 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
|
279 |
if (!uses_default_loader()) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
280 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
281 |
GUARDED_VM_ENTRY( |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
282 |
return is_in_package_impl(packagename, len); |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
283 |
) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
284 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
285 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
286 |
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
|
287 |
ASSERT_IN_VM; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
288 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
289 |
// If packagename contains trailing '/' exclude it from the |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
290 |
// prefix-test since we test for it explicitly. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
291 |
if (packagename[len - 1] == '/') |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
292 |
len--; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
293 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
294 |
if (!name()->starts_with(packagename, len)) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
295 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
296 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
297 |
// Test if the class name is something like "java/lang". |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
298 |
if ((len + 1) > name()->utf8_length()) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
299 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
300 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
301 |
// Test for trailing '/' |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
302 |
if ((char) name()->byte_at(len) != '/') |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
303 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
304 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
305 |
// Make sure it's not actually in a subpackage: |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
306 |
if (name()->index_of_at(len+1, "/", 1) >= 0) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
307 |
return false; |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
308 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4450
diff
changeset
|
309 |
return true; |
1 | 310 |
} |
311 |
||
312 |
// ------------------------------------------------------------------ |
|
313 |
// ciInstanceKlass::print_impl |
|
314 |
// |
|
315 |
// Implementation of the print method. |
|
316 |
void ciInstanceKlass::print_impl(outputStream* st) { |
|
317 |
ciKlass::print_impl(st); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
21209
diff
changeset
|
318 |
GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i((address)loader()));) |
1 | 319 |
if (is_loaded()) { |
320 |
st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=", |
|
321 |
bool_to_str(is_initialized()), |
|
322 |
bool_to_str(has_finalizer()), |
|
323 |
bool_to_str(has_subklass()), |
|
324 |
layout_helper()); |
|
325 |
||
326 |
_flags.print_klass_flags(); |
|
327 |
||
328 |
if (_super) { |
|
329 |
st->print(" super="); |
|
330 |
_super->print_name(); |
|
331 |
} |
|
332 |
if (_java_mirror) { |
|
333 |
st->print(" mirror=PRESENT"); |
|
334 |
} |
|
335 |
} else { |
|
336 |
st->print(" loaded=false"); |
|
337 |
} |
|
338 |
} |
|
339 |
||
340 |
// ------------------------------------------------------------------ |
|
341 |
// ciInstanceKlass::super |
|
342 |
// |
|
343 |
// Get the superklass of this klass. |
|
344 |
ciInstanceKlass* ciInstanceKlass::super() { |
|
345 |
assert(is_loaded(), "must be loaded"); |
|
346 |
if (_super == NULL && !is_java_lang_Object()) { |
|
347 |
GUARDED_VM_ENTRY( |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
348 |
Klass* super_klass = get_instanceKlass()->super(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
349 |
_super = CURRENT_ENV->get_instance_klass(super_klass); |
1 | 350 |
) |
351 |
} |
|
352 |
return _super; |
|
353 |
} |
|
354 |
||
355 |
// ------------------------------------------------------------------ |
|
356 |
// ciInstanceKlass::java_mirror |
|
357 |
// |
|
358 |
// 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
|
359 |
// Cache it on this->_java_mirror. |
1 | 360 |
ciInstance* ciInstanceKlass::java_mirror() { |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8314
diff
changeset
|
361 |
if (is_shared()) { |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8314
diff
changeset
|
362 |
return ciKlass::java_mirror(); |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8314
diff
changeset
|
363 |
} |
1 | 364 |
if (_java_mirror == NULL) { |
5884
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5882
diff
changeset
|
365 |
_java_mirror = ciKlass::java_mirror(); |
1 | 366 |
} |
367 |
return _java_mirror; |
|
368 |
} |
|
369 |
||
370 |
// ------------------------------------------------------------------ |
|
371 |
// ciInstanceKlass::unique_concrete_subklass |
|
372 |
ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { |
|
373 |
if (!is_loaded()) return NULL; // No change if class is not loaded |
|
374 |
if (!is_abstract()) return NULL; // Only applies to abstract classes. |
|
375 |
if (!has_subklass()) return NULL; // Must have at least one subklass. |
|
376 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
377 |
InstanceKlass* ik = get_instanceKlass(); |
1 | 378 |
Klass* up = ik->up_cast_abstract(); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31519
diff
changeset
|
379 |
assert(up->is_instance_klass(), "must be InstanceKlass"); |
1 | 380 |
if (ik == up) { |
381 |
return NULL; |
|
382 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
383 |
return CURRENT_THREAD_ENV->get_instance_klass(up); |
1 | 384 |
} |
385 |
||
386 |
// ------------------------------------------------------------------ |
|
387 |
// ciInstanceKlass::has_finalizable_subclass |
|
388 |
bool ciInstanceKlass::has_finalizable_subclass() { |
|
389 |
if (!is_loaded()) return true; |
|
390 |
VM_ENTRY_MARK; |
|
391 |
return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL; |
|
392 |
} |
|
393 |
||
394 |
// ------------------------------------------------------------------ |
|
395 |
// ciInstanceKlass::get_field_by_offset |
|
396 |
ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) { |
|
397 |
if (!is_static) { |
|
398 |
for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) { |
|
399 |
ciField* field = _nonstatic_fields->at(i); |
|
400 |
int field_off = field->offset_in_bytes(); |
|
401 |
if (field_off == field_offset) |
|
402 |
return field; |
|
403 |
if (field_off > field_offset) |
|
404 |
break; |
|
405 |
// could do binary search or check bins, but probably not worth it |
|
406 |
} |
|
407 |
return NULL; |
|
408 |
} |
|
409 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
410 |
InstanceKlass* k = get_instanceKlass(); |
1 | 411 |
fieldDescriptor fd; |
412 |
if (!k->find_field_from_offset(field_offset, is_static, &fd)) { |
|
413 |
return NULL; |
|
414 |
} |
|
415 |
ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); |
|
416 |
return field; |
|
417 |
} |
|
418 |
||
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
419 |
// ------------------------------------------------------------------ |
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
420 |
// ciInstanceKlass::get_field_by_name |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
421 |
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
|
422 |
VM_ENTRY_MARK; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
423 |
InstanceKlass* k = get_instanceKlass(); |
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
424 |
fieldDescriptor fd; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
425 |
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
|
426 |
if (def == NULL) { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
427 |
return NULL; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
428 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
429 |
ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
430 |
return field; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
431 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
670
diff
changeset
|
432 |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
433 |
|
1 | 434 |
static int sort_field_by_offset(ciField** a, ciField** b) { |
435 |
return (*a)->offset_in_bytes() - (*b)->offset_in_bytes(); |
|
436 |
// (no worries about 32-bit overflow...) |
|
437 |
} |
|
438 |
||
439 |
// ------------------------------------------------------------------ |
|
440 |
// ciInstanceKlass::compute_nonstatic_fields |
|
441 |
int ciInstanceKlass::compute_nonstatic_fields() { |
|
442 |
assert(is_loaded(), "must be loaded"); |
|
443 |
||
444 |
if (_nonstatic_fields != NULL) |
|
445 |
return _nonstatic_fields->length(); |
|
446 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
447 |
if (!has_nonstatic_fields()) { |
1 | 448 |
Arena* arena = CURRENT_ENV->arena(); |
449 |
_nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL); |
|
450 |
return 0; |
|
451 |
} |
|
452 |
assert(!is_java_lang_Object(), "bootstrap OK"); |
|
453 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
454 |
// 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
|
455 |
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
|
456 |
|
1 | 457 |
ciInstanceKlass* super = this->super(); |
458 |
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
|
459 |
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
|
460 |
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
|
461 |
int super_flen = super->nof_nonstatic_fields(); |
1 | 462 |
super_fields = super->_nonstatic_fields; |
463 |
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
|
464 |
// 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
|
465 |
if (fsize == super_fsize) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
466 |
_nonstatic_fields = super_fields; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
467 |
return super_fields->length(); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
217
diff
changeset
|
468 |
} |
1 | 469 |
} |
470 |
||
471 |
GrowableArray<ciField*>* fields = NULL; |
|
472 |
GUARDED_VM_ENTRY({ |
|
473 |
fields = compute_nonstatic_fields_impl(super_fields); |
|
474 |
}); |
|
475 |
||
476 |
if (fields == NULL) { |
|
477 |
// This can happen if this class (java.lang.Class) has invisible fields. |
|
31037
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
28933
diff
changeset
|
478 |
if (super_fields != NULL) { |
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
28933
diff
changeset
|
479 |
_nonstatic_fields = super_fields; |
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
28933
diff
changeset
|
480 |
return super_fields->length(); |
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
28933
diff
changeset
|
481 |
} else { |
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
28933
diff
changeset
|
482 |
return 0; |
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
28933
diff
changeset
|
483 |
} |
1 | 484 |
} |
485 |
||
486 |
int flen = fields->length(); |
|
487 |
||
488 |
// Now sort them by offset, ascending. |
|
489 |
// (In principle, they could mix with superclass fields.) |
|
490 |
fields->sort(sort_field_by_offset); |
|
491 |
_nonstatic_fields = fields; |
|
492 |
return flen; |
|
493 |
} |
|
494 |
||
495 |
GrowableArray<ciField*>* |
|
496 |
ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>* |
|
497 |
super_fields) { |
|
498 |
ASSERT_IN_VM; |
|
499 |
Arena* arena = CURRENT_ENV->arena(); |
|
500 |
int flen = 0; |
|
501 |
GrowableArray<ciField*>* fields = NULL; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
502 |
InstanceKlass* k = get_instanceKlass(); |
10546 | 503 |
for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
504 |
if (fs.access_flags().is_static()) continue; |
|
505 |
flen += 1; |
|
506 |
} |
|
1 | 507 |
|
10546 | 508 |
// allocate the array: |
509 |
if (flen == 0) { |
|
510 |
return NULL; // return nothing if none are locally declared |
|
511 |
} |
|
512 |
if (super_fields != NULL) { |
|
513 |
flen += super_fields->length(); |
|
514 |
} |
|
515 |
fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); |
|
516 |
if (super_fields != NULL) { |
|
517 |
fields->appendAll(super_fields); |
|
518 |
} |
|
519 |
||
520 |
for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
|
521 |
if (fs.access_flags().is_static()) continue; |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17383
diff
changeset
|
522 |
fieldDescriptor& fd = fs.field_descriptor(); |
10546 | 523 |
ciField* field = new (arena) ciField(&fd); |
524 |
fields->append(field); |
|
1 | 525 |
} |
526 |
assert(fields->length() == flen, "sanity"); |
|
527 |
return fields; |
|
528 |
} |
|
529 |
||
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
530 |
bool ciInstanceKlass::compute_injected_fields_helper() { |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
531 |
ASSERT_IN_VM; |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
532 |
InstanceKlass* k = get_instanceKlass(); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
533 |
|
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
534 |
for (InternalFieldStream fs(k); !fs.done(); fs.next()) { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
535 |
if (fs.access_flags().is_static()) continue; |
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
536 |
return true; |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
537 |
} |
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
538 |
return false; |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
539 |
} |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
540 |
|
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
541 |
void ciInstanceKlass::compute_injected_fields() { |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
542 |
assert(is_loaded(), "must be loaded"); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
543 |
|
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
544 |
int has_injected_fields = 0; |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
545 |
if (super() != NULL && super()->has_injected_fields()) { |
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
546 |
has_injected_fields = 1; |
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
547 |
} else { |
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
548 |
GUARDED_VM_ENTRY({ |
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
549 |
has_injected_fields = compute_injected_fields_helper() ? 1 : 0; |
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
550 |
}); |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
551 |
} |
28933
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
552 |
// may be concurrently initialized for shared ciInstanceKlass objects |
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
553 |
assert(_has_injected_fields == -1 || _has_injected_fields == has_injected_fields, "broken concurrent initialization"); |
a11a29cf06d5
8071821: Assert failed in UnexpectedDeoptimizationTest.java
roland
parents:
28396
diff
changeset
|
554 |
_has_injected_fields = has_injected_fields; |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
555 |
} |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
26706
diff
changeset
|
556 |
|
1 | 557 |
// ------------------------------------------------------------------ |
558 |
// ciInstanceKlass::find_method |
|
559 |
// |
|
560 |
// Find a method in this klass. |
|
561 |
ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) { |
|
562 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
563 |
InstanceKlass* k = get_instanceKlass(); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
564 |
Symbol* name_sym = name->get_symbol(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
565 |
Symbol* sig_sym= signature->get_symbol(); |
1 | 566 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
567 |
Method* m = k->find_method(name_sym, sig_sym); |
1 | 568 |
if (m == NULL) return NULL; |
569 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
570 |
return CURRENT_THREAD_ENV->get_method(m); |
1 | 571 |
} |
572 |
||
573 |
// ------------------------------------------------------------------ |
|
574 |
// ciInstanceKlass::is_leaf_type |
|
575 |
bool ciInstanceKlass::is_leaf_type() { |
|
576 |
assert(is_loaded(), "must be loaded"); |
|
577 |
if (is_shared()) { |
|
578 |
return is_final(); // approximately correct |
|
579 |
} else { |
|
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
580 |
return !_has_subklass && (nof_implementors() == 0); |
1 | 581 |
} |
582 |
} |
|
583 |
||
584 |
// ------------------------------------------------------------------ |
|
585 |
// ciInstanceKlass::implementor |
|
586 |
// |
|
587 |
// Report an implementor of this interface. |
|
588 |
// Note that there are various races here, since my copy |
|
589 |
// 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
|
590 |
// to results returned by InstanceKlass::implementor. |
1 | 591 |
// This is OK, since any dependencies we decide to assert |
592 |
// 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
|
593 |
ciInstanceKlass* ciInstanceKlass::implementor() { |
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
594 |
ciInstanceKlass* impl = _implementor; |
1 | 595 |
if (impl == NULL) { |
596 |
// Go into the VM to fetch the implementor. |
|
597 |
{ |
|
598 |
VM_ENTRY_MARK; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
599 |
Klass* k = get_instanceKlass()->implementor(); |
1 | 600 |
if (k != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
601 |
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
|
602 |
// 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
|
603 |
impl = this; |
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
604 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12369
diff
changeset
|
605 |
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
|
606 |
} |
1 | 607 |
} |
608 |
} |
|
609 |
// Memoize this result. |
|
610 |
if (!is_shared()) { |
|
12369
48fd3da4025c
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
11407
diff
changeset
|
611 |
_implementor = impl; |
1 | 612 |
} |
613 |
} |
|
614 |
return impl; |
|
615 |
} |
|
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
616 |
|
44738 | 617 |
ciInstanceKlass* ciInstanceKlass::host_klass() { |
618 |
assert(is_loaded(), "must be loaded"); |
|
619 |
if (is_anonymous()) { |
|
620 |
VM_ENTRY_MARK |
|
621 |
Klass* host_klass = get_instanceKlass()->host_klass(); |
|
622 |
return CURRENT_ENV->get_instance_klass(host_klass); |
|
623 |
} |
|
624 |
return NULL; |
|
625 |
} |
|
626 |
||
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
627 |
// Utility class for printing of the contents of the static fields for |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
628 |
// use by compilation replay. It only prints out the information that |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
629 |
// could be consumed by the compiler, so for primitive types it prints |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
630 |
// out the actual value. For Strings it's the actual string value. |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
631 |
// For array types it it's first level array size since that's the |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
632 |
// only value which statically unchangeable. For all other reference |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
633 |
// types it simply prints out the dynamic type. |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
634 |
|
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
635 |
class StaticFinalFieldPrinter : public FieldClosure { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
636 |
outputStream* _out; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
637 |
const char* _holder; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
638 |
public: |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
639 |
StaticFinalFieldPrinter(outputStream* out, const char* holder) : |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
640 |
_out(out), |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
641 |
_holder(holder) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
642 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
643 |
void do_field(fieldDescriptor* fd) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
644 |
if (fd->is_final() && !fd->has_initial_value()) { |
15471
41f75023e6a6
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
14477
diff
changeset
|
645 |
ResourceMark rm; |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
646 |
oop mirror = fd->field_holder()->java_mirror(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
647 |
_out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
648 |
switch (fd->field_type()) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
649 |
case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
650 |
case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
651 |
case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
652 |
case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
653 |
case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break; |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
21209
diff
changeset
|
654 |
case T_LONG: _out->print_cr(INT64_FORMAT, (int64_t)(mirror->long_field(fd->offset()))); break; |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
655 |
case T_FLOAT: { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
656 |
float f = mirror->float_field(fd->offset()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
657 |
_out->print_cr("%d", *(int*)&f); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
658 |
break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
659 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
660 |
case T_DOUBLE: { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
661 |
double d = mirror->double_field(fd->offset()); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
21209
diff
changeset
|
662 |
_out->print_cr(INT64_FORMAT, *(int64_t*)&d); |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
663 |
break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
664 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
665 |
case T_ARRAY: { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
666 |
oop value = mirror->obj_field_acquire(fd->offset()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
667 |
if (value == NULL) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
668 |
_out->print_cr("null"); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
669 |
} else { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
670 |
typeArrayOop ta = (typeArrayOop)value; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
671 |
_out->print("%d", ta->length()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
672 |
if (value->is_objArray()) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
673 |
objArrayOop oa = (objArrayOop)value; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
674 |
const char* klass_name = value->klass()->name()->as_quoted_ascii(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
675 |
_out->print(" %s", klass_name); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
676 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
677 |
_out->cr(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
678 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
679 |
break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
680 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
681 |
case T_OBJECT: { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
682 |
oop value = mirror->obj_field_acquire(fd->offset()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
683 |
if (value == NULL) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
684 |
_out->print_cr("null"); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
685 |
} else if (value->is_instance()) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
686 |
if (value->is_a(SystemDictionary::String_klass())) { |
47551
4d034d861e13
8187780: VM crashes while generating replay compilation file
thartmann
parents:
47216
diff
changeset
|
687 |
const char* ascii_value = java_lang_String::as_quoted_ascii(value); |
4d034d861e13
8187780: VM crashes while generating replay compilation file
thartmann
parents:
47216
diff
changeset
|
688 |
_out->print("\"%s\"", (ascii_value != NULL) ? ascii_value : ""); |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
689 |
} else { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
690 |
const char* klass_name = value->klass()->name()->as_quoted_ascii(); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
21209
diff
changeset
|
691 |
_out->print_cr("%s", klass_name); |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
692 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
693 |
} else { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
694 |
ShouldNotReachHere(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
695 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
696 |
break; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
697 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
698 |
default: |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
699 |
ShouldNotReachHere(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
700 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
701 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
702 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
703 |
}; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
704 |
|
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
705 |
|
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
706 |
void ciInstanceKlass::dump_replay_data(outputStream* out) { |
15471
41f75023e6a6
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
14477
diff
changeset
|
707 |
ResourceMark rm; |
41f75023e6a6
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
14477
diff
changeset
|
708 |
|
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
709 |
InstanceKlass* ik = get_instanceKlass(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
710 |
ConstantPool* cp = ik->constants(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
711 |
|
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
712 |
// Try to record related loaded classes |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
713 |
Klass* sub = ik->subklass(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
714 |
while (sub != NULL) { |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31519
diff
changeset
|
715 |
if (sub->is_instance_klass()) { |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
716 |
out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
717 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
718 |
sub = sub->next_sibling(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
719 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
720 |
|
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
721 |
// Dump out the state of the constant pool tags. During replay the |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
722 |
// tags will be validated for things which shouldn't change and |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
723 |
// classes will be resolved if the tags indicate that they were |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
724 |
// resolved at compile time. |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
725 |
out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(), |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
726 |
is_linked(), is_initialized(), cp->length()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
727 |
for (int index = 1; index < cp->length(); index++) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
728 |
out->print(" %d", cp->tags()->at(index)); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
729 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
730 |
out->cr(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
731 |
if (is_initialized()) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
732 |
// Dump out the static final fields in case the compilation relies |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
733 |
// on their value for correct replay. |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
734 |
StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
735 |
ik->do_local_static_fields(&sffp); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
736 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13728
diff
changeset
|
737 |
} |