Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciInstanceKlass.hpp @ 1507:cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
Summary: split MethodHandle.invoke into invokeExact and invokeGeneric; also clean up JVM-to-Java interfaces
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 01 May 2010 02:42:18 -0700 |
parents | dd57230ba8fe |
children | 5571b97fc1ec c18cbe5936b8 |
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 |
0 | 66 protected: |
67 ciInstanceKlass(KlassHandle h_k); | |
68 ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain); | |
69 | |
70 instanceKlass* get_instanceKlass() const { | |
71 return (instanceKlass*)get_Klass(); | |
72 } | |
73 | |
74 oop loader(); | |
75 jobject loader_handle(); | |
76 | |
77 oop protection_domain(); | |
78 jobject protection_domain_handle(); | |
79 | |
80 const char* type_string() { return "ciInstanceKlass"; } | |
81 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
82 bool is_in_package_impl(const char* packagename, int len); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
83 |
0 | 84 void print_impl(outputStream* st); |
85 | |
86 ciConstantPoolCache* field_cache(); | |
87 | |
88 bool is_shared() { return _is_shared; } | |
89 | |
90 bool compute_shared_is_initialized(); | |
91 bool compute_shared_is_linked(); | |
92 bool compute_shared_has_subklass(); | |
93 int compute_shared_nof_implementors(); | |
94 int compute_nonstatic_fields(); | |
95 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields); | |
96 | |
97 public: | |
98 // Has this klass been initialized? | |
99 bool is_initialized() { | |
100 if (_is_shared && !_is_initialized) { | |
101 return is_loaded() && compute_shared_is_initialized(); | |
102 } | |
103 return _is_initialized; | |
104 } | |
105 // Has this klass been linked? | |
106 bool is_linked() { | |
107 if (_is_shared && !_is_linked) { | |
108 return is_loaded() && compute_shared_is_linked(); | |
109 } | |
110 return _is_linked; | |
111 } | |
112 | |
113 // General klass information. | |
114 ciFlags flags() { | |
115 assert(is_loaded(), "must be loaded"); | |
116 return _flags; | |
117 } | |
118 bool has_finalizer() { | |
119 assert(is_loaded(), "must be loaded"); | |
120 return _has_finalizer; } | |
121 bool has_subklass() { | |
122 assert(is_loaded(), "must be loaded"); | |
123 if (_is_shared && !_has_subklass) { | |
124 if (flags().is_final()) { | |
125 return false; | |
126 } else { | |
127 return compute_shared_has_subklass(); | |
128 } | |
129 } | |
130 return _has_subklass; | |
131 } | |
132 jint size_helper() { | |
133 return (Klass::layout_helper_size_in_bytes(layout_helper()) | |
134 >> LogHeapWordSize); | |
135 } | |
136 jint nonstatic_field_size() { | |
137 assert(is_loaded(), "must be loaded"); | |
138 return _nonstatic_field_size; } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
139 jint has_nonstatic_fields() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
44
diff
changeset
|
140 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
|
141 return _has_nonstatic_fields; } |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
142 jint nonstatic_oop_map_size() { |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
143 assert(is_loaded(), "must be loaded"); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
144 return _nonstatic_oop_map_size; } |
0 | 145 ciInstanceKlass* super(); |
146 jint nof_implementors() { | |
147 assert(is_loaded(), "must be loaded"); | |
148 if (_is_shared) return compute_shared_nof_implementors(); | |
149 return _nof_implementors; | |
150 } | |
151 | |
152 ciInstanceKlass* get_canonical_holder(int offset); | |
153 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
|
154 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
|
155 |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
156 GrowableArray<ciField*>* non_static_fields(); |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
157 |
0 | 158 // total number of nonstatic fields (including inherited): |
159 int nof_nonstatic_fields() { | |
160 if (_nonstatic_fields == NULL) | |
161 return compute_nonstatic_fields(); | |
162 else | |
163 return _nonstatic_fields->length(); | |
164 } | |
165 // nth nonstatic field (presented by ascending address) | |
166 ciField* nonstatic_field_at(int i) { | |
167 assert(_nonstatic_fields != NULL, ""); | |
168 return _nonstatic_fields->at(i); | |
169 } | |
170 | |
171 ciInstanceKlass* unique_concrete_subklass(); | |
172 bool has_finalizable_subclass(); | |
173 | |
174 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
|
175 return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size()); |
0 | 176 } |
177 | |
178 // Get the instance of java.lang.Class corresponding to | |
179 // this klass. This instance is used for locking of | |
180 // synchronized static methods of this klass. | |
181 ciInstance* java_mirror(); | |
182 | |
183 // Java access flags | |
184 bool is_public () { return flags().is_public(); } | |
185 bool is_final () { return flags().is_final(); } | |
186 bool is_super () { return flags().is_super(); } | |
187 bool is_interface () { return flags().is_interface(); } | |
188 bool is_abstract () { return flags().is_abstract(); } | |
189 | |
190 ciMethod* find_method(ciSymbol* name, ciSymbol* signature); | |
191 // Note: To find a method from name and type strings, use ciSymbol::make, | |
192 // but consider adding to vmSymbols.hpp instead. | |
193 | |
194 bool is_leaf_type(); | |
195 ciInstanceKlass* implementor(int n); | |
196 | |
197 // Is the defining class loader of this class the default loader? | |
198 bool uses_default_loader(); | |
199 | |
200 bool is_java_lang_Object(); | |
201 | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
202 // Is this klass in the given package? |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
203 bool is_in_package(const char* packagename) { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
204 return is_in_package(packagename, (int) strlen(packagename)); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
205 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
206 bool is_in_package(const char* packagename, int len); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1080
diff
changeset
|
207 |
0 | 208 // What kind of ciObject is this? |
209 bool is_instance_klass() { return true; } | |
210 bool is_java_klass() { return true; } | |
211 }; |