Mercurial > hg > graal-compiler
annotate src/share/vm/oops/methodKlass.cpp @ 878:abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
Summary: JVM_FindClassFromBootLoader returns null if class not found
Reviewed-by: acorn, alanb, dholmes
author | mchung |
---|---|
date | Mon, 27 Jul 2009 09:06:22 -0700 |
parents | e5b0439ef4ae |
children | 75596850f863 |
rev | line source |
---|---|
0 | 1 /* |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
2 * Copyright 1997-2009 Sun Microsystems, Inc. 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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_methodKlass.cpp.incl" | |
27 | |
28 klassOop methodKlass::create_klass(TRAPS) { | |
29 methodKlass o; | |
30 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); | |
31 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
32 // Make sure size calculation is right | |
33 assert(k()->size() == align_object_size(header_size()), "wrong size for object"); | |
34 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror | |
35 return k(); | |
36 } | |
37 | |
38 | |
39 int methodKlass::oop_size(oop obj) const { | |
40 assert(obj->is_method(), "must be method oop"); | |
41 return methodOop(obj)->object_size(); | |
42 } | |
43 | |
44 | |
45 bool methodKlass::oop_is_parsable(oop obj) const { | |
46 assert(obj->is_method(), "must be method oop"); | |
47 return methodOop(obj)->object_is_parsable(); | |
48 } | |
49 | |
50 | |
51 methodOop methodKlass::allocate(constMethodHandle xconst, | |
52 AccessFlags access_flags, TRAPS) { | |
53 int size = methodOopDesc::object_size(access_flags.is_native()); | |
54 KlassHandle h_k(THREAD, as_klassOop()); | |
55 assert(xconst()->is_parsable(), "possible publication protocol violation"); | |
56 methodOop m = (methodOop)CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL); | |
57 assert(!m->is_parsable(), "not expecting parsability yet."); | |
58 | |
59 No_Safepoint_Verifier no_safepoint; // until m becomes parsable below | |
60 m->set_constMethod(xconst()); | |
61 m->set_access_flags(access_flags); | |
62 m->set_method_size(size); | |
63 m->set_name_index(0); | |
64 m->set_signature_index(0); | |
65 #ifdef CC_INTERP | |
66 m->set_result_index(T_VOID); | |
67 #endif | |
68 m->set_constants(NULL); | |
69 m->set_max_stack(0); | |
70 m->set_max_locals(0); | |
71 m->clear_intrinsic_id_cache(); | |
72 m->set_method_data(NULL); | |
73 m->set_interpreter_throwout_count(0); | |
74 m->set_vtable_index(methodOopDesc::garbage_vtable_index); | |
75 | |
76 // Fix and bury in methodOop | |
77 m->set_interpreter_entry(NULL); // sets i2i entry and from_int | |
78 m->set_highest_tier_compile(CompLevel_none); | |
79 m->set_adapter_entry(NULL); | |
80 m->clear_code(); // from_c/from_i get set to c2i/i2i | |
81 | |
82 if (access_flags.is_native()) { | |
83 m->clear_native_function(); | |
84 m->set_signature_handler(NULL); | |
85 } | |
86 | |
87 NOT_PRODUCT(m->set_compiled_invocation_count(0);) | |
88 m->set_interpreter_invocation_count(0); | |
89 m->invocation_counter()->init(); | |
90 m->backedge_counter()->init(); | |
91 m->clear_number_of_breakpoints(); | |
92 assert(m->is_parsable(), "must be parsable here."); | |
93 assert(m->size() == size, "wrong size for object"); | |
94 // We should not publish an uprasable object's reference | |
95 // into one that is parsable, since that presents problems | |
96 // for the concurrent parallel marking and precleaning phases | |
97 // of concurrent gc (CMS). | |
98 xconst->set_method(m); | |
99 return m; | |
100 } | |
101 | |
102 | |
103 void methodKlass::oop_follow_contents(oop obj) { | |
104 assert (obj->is_method(), "object must be method"); | |
105 methodOop m = methodOop(obj); | |
106 // Performance tweak: We skip iterating over the klass pointer since we | |
107 // know that Universe::methodKlassObj never moves. | |
108 MarkSweep::mark_and_push(m->adr_constMethod()); | |
109 MarkSweep::mark_and_push(m->adr_constants()); | |
110 if (m->method_data() != NULL) { | |
111 MarkSweep::mark_and_push(m->adr_method_data()); | |
112 } | |
113 } | |
114 | |
115 #ifndef SERIALGC | |
116 void methodKlass::oop_follow_contents(ParCompactionManager* cm, | |
117 oop obj) { | |
118 assert (obj->is_method(), "object must be method"); | |
119 methodOop m = methodOop(obj); | |
120 // Performance tweak: We skip iterating over the klass pointer since we | |
121 // know that Universe::methodKlassObj never moves. | |
122 PSParallelCompact::mark_and_push(cm, m->adr_constMethod()); | |
123 PSParallelCompact::mark_and_push(cm, m->adr_constants()); | |
124 #ifdef COMPILER2 | |
125 if (m->method_data() != NULL) { | |
126 PSParallelCompact::mark_and_push(cm, m->adr_method_data()); | |
127 } | |
128 #endif // COMPILER2 | |
129 } | |
130 #endif // SERIALGC | |
131 | |
132 int methodKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
133 assert (obj->is_method(), "object must be method"); | |
134 methodOop m = methodOop(obj); | |
135 // Get size before changing pointers. | |
136 // Don't call size() or oop_size() since that is a virtual call. | |
137 int size = m->object_size(); | |
138 // Performance tweak: We skip iterating over the klass pointer since we | |
139 // know that Universe::methodKlassObj never moves | |
140 blk->do_oop(m->adr_constMethod()); | |
141 blk->do_oop(m->adr_constants()); | |
142 if (m->method_data() != NULL) { | |
143 blk->do_oop(m->adr_method_data()); | |
144 } | |
145 return size; | |
146 } | |
147 | |
148 | |
149 int methodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
150 assert (obj->is_method(), "object must be method"); | |
151 methodOop m = methodOop(obj); | |
152 // Get size before changing pointers. | |
153 // Don't call size() or oop_size() since that is a virtual call. | |
154 int size = m->object_size(); | |
155 // Performance tweak: We skip iterating over the klass pointer since we | |
156 // know that Universe::methodKlassObj never moves. | |
157 oop* adr; | |
158 adr = m->adr_constMethod(); | |
159 if (mr.contains(adr)) blk->do_oop(adr); | |
160 adr = m->adr_constants(); | |
161 if (mr.contains(adr)) blk->do_oop(adr); | |
162 if (m->method_data() != NULL) { | |
163 adr = m->adr_method_data(); | |
164 if (mr.contains(adr)) blk->do_oop(adr); | |
165 } | |
166 return size; | |
167 } | |
168 | |
169 | |
170 int methodKlass::oop_adjust_pointers(oop obj) { | |
171 assert(obj->is_method(), "should be method"); | |
172 methodOop m = methodOop(obj); | |
173 // Get size before changing pointers. | |
174 // Don't call size() or oop_size() since that is a virtual call. | |
175 int size = m->object_size(); | |
176 // Performance tweak: We skip iterating over the klass pointer since we | |
177 // know that Universe::methodKlassObj never moves. | |
178 MarkSweep::adjust_pointer(m->adr_constMethod()); | |
179 MarkSweep::adjust_pointer(m->adr_constants()); | |
180 if (m->method_data() != NULL) { | |
181 MarkSweep::adjust_pointer(m->adr_method_data()); | |
182 } | |
183 return size; | |
184 } | |
185 | |
186 #ifndef SERIALGC | |
187 void methodKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) { | |
188 assert(obj->is_method(), "should be method"); | |
189 } | |
190 | |
191 void methodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
192 assert(obj->is_method(), "should be method"); | |
193 } | |
194 | |
195 int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
196 assert(obj->is_method(), "should be method"); | |
197 methodOop m = methodOop(obj); | |
198 PSParallelCompact::adjust_pointer(m->adr_constMethod()); | |
199 PSParallelCompact::adjust_pointer(m->adr_constants()); | |
200 #ifdef COMPILER2 | |
201 if (m->method_data() != NULL) { | |
202 PSParallelCompact::adjust_pointer(m->adr_method_data()); | |
203 } | |
204 #endif // COMPILER2 | |
205 return m->object_size(); | |
206 } | |
207 | |
208 int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
209 HeapWord* beg_addr, HeapWord* end_addr) { | |
210 assert(obj->is_method(), "should be method"); | |
211 | |
212 oop* p; | |
213 methodOop m = methodOop(obj); | |
214 | |
215 p = m->adr_constMethod(); | |
216 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
217 p = m->adr_constants(); | |
218 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
219 | |
220 #ifdef COMPILER2 | |
221 if (m->method_data() != NULL) { | |
222 p = m->adr_method_data(); | |
223 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
224 } | |
225 #endif // COMPILER2 | |
226 return m->object_size(); | |
227 } | |
228 #endif // SERIALGC | |
229 | |
230 #ifndef PRODUCT | |
231 | |
232 // Printing | |
233 | |
234 void methodKlass::oop_print_on(oop obj, outputStream* st) { | |
235 ResourceMark rm; | |
236 assert(obj->is_method(), "must be method"); | |
237 Klass::oop_print_on(obj, st); | |
238 methodOop m = methodOop(obj); | |
239 st->print (" - method holder: "); m->method_holder()->print_value_on(st); st->cr(); | |
240 st->print (" - constants: " INTPTR_FORMAT, " ", (address)m->constants()); | |
241 m->constants()->print_value_on(st); st->cr(); | |
242 st->print (" - access: 0x%x ", m->access_flags().as_int()); m->access_flags().print_on(st); st->cr(); | |
243 st->print (" - name: "); m->name()->print_value_on(st); st->cr(); | |
244 st->print (" - signature: "); m->signature()->print_value_on(st); st->cr(); | |
245 st->print_cr(" - max stack: %d", m->max_stack()); | |
246 st->print_cr(" - max locals: %d", m->max_locals()); | |
247 st->print_cr(" - size of params: %d", m->size_of_parameters()); | |
248 st->print_cr(" - method size: %d", m->method_size()); | |
249 st->print_cr(" - vtable index: %d", m->_vtable_index); | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
250 st->print_cr(" - i2i entry: " INTPTR_FORMAT, m->interpreter_entry()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
251 st->print_cr(" - adapter: " INTPTR_FORMAT, m->adapter()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
252 st->print_cr(" - compiled entry " INTPTR_FORMAT, m->from_compiled_entry()); |
0 | 253 st->print_cr(" - code size: %d", m->code_size()); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
254 if (m->code_size() != 0) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
255 st->print_cr(" - code start: " INTPTR_FORMAT, m->code_base()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
256 st->print_cr(" - code end (excl): " INTPTR_FORMAT, m->code_base() + m->code_size()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
257 } |
0 | 258 if (m->method_data() != NULL) { |
259 st->print_cr(" - method data: " INTPTR_FORMAT, (address)m->method_data()); | |
260 } | |
261 st->print_cr(" - checked ex length: %d", m->checked_exceptions_length()); | |
262 if (m->checked_exceptions_length() > 0) { | |
263 CheckedExceptionElement* table = m->checked_exceptions_start(); | |
264 st->print_cr(" - checked ex start: " INTPTR_FORMAT, table); | |
265 if (Verbose) { | |
266 for (int i = 0; i < m->checked_exceptions_length(); i++) { | |
267 st->print_cr(" - throws %s", m->constants()->printable_name_at(table[i].class_cp_index)); | |
268 } | |
269 } | |
270 } | |
271 if (m->has_linenumber_table()) { | |
272 u_char* table = m->compressed_linenumber_table(); | |
273 st->print_cr(" - linenumber start: " INTPTR_FORMAT, table); | |
274 if (Verbose) { | |
275 CompressedLineNumberReadStream stream(table); | |
276 while (stream.read_pair()) { | |
277 st->print_cr(" - line %d: %d", stream.line(), stream.bci()); | |
278 } | |
279 } | |
280 } | |
281 st->print_cr(" - localvar length: %d", m->localvariable_table_length()); | |
282 if (m->localvariable_table_length() > 0) { | |
283 LocalVariableTableElement* table = m->localvariable_table_start(); | |
284 st->print_cr(" - localvar start: " INTPTR_FORMAT, table); | |
285 if (Verbose) { | |
286 for (int i = 0; i < m->localvariable_table_length(); i++) { | |
287 int bci = table[i].start_bci; | |
288 int len = table[i].length; | |
289 const char* name = m->constants()->printable_name_at(table[i].name_cp_index); | |
290 const char* desc = m->constants()->printable_name_at(table[i].descriptor_cp_index); | |
291 int slot = table[i].slot; | |
292 st->print_cr(" - %s %s bci=%d len=%d slot=%d", desc, name, bci, len, slot); | |
293 } | |
294 } | |
295 } | |
296 if (m->code() != NULL) { | |
297 st->print (" - compiled code: "); | |
298 m->code()->print_value_on(st); | |
299 st->cr(); | |
300 } | |
710 | 301 if (m->is_method_handle_invoke()) { |
302 st->print_cr(" - invoke method type: " INTPTR_FORMAT, (address) m->method_handle_type()); | |
303 // m is classified as native, but it does not have an interesting | |
304 // native_function or signature handler | |
305 } else if (m->is_native()) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
306 st->print_cr(" - native function: " INTPTR_FORMAT, m->native_function()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
307 st->print_cr(" - signature handler: " INTPTR_FORMAT, m->signature_handler()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
0
diff
changeset
|
308 } |
0 | 309 } |
310 | |
311 | |
312 void methodKlass::oop_print_value_on(oop obj, outputStream* st) { | |
313 assert(obj->is_method(), "must be method"); | |
314 Klass::oop_print_value_on(obj, st); | |
315 methodOop m = methodOop(obj); | |
316 st->print(" "); | |
317 m->name()->print_value_on(st); | |
318 st->print(" "); | |
319 m->signature()->print_value_on(st); | |
320 st->print(" in "); | |
321 m->method_holder()->print_value_on(st); | |
322 if (WizardMode) st->print("[%d,%d]", m->size_of_parameters(), m->max_locals()); | |
323 if (WizardMode && m->code() != NULL) st->print(" ((nmethod*)%p)", m->code()); | |
324 } | |
325 | |
326 #endif // PRODUCT | |
327 | |
328 const char* methodKlass::internal_name() const { | |
329 return "{method}"; | |
330 } | |
331 | |
332 | |
333 // Verification | |
334 | |
335 void methodKlass::oop_verify_on(oop obj, outputStream* st) { | |
336 Klass::oop_verify_on(obj, st); | |
337 guarantee(obj->is_method(), "object must be method"); | |
338 if (!obj->partially_loaded()) { | |
339 methodOop m = methodOop(obj); | |
340 guarantee(m->is_perm(), "should be in permspace"); | |
341 guarantee(m->name()->is_perm(), "should be in permspace"); | |
342 guarantee(m->name()->is_symbol(), "should be symbol"); | |
343 guarantee(m->signature()->is_perm(), "should be in permspace"); | |
344 guarantee(m->signature()->is_symbol(), "should be symbol"); | |
345 guarantee(m->constants()->is_perm(), "should be in permspace"); | |
346 guarantee(m->constants()->is_constantPool(), "should be constant pool"); | |
347 guarantee(m->constMethod()->is_constMethod(), "should be constMethodOop"); | |
348 guarantee(m->constMethod()->is_perm(), "should be in permspace"); | |
349 methodDataOop method_data = m->method_data(); | |
350 guarantee(method_data == NULL || | |
351 method_data->is_perm(), "should be in permspace"); | |
352 guarantee(method_data == NULL || | |
353 method_data->is_methodData(), "should be method data"); | |
354 } | |
355 } | |
356 | |
357 bool methodKlass::oop_partially_loaded(oop obj) const { | |
358 assert(obj->is_method(), "object must be method"); | |
359 methodOop m = methodOop(obj); | |
360 constMethodOop xconst = m->constMethod(); | |
361 assert(xconst != NULL, "const method must be set"); | |
362 constMethodKlass* ck = constMethodKlass::cast(xconst->klass()); | |
363 return ck->oop_partially_loaded(xconst); | |
364 } | |
365 | |
366 | |
367 void methodKlass::oop_set_partially_loaded(oop obj) { | |
368 assert(obj->is_method(), "object must be method"); | |
369 methodOop m = methodOop(obj); | |
370 constMethodOop xconst = m->constMethod(); | |
371 assert(xconst != NULL, "const method must be set"); | |
372 constMethodKlass* ck = constMethodKlass::cast(xconst->klass()); | |
373 ck->oop_set_partially_loaded(xconst); | |
374 } |