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