Mercurial > hg > graal-jvmci-8
annotate src/share/vm/ci/ciInstanceKlass.hpp @ 1930:2d26b0046e0d
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 30 Nov 2010 14:53:30 +0100 |
parents | 5571b97fc1ec 3941674cc7fa |
children | 06f017f7daa7 |
rev | line source |
---|---|
0 | 1 /* |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // ciInstanceKlass | |
26 // | |
27 // This class represents a klassOop in the HotSpot virtual machine | |
28 // whose Klass part is an instanceKlass. It may or may not | |
29 // be loaded. | |
30 class ciInstanceKlass : public ciKlass { | |
31 CI_PACKAGE_ACCESS | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
32 friend class ciBytecodeStream; |
0 | 33 friend class ciEnv; |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
34 friend class ciExceptionHandler; |
0 | 35 friend class ciMethod; |
36 friend class ciField; | |
37 | |
38 private: | |
39 jobject _loader; | |
40 jobject _protection_domain; | |
41 | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
42 instanceKlass::ClassState _init_state; // state of class |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
43 bool _is_shared; |
0 | 44 bool _has_finalizer; |
45 bool _has_subklass; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
46 bool _has_nonstatic_fields; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
47 |
0 | 48 ciFlags _flags; |
49 jint _nonstatic_field_size; | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
50 jint _nonstatic_oop_map_size; |
0 | 51 |
52 // Lazy fields get filled in only upon request. | |
53 ciInstanceKlass* _super; | |
54 ciInstance* _java_mirror; | |
55 | |
56 ciConstantPoolCache* _field_cache; // cached map index->field | |
57 GrowableArray<ciField*>* _nonstatic_fields; | |
58 | |
59 enum { implementors_limit = instanceKlass::implementors_limit }; | |
60 ciInstanceKlass* _implementors[implementors_limit]; | |
61 jint _nof_implementors; | |
62 | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
63 GrowableArray<ciField*>* _non_static_fields; |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
64 |
1478
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
65 public: |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
66 virtual void cleanup() { |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
67 ciObject::cleanup(); |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
68 if (!_is_shared) { |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
69 if (JNIHandles::is_global_handle(_loader)) { |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
70 JNIHandles::destroy_global(_loader); |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
71 } |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
72 if (JNIHandles::is_global_handle(_protection_domain)) { |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
73 JNIHandles::destroy_global(_protection_domain); |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
74 } |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
75 } |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
76 } |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1138
diff
changeset
|
77 |
0 | 78 protected: |
79 ciInstanceKlass(KlassHandle h_k); | |
80 ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain); | |
81 | |
82 instanceKlass* get_instanceKlass() const { | |
83 return (instanceKlass*)get_Klass(); | |
84 } | |
85 | |
86 oop loader(); | |
87 jobject loader_handle(); | |
88 | |
89 oop protection_domain(); | |
90 jobject protection_domain_handle(); | |
91 | |
92 const char* type_string() { return "ciInstanceKlass"; } | |
93 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
94 bool is_in_package_impl(const char* packagename, int len); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
95 |
0 | 96 void print_impl(outputStream* st); |
97 | |
98 ciConstantPoolCache* field_cache(); | |
99 | |
100 bool is_shared() { return _is_shared; } | |
101 | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
102 void compute_shared_init_state(); |
0 | 103 bool compute_shared_has_subklass(); |
104 int compute_shared_nof_implementors(); | |
105 int compute_nonstatic_fields(); | |
106 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields); | |
107 | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
108 // Update the init_state for shared klasses |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
109 void update_if_shared(instanceKlass::ClassState expected) { |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
110 if (_is_shared && _init_state != expected) { |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
111 if (is_loaded()) compute_shared_init_state(); |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
112 } |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
113 } |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
114 |
0 | 115 public: |
116 // Has this klass been initialized? | |
117 bool is_initialized() { | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
118 update_if_shared(instanceKlass::fully_initialized); |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
119 return _init_state == instanceKlass::fully_initialized; |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
120 } |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
121 // Is this klass being initialized? |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
122 bool is_being_initialized() { |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
123 update_if_shared(instanceKlass::being_initialized); |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
124 return _init_state == instanceKlass::being_initialized; |
0 | 125 } |
126 // Has this klass been linked? | |
127 bool is_linked() { | |
1645
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
128 update_if_shared(instanceKlass::linked); |
3941674cc7fa
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
1552
diff
changeset
|
129 return _init_state >= instanceKlass::linked; |
0 | 130 } |
131 | |
132 // General klass information. | |
133 ciFlags flags() { | |
134 assert(is_loaded(), "must be loaded"); | |
135 return _flags; | |
136 } | |
137 bool has_finalizer() { | |
138 assert(is_loaded(), "must be loaded"); | |
139 return _has_finalizer; } | |
140 bool has_subklass() { | |
141 assert(is_loaded(), "must be loaded"); | |
142 if (_is_shared && !_has_subklass) { | |
143 if (flags().is_final()) { | |
144 return false; | |
145 } else { | |
146 return compute_shared_has_subklass(); | |
147 } | |
148 } | |
149 return _has_subklass; | |
150 } | |
151 jint size_helper() { | |
152 return (Klass::layout_helper_size_in_bytes(layout_helper()) | |
153 >> LogHeapWordSize); | |
154 } | |
155 jint nonstatic_field_size() { | |
156 assert(is_loaded(), "must be loaded"); | |
157 return _nonstatic_field_size; } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
158 jint has_nonstatic_fields() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
159 assert(is_loaded(), "must be loaded"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
160 return _has_nonstatic_fields; } |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
161 jint nonstatic_oop_map_size() { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
162 assert(is_loaded(), "must be loaded"); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
163 return _nonstatic_oop_map_size; } |
0 | 164 ciInstanceKlass* super(); |
165 jint nof_implementors() { | |
166 assert(is_loaded(), "must be loaded"); | |
167 if (_is_shared) return compute_shared_nof_implementors(); | |
168 return _nof_implementors; | |
169 } | |
170 | |
171 ciInstanceKlass* get_canonical_holder(int offset); | |
172 ciField* get_field_by_offset(int field_offset, bool is_static); | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
196
diff
changeset
|
173 ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static); |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
174 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
175 GrowableArray<ciField*>* non_static_fields(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
176 |
0 | 177 // total number of nonstatic fields (including inherited): |
178 int nof_nonstatic_fields() { | |
179 if (_nonstatic_fields == NULL) | |
180 return compute_nonstatic_fields(); | |
181 else | |
182 return _nonstatic_fields->length(); | |
183 } | |
184 // nth nonstatic field (presented by ascending address) | |
185 ciField* nonstatic_field_at(int i) { | |
186 assert(_nonstatic_fields != NULL, ""); | |
187 return _nonstatic_fields->at(i); | |
188 } | |
189 | |
190 ciInstanceKlass* unique_concrete_subklass(); | |
191 bool has_finalizable_subclass(); | |
192 | |
193 bool contains_field_offset(int offset) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
194 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size()); |
0 | 195 } |
196 | |
197 // Get the instance of java.lang.Class corresponding to | |
198 // this klass. This instance is used for locking of | |
199 // synchronized static methods of this klass. | |
200 ciInstance* java_mirror(); | |
201 | |
202 // Java access flags | |
203 bool is_public () { return flags().is_public(); } | |
204 bool is_final () { return flags().is_final(); } | |
205 bool is_super () { return flags().is_super(); } | |
206 bool is_interface () { return flags().is_interface(); } | |
207 bool is_abstract () { return flags().is_abstract(); } | |
208 | |
209 ciMethod* find_method(ciSymbol* name, ciSymbol* signature); | |
210 // Note: To find a method from name and type strings, use ciSymbol::make, | |
211 // but consider adding to vmSymbols.hpp instead. | |
212 | |
213 bool is_leaf_type(); | |
214 ciInstanceKlass* implementor(int n); | |
215 | |
216 // Is the defining class loader of this class the default loader? | |
217 bool uses_default_loader(); | |
218 | |
219 bool is_java_lang_Object(); | |
220 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
221 // Is this klass in the given package? |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
222 bool is_in_package(const char* packagename) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
223 return is_in_package(packagename, (int) strlen(packagename)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
224 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
225 bool is_in_package(const char* packagename, int len); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
226 |
0 | 227 // What kind of ciObject is this? |
228 bool is_instance_klass() { return true; } | |
229 bool is_java_klass() { return true; } | |
230 }; |