Mercurial > hg > truffle
annotate src/share/vm/ci/ciKlass.cpp @ 17374:9928ad27a80e
OopRecorder should check for duplicates
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 08 Oct 2014 11:48:00 -0700 |
parents | 4ca6dc0799b6 |
children | 89152779163c |
rev | line source |
---|---|
0 | 1 /* |
14909 | 2 * Copyright (c) 1999, 2012, 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 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "ci/ciKlass.hpp" | |
27 #include "ci/ciSymbol.hpp" | |
28 #include "ci/ciUtilities.hpp" | |
29 #include "oops/oop.inline.hpp" | |
0 | 30 |
31 // ciKlass | |
32 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
33 // This class represents a Klass* in the HotSpot virtual |
0 | 34 // machine. |
35 | |
36 // ------------------------------------------------------------------ | |
37 // ciKlass::ciKlass | |
38 ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
39 assert(get_Klass()->is_klass(), "wrong type"); |
0 | 40 Klass* k = get_Klass(); |
41 _layout_helper = k->layout_helper(); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
42 Symbol* klass_name = k->name(); |
0 | 43 assert(klass_name != NULL, "wrong ciKlass constructor"); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
44 _name = CURRENT_ENV->get_symbol(klass_name); |
0 | 45 } |
46 | |
47 // ------------------------------------------------------------------ | |
48 // ciKlass::ciKlass | |
49 // | |
50 // Nameless klass variant. | |
51 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
52 assert(get_Klass()->is_klass(), "wrong type"); |
0 | 53 _name = name; |
54 _layout_helper = Klass::_lh_neutral_value; | |
55 } | |
56 | |
57 // ------------------------------------------------------------------ | |
58 // ciKlass::ciKlass | |
59 // | |
60 // Unloaded klass variant. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
61 ciKlass::ciKlass(ciSymbol* name, BasicType bt) : ciType(bt) { |
0 | 62 _name = name; |
63 _layout_helper = Klass::_lh_neutral_value; | |
64 } | |
65 | |
66 // ------------------------------------------------------------------ | |
67 // ciKlass::is_subtype_of | |
68 bool ciKlass::is_subtype_of(ciKlass* that) { | |
12871 | 69 assert(this->is_loaded(), err_msg("must be loaded: %s", this->name()->as_quoted_ascii())); |
70 assert(that->is_loaded(), err_msg("must be loaded: %s", that->name()->as_quoted_ascii())); | |
71 | |
0 | 72 // Check to see if the klasses are identical. |
73 if (this == that) { | |
74 return true; | |
75 } | |
76 | |
77 VM_ENTRY_MARK; | |
78 Klass* this_klass = get_Klass(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
79 Klass* that_klass = that->get_Klass(); |
0 | 80 bool result = this_klass->is_subtype_of(that_klass); |
81 | |
82 return result; | |
83 } | |
84 | |
85 // ------------------------------------------------------------------ | |
86 // ciKlass::is_subclass_of | |
87 bool ciKlass::is_subclass_of(ciKlass* that) { | |
12871 | 88 assert(this->is_loaded(), err_msg("must be loaded: %s", this->name()->as_quoted_ascii())); |
89 assert(that->is_loaded(), err_msg("must be loaded: %s", that->name()->as_quoted_ascii())); | |
0 | 90 |
91 VM_ENTRY_MARK; | |
92 Klass* this_klass = get_Klass(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
93 Klass* that_klass = that->get_Klass(); |
0 | 94 bool result = this_klass->is_subclass_of(that_klass); |
95 | |
96 return result; | |
97 } | |
98 | |
99 // ------------------------------------------------------------------ | |
100 // ciKlass::super_depth | |
101 juint ciKlass::super_depth() { | |
102 assert(is_loaded(), "must be loaded"); | |
103 | |
104 VM_ENTRY_MARK; | |
105 Klass* this_klass = get_Klass(); | |
106 return this_klass->super_depth(); | |
107 } | |
108 | |
109 // ------------------------------------------------------------------ | |
110 // ciKlass::super_check_offset | |
111 juint ciKlass::super_check_offset() { | |
112 assert(is_loaded(), "must be loaded"); | |
113 | |
114 VM_ENTRY_MARK; | |
115 Klass* this_klass = get_Klass(); | |
116 return this_klass->super_check_offset(); | |
117 } | |
118 | |
119 // ------------------------------------------------------------------ | |
120 // ciKlass::super_of_depth | |
121 ciKlass* ciKlass::super_of_depth(juint i) { | |
122 assert(is_loaded(), "must be loaded"); | |
123 | |
124 VM_ENTRY_MARK; | |
125 Klass* this_klass = get_Klass(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
126 Klass* super = this_klass->primary_super_of_depth(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
127 return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL; |
0 | 128 } |
129 | |
130 // ------------------------------------------------------------------ | |
131 // ciKlass::can_be_primary_super | |
132 bool ciKlass::can_be_primary_super() { | |
133 assert(is_loaded(), "must be loaded"); | |
134 | |
135 VM_ENTRY_MARK; | |
136 Klass* this_klass = get_Klass(); | |
137 return this_klass->can_be_primary_super(); | |
138 } | |
139 | |
140 // ------------------------------------------------------------------ | |
141 // ciKlass::least_common_ancestor | |
142 // | |
143 // Get the shared parent of two klasses. | |
144 // | |
145 // Implementation note: this method currently goes "over the wall" | |
146 // and does all of the work on the VM side. It could be rewritten | |
147 // to use the super() method and do all of the work (aside from the | |
148 // lazy computation of super()) in native mode. This may be | |
149 // worthwhile if the compiler is repeatedly requesting the same lca | |
150 // computation or possibly if most of the superklasses have already | |
151 // been created as ciObjects anyway. Something to think about... | |
152 ciKlass* | |
153 ciKlass::least_common_ancestor(ciKlass* that) { | |
154 assert(is_loaded() && that->is_loaded(), "must be loaded"); | |
155 // Check to see if the klasses are identical. | |
156 if (this == that) { | |
157 return this; | |
158 } | |
159 | |
160 VM_ENTRY_MARK; | |
161 Klass* this_klass = get_Klass(); | |
162 Klass* that_klass = that->get_Klass(); | |
163 Klass* lca = this_klass->LCA(that_klass); | |
164 | |
165 // Many times the LCA will be either this_klass or that_klass. | |
166 // Treat these as special cases. | |
167 if (lca == that_klass) { | |
168 return that; | |
169 } | |
170 if (this_klass == lca) { | |
171 return this; | |
172 } | |
173 | |
174 // Create the ciInstanceKlass for the lca. | |
175 ciKlass* result = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
176 CURRENT_THREAD_ENV->get_klass(lca); |
0 | 177 |
178 return result; | |
179 } | |
180 | |
181 // ------------------------------------------------------------------ | |
182 // ciKlass::find_klass | |
183 // | |
184 // Find a klass using this klass's class loader. | |
185 ciKlass* ciKlass::find_klass(ciSymbol* klass_name) { | |
186 assert(is_loaded(), "cannot find_klass through an unloaded klass"); | |
187 return CURRENT_ENV->get_klass_by_name(this, | |
188 klass_name, false); | |
189 } | |
190 | |
191 // ------------------------------------------------------------------ | |
192 // ciKlass::java_mirror | |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
193 // |
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
194 // Get the instance of java.lang.Class corresponding to this klass. |
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
195 // If it is an unloaded instance or array klass, return an unloaded |
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
196 // mirror object of type Class. |
0 | 197 ciInstance* ciKlass::java_mirror() { |
198 GUARDED_VM_ENTRY( | |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
199 if (!is_loaded()) |
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
200 return ciEnv::current()->get_unloaded_klass_mirror(this); |
0 | 201 oop java_mirror = get_Klass()->java_mirror(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
202 return CURRENT_ENV->get_instance(java_mirror); |
0 | 203 ) |
204 } | |
205 | |
206 // ------------------------------------------------------------------ | |
207 // ciKlass::modifier_flags | |
208 jint ciKlass::modifier_flags() { | |
209 assert(is_loaded(), "not loaded"); | |
210 GUARDED_VM_ENTRY( | |
211 return get_Klass()->modifier_flags(); | |
212 ) | |
213 } | |
214 | |
215 // ------------------------------------------------------------------ | |
216 // ciKlass::access_flags | |
217 jint ciKlass::access_flags() { | |
218 assert(is_loaded(), "not loaded"); | |
219 GUARDED_VM_ENTRY( | |
220 return get_Klass()->access_flags().as_int(); | |
221 ) | |
222 } | |
223 | |
224 // ------------------------------------------------------------------ | |
225 // ciKlass::print_impl | |
226 // | |
227 // Implementation of the print method | |
228 void ciKlass::print_impl(outputStream* st) { | |
229 st->print(" name="); | |
230 print_name_on(st); | |
231 } | |
232 | |
233 // ------------------------------------------------------------------ | |
234 // ciKlass::print_name | |
235 // | |
236 // Print the name of this klass | |
237 void ciKlass::print_name_on(outputStream* st) { | |
238 name()->print_symbol_on(st); | |
239 } |