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