Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciKlass.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 532be189cf09 da91efe96a93 |
children | ce248dc0a656 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
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) { | |
69 assert(is_loaded() && that->is_loaded(), "must be loaded"); | |
70 // Check to see if the klasses are identical. | |
71 if (this == that) { | |
72 return true; | |
73 } | |
4977
532be189cf09
Reducing diff to hsx24
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3672
diff
changeset
|
74 #ifndef GRAAL |
0 | 75 VM_ENTRY_MARK; |
4977
532be189cf09
Reducing diff to hsx24
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3672
diff
changeset
|
76 #endif |
0 | 77 Klass* this_klass = get_Klass(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
78 Klass* that_klass = that->get_Klass(); |
0 | 79 bool result = this_klass->is_subtype_of(that_klass); |
80 | |
81 return result; | |
82 } | |
83 | |
84 // ------------------------------------------------------------------ | |
85 // ciKlass::is_subclass_of | |
86 bool ciKlass::is_subclass_of(ciKlass* that) { | |
87 assert(is_loaded() && that->is_loaded(), "must be loaded"); | |
88 // Check to see if the klasses are identical. | |
89 | |
90 VM_ENTRY_MARK; | |
91 Klass* this_klass = get_Klass(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
92 Klass* that_klass = that->get_Klass(); |
0 | 93 bool result = this_klass->is_subclass_of(that_klass); |
94 | |
95 return result; | |
96 } | |
97 | |
98 // ------------------------------------------------------------------ | |
99 // ciKlass::super_depth | |
100 juint ciKlass::super_depth() { | |
101 assert(is_loaded(), "must be loaded"); | |
102 | |
103 VM_ENTRY_MARK; | |
104 Klass* this_klass = get_Klass(); | |
105 return this_klass->super_depth(); | |
106 } | |
107 | |
108 // ------------------------------------------------------------------ | |
109 // ciKlass::super_check_offset | |
110 juint ciKlass::super_check_offset() { | |
111 assert(is_loaded(), "must be loaded"); | |
112 | |
113 VM_ENTRY_MARK; | |
114 Klass* this_klass = get_Klass(); | |
115 return this_klass->super_check_offset(); | |
116 } | |
117 | |
118 // ------------------------------------------------------------------ | |
119 // ciKlass::super_of_depth | |
120 ciKlass* ciKlass::super_of_depth(juint i) { | |
121 assert(is_loaded(), "must be loaded"); | |
122 | |
123 VM_ENTRY_MARK; | |
124 Klass* this_klass = get_Klass(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
125 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
|
126 return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL; |
0 | 127 } |
128 | |
129 // ------------------------------------------------------------------ | |
130 // ciKlass::can_be_primary_super | |
131 bool ciKlass::can_be_primary_super() { | |
132 assert(is_loaded(), "must be loaded"); | |
133 | |
134 VM_ENTRY_MARK; | |
135 Klass* this_klass = get_Klass(); | |
136 return this_klass->can_be_primary_super(); | |
137 } | |
138 | |
139 // ------------------------------------------------------------------ | |
140 // ciKlass::least_common_ancestor | |
141 // | |
142 // Get the shared parent of two klasses. | |
143 // | |
144 // Implementation note: this method currently goes "over the wall" | |
145 // and does all of the work on the VM side. It could be rewritten | |
146 // to use the super() method and do all of the work (aside from the | |
147 // lazy computation of super()) in native mode. This may be | |
148 // worthwhile if the compiler is repeatedly requesting the same lca | |
149 // computation or possibly if most of the superklasses have already | |
150 // been created as ciObjects anyway. Something to think about... | |
151 ciKlass* | |
152 ciKlass::least_common_ancestor(ciKlass* that) { | |
153 assert(is_loaded() && that->is_loaded(), "must be loaded"); | |
154 // Check to see if the klasses are identical. | |
155 if (this == that) { | |
156 return this; | |
157 } | |
158 | |
159 VM_ENTRY_MARK; | |
160 Klass* this_klass = get_Klass(); | |
161 Klass* that_klass = that->get_Klass(); | |
162 Klass* lca = this_klass->LCA(that_klass); | |
163 | |
164 // Many times the LCA will be either this_klass or that_klass. | |
165 // Treat these as special cases. | |
166 if (lca == that_klass) { | |
167 return that; | |
168 } | |
169 if (this_klass == lca) { | |
170 return this; | |
171 } | |
172 | |
173 // Create the ciInstanceKlass for the lca. | |
174 ciKlass* result = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
175 CURRENT_THREAD_ENV->get_klass(lca); |
0 | 176 |
177 return result; | |
178 } | |
179 | |
180 // ------------------------------------------------------------------ | |
181 // ciKlass::find_klass | |
182 // | |
183 // Find a klass using this klass's class loader. | |
184 ciKlass* ciKlass::find_klass(ciSymbol* klass_name) { | |
185 assert(is_loaded(), "cannot find_klass through an unloaded klass"); | |
186 return CURRENT_ENV->get_klass_by_name(this, | |
187 klass_name, false); | |
188 } | |
189 | |
190 // ------------------------------------------------------------------ | |
191 // ciKlass::java_mirror | |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
192 // |
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
193 // 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
|
194 // 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
|
195 // mirror object of type Class. |
0 | 196 ciInstance* ciKlass::java_mirror() { |
197 GUARDED_VM_ENTRY( | |
1604
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
198 if (!is_loaded()) |
b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
1552
diff
changeset
|
199 return ciEnv::current()->get_unloaded_klass_mirror(this); |
0 | 200 oop java_mirror = get_Klass()->java_mirror(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
201 return CURRENT_ENV->get_instance(java_mirror); |
0 | 202 ) |
203 } | |
204 | |
205 // ------------------------------------------------------------------ | |
206 // ciKlass::modifier_flags | |
207 jint ciKlass::modifier_flags() { | |
208 assert(is_loaded(), "not loaded"); | |
209 GUARDED_VM_ENTRY( | |
210 return get_Klass()->modifier_flags(); | |
211 ) | |
212 } | |
213 | |
214 // ------------------------------------------------------------------ | |
215 // ciKlass::access_flags | |
216 jint ciKlass::access_flags() { | |
217 assert(is_loaded(), "not loaded"); | |
218 GUARDED_VM_ENTRY( | |
219 return get_Klass()->access_flags().as_int(); | |
220 ) | |
221 } | |
222 | |
223 // ------------------------------------------------------------------ | |
224 // ciKlass::print_impl | |
225 // | |
226 // Implementation of the print method | |
227 void ciKlass::print_impl(outputStream* st) { | |
228 st->print(" name="); | |
229 print_name_on(st); | |
230 } | |
231 | |
232 // ------------------------------------------------------------------ | |
233 // ciKlass::print_name | |
234 // | |
235 // Print the name of this klass | |
236 void ciKlass::print_name_on(outputStream* st) { | |
237 name()->print_symbol_on(st); | |
238 } |