Print this page
rev 1026 : imported patch indy.compiler.inline.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/ci/ciKlass.cpp
+++ new/src/share/vm/ci/ciKlass.cpp
1 1 /*
2 - * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
2 + * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 #include "incls/_precompiled.incl"
26 26 #include "incls/_ciKlass.cpp.incl"
27 27
28 28 // ciKlass
29 29 //
30 30 // This class represents a klassOop in the HotSpot virtual
31 31 // machine.
32 32
33 33 // ------------------------------------------------------------------
34 34 // ciKlass::ciKlass
35 35 ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) {
36 36 assert(get_oop()->is_klass(), "wrong type");
37 37 Klass* k = get_Klass();
38 38 _layout_helper = k->layout_helper();
39 39 symbolOop klass_name = k->name();
40 40 assert(klass_name != NULL, "wrong ciKlass constructor");
41 41 _name = CURRENT_ENV->get_object(klass_name)->as_symbol();
42 42 }
43 43
44 44 // ------------------------------------------------------------------
45 45 // ciKlass::ciKlass
46 46 //
47 47 // Nameless klass variant.
48 48 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) {
49 49 assert(get_oop()->is_klass(), "wrong type");
50 50 _name = name;
51 51 _layout_helper = Klass::_lh_neutral_value;
52 52 }
53 53
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
54 54 // ------------------------------------------------------------------
55 55 // ciKlass::ciKlass
56 56 //
57 57 // Unloaded klass variant.
58 58 ciKlass::ciKlass(ciSymbol* name, ciKlass* klass) : ciType(klass) {
59 59 _name = name;
60 60 _layout_helper = Klass::_lh_neutral_value;
61 61 }
62 62
63 63 // ------------------------------------------------------------------
64 +// ciKlass::is_in_package
65 +//
66 +// Is this klass in the given package?
67 +bool ciKlass::is_in_package(const char* packagename) const {
68 + ResourceMark rm;
69 + Klass* klass = get_klassOop()->klass_part();
70 + const char* external_name = klass->external_name();
71 + size_t packagename_len = strlen(packagename);
72 + return (strncmp(packagename, external_name, packagename_len) == 0);
73 +}
74 +
75 +// ------------------------------------------------------------------
64 76 // ciKlass::is_subtype_of
65 77 bool ciKlass::is_subtype_of(ciKlass* that) {
66 78 assert(is_loaded() && that->is_loaded(), "must be loaded");
67 79 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
68 80 // Check to see if the klasses are identical.
69 81 if (this == that) {
70 82 return true;
71 83 }
72 84
73 85 VM_ENTRY_MARK;
74 86 Klass* this_klass = get_Klass();
75 87 klassOop that_klass = that->get_klassOop();
76 88 bool result = this_klass->is_subtype_of(that_klass);
77 89
78 90 return result;
79 91 }
80 92
81 93 // ------------------------------------------------------------------
82 94 // ciKlass::is_subclass_of
83 95 bool ciKlass::is_subclass_of(ciKlass* that) {
84 96 assert(is_loaded() && that->is_loaded(), "must be loaded");
85 97 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
86 98 // Check to see if the klasses are identical.
87 99
88 100 VM_ENTRY_MARK;
89 101 Klass* this_klass = get_Klass();
90 102 klassOop that_klass = that->get_klassOop();
91 103 bool result = this_klass->is_subclass_of(that_klass);
92 104
93 105 return result;
94 106 }
95 107
96 108 // ------------------------------------------------------------------
97 109 // ciKlass::super_depth
98 110 juint ciKlass::super_depth() {
99 111 assert(is_loaded(), "must be loaded");
100 112 assert(is_java_klass(), "must be java klasses");
101 113
102 114 VM_ENTRY_MARK;
103 115 Klass* this_klass = get_Klass();
104 116 return this_klass->super_depth();
105 117 }
106 118
107 119 // ------------------------------------------------------------------
108 120 // ciKlass::super_check_offset
109 121 juint ciKlass::super_check_offset() {
110 122 assert(is_loaded(), "must be loaded");
111 123 assert(is_java_klass(), "must be java klasses");
112 124
113 125 VM_ENTRY_MARK;
114 126 Klass* this_klass = get_Klass();
115 127 return this_klass->super_check_offset();
116 128 }
117 129
118 130 // ------------------------------------------------------------------
119 131 // ciKlass::super_of_depth
120 132 ciKlass* ciKlass::super_of_depth(juint i) {
121 133 assert(is_loaded(), "must be loaded");
122 134 assert(is_java_klass(), "must be java klasses");
123 135
124 136 VM_ENTRY_MARK;
125 137 Klass* this_klass = get_Klass();
126 138 klassOop super = this_klass->primary_super_of_depth(i);
127 139 return (super != NULL) ? CURRENT_THREAD_ENV->get_object(super)->as_klass() : NULL;
128 140 }
129 141
130 142 // ------------------------------------------------------------------
131 143 // ciKlass::can_be_primary_super
132 144 bool ciKlass::can_be_primary_super() {
133 145 assert(is_loaded(), "must be loaded");
134 146 assert(is_java_klass(), "must be java klasses");
135 147
136 148 VM_ENTRY_MARK;
137 149 Klass* this_klass = get_Klass();
138 150 return this_klass->can_be_primary_super();
139 151 }
140 152
141 153 // ------------------------------------------------------------------
142 154 // ciKlass::least_common_ancestor
143 155 //
144 156 // Get the shared parent of two klasses.
145 157 //
146 158 // Implementation note: this method currently goes "over the wall"
147 159 // and does all of the work on the VM side. It could be rewritten
148 160 // to use the super() method and do all of the work (aside from the
149 161 // lazy computation of super()) in native mode. This may be
150 162 // worthwhile if the compiler is repeatedly requesting the same lca
151 163 // computation or possibly if most of the superklasses have already
152 164 // been created as ciObjects anyway. Something to think about...
153 165 ciKlass*
154 166 ciKlass::least_common_ancestor(ciKlass* that) {
155 167 assert(is_loaded() && that->is_loaded(), "must be loaded");
156 168 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
157 169 // Check to see if the klasses are identical.
158 170 if (this == that) {
159 171 return this;
160 172 }
161 173
162 174 VM_ENTRY_MARK;
163 175 Klass* this_klass = get_Klass();
164 176 Klass* that_klass = that->get_Klass();
165 177 Klass* lca = this_klass->LCA(that_klass);
166 178
167 179 // Many times the LCA will be either this_klass or that_klass.
168 180 // Treat these as special cases.
169 181 if (lca == that_klass) {
170 182 return that;
171 183 }
172 184 if (this_klass == lca) {
173 185 return this;
174 186 }
175 187
176 188 // Create the ciInstanceKlass for the lca.
177 189 ciKlass* result =
178 190 CURRENT_THREAD_ENV->get_object(lca->as_klassOop())->as_klass();
179 191
180 192 return result;
181 193 }
182 194
183 195 // ------------------------------------------------------------------
184 196 // ciKlass::find_klass
185 197 //
186 198 // Find a klass using this klass's class loader.
187 199 ciKlass* ciKlass::find_klass(ciSymbol* klass_name) {
188 200 assert(is_loaded(), "cannot find_klass through an unloaded klass");
189 201 return CURRENT_ENV->get_klass_by_name(this,
190 202 klass_name, false);
191 203 }
192 204
193 205 // ------------------------------------------------------------------
194 206 // ciKlass::java_mirror
195 207 ciInstance* ciKlass::java_mirror() {
196 208 GUARDED_VM_ENTRY(
197 209 oop java_mirror = get_Klass()->java_mirror();
198 210 return CURRENT_ENV->get_object(java_mirror)->as_instance();
199 211 )
200 212 }
201 213
202 214 // ------------------------------------------------------------------
203 215 // ciKlass::modifier_flags
204 216 jint ciKlass::modifier_flags() {
205 217 assert(is_loaded(), "not loaded");
206 218 GUARDED_VM_ENTRY(
207 219 return get_Klass()->modifier_flags();
208 220 )
209 221 }
210 222
211 223 // ------------------------------------------------------------------
212 224 // ciKlass::access_flags
213 225 jint ciKlass::access_flags() {
214 226 assert(is_loaded(), "not loaded");
215 227 GUARDED_VM_ENTRY(
216 228 return get_Klass()->access_flags().as_int();
217 229 )
218 230 }
219 231
220 232 // ------------------------------------------------------------------
221 233 // ciKlass::print_impl
222 234 //
223 235 // Implementation of the print method
224 236 void ciKlass::print_impl(outputStream* st) {
225 237 st->print(" name=");
226 238 print_name_on(st);
227 239 }
228 240
229 241 // ------------------------------------------------------------------
230 242 // ciKlass::print_name
231 243 //
232 244 // Print the name of this klass
233 245 void ciKlass::print_name_on(outputStream* st) {
234 246 name()->print_symbol_on(st);
235 247 }
↓ open down ↓ |
162 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX