author | david |
Tue, 29 Sep 2015 11:02:08 +0200 | |
changeset 33105 | 294e48b4f704 |
parent 24002 | 4e6a72032a99 |
child 38030 | 93f24e7b3c43 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
20698
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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" |
|
1 | 30 |
|
31 |
// ciKlass |
|
32 |
// |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
33 |
// This class represents a Klass* in the HotSpot virtual |
1 | 34 |
// machine. |
35 |
||
36 |
// ------------------------------------------------------------------ |
|
37 |
// ciKlass::ciKlass |
|
38 |
ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
39 |
assert(get_Klass()->is_klass(), "wrong type"); |
1 | 40 |
Klass* k = get_Klass(); |
41 |
_layout_helper = k->layout_helper(); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
42 |
Symbol* klass_name = k->name(); |
1 | 43 |
assert(klass_name != NULL, "wrong ciKlass constructor"); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
44 |
_name = CURRENT_ENV->get_symbol(klass_name); |
1 | 45 |
} |
46 |
||
47 |
// ------------------------------------------------------------------ |
|
48 |
// ciKlass::ciKlass |
|
49 |
// |
|
50 |
// Nameless klass variant. |
|
51 |
ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
52 |
assert(get_Klass()->is_klass(), "wrong type"); |
1 | 53 |
_name = name; |
54 |
_layout_helper = Klass::_lh_neutral_value; |
|
55 |
} |
|
56 |
||
57 |
// ------------------------------------------------------------------ |
|
58 |
// ciKlass::ciKlass |
|
59 |
// |
|
60 |
// Unloaded klass variant. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
61 |
ciKlass::ciKlass(ciSymbol* name, BasicType bt) : ciType(bt) { |
1 | 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) { |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
24002
diff
changeset
|
69 |
assert(this->is_loaded(), "must be loaded: %s", this->name()->as_quoted_ascii()); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
24002
diff
changeset
|
70 |
assert(that->is_loaded(), "must be loaded: %s", that->name()->as_quoted_ascii()); |
20698 | 71 |
|
1 | 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(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
79 |
Klass* that_klass = that->get_Klass(); |
1 | 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) { |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
24002
diff
changeset
|
88 |
assert(this->is_loaded(), "must be loaded: %s", this->name()->as_quoted_ascii()); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
24002
diff
changeset
|
89 |
assert(that->is_loaded(), "must be loaded: %s", that->name()->as_quoted_ascii()); |
1 | 90 |
|
91 |
VM_ENTRY_MARK; |
|
92 |
Klass* this_klass = get_Klass(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
93 |
Klass* that_klass = that->get_Klass(); |
1 | 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(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
126 |
Klass* super = this_klass->primary_super_of_depth(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
127 |
return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL; |
1 | 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 = |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
176 |
CURRENT_THREAD_ENV->get_klass(lca); |
1 | 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 |
|
5884
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5547
diff
changeset
|
193 |
// |
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5547
diff
changeset
|
194 |
// Get the instance of java.lang.Class corresponding to this klass. |
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5547
diff
changeset
|
195 |
// If it is an unloaded instance or array klass, return an unloaded |
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5547
diff
changeset
|
196 |
// mirror object of type Class. |
1 | 197 |
ciInstance* ciKlass::java_mirror() { |
198 |
GUARDED_VM_ENTRY( |
|
5884
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5547
diff
changeset
|
199 |
if (!is_loaded()) |
3963019e3782
6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents:
5547
diff
changeset
|
200 |
return ciEnv::current()->get_unloaded_klass_mirror(this); |
1 | 201 |
oop java_mirror = get_Klass()->java_mirror(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
202 |
return CURRENT_ENV->get_instance(java_mirror); |
1 | 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 |
} |
|
24002
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
240 |
|
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
241 |
const char* ciKlass::external_name() const { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
242 |
GUARDED_VM_ENTRY( |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
243 |
return get_Klass()->external_name(); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
244 |
) |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
245 |
} |