annotate src/share/vm/oops/methodKlass.cpp @ 452:00b023ae2d78

6722113: CMS: Incorrect overflow handling during precleaning of Reference lists Summary: When we encounter marking stack overflow during precleaning of Reference lists, we were using the overflow list mechanism, which can cause problems on account of mutating the mark word of the header because of conflicts with mutator accesses and updates of that field. Instead we should use the usual mechanism for overflow handling in concurrent phases, namely dirtying of the card on which the overflowed object lies. Since precleaning effectively does a form of discovered list processing, albeit with discovery enabled, we needed to adjust some code to be correct in the face of interleaved processing and discovery. Reviewed-by: apetrusenko, jcoomes
author ysr
date Thu, 20 Nov 2008 12:27:41 -0800
parents a61af66fc99e
children c89f86385056
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_methodKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 klassOop methodKlass::create_klass(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 methodKlass o;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
31 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Make sure size calculation is right
a61af66fc99e Initial load
duke
parents:
diff changeset
33 assert(k()->size() == align_object_size(header_size()), "wrong size for object");
a61af66fc99e Initial load
duke
parents:
diff changeset
34 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
35 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 }
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 int methodKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 assert(obj->is_method(), "must be method oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
41 return methodOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bool methodKlass::oop_is_parsable(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(obj->is_method(), "must be method oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
47 return methodOop(obj)->object_is_parsable();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 methodOop methodKlass::allocate(constMethodHandle xconst,
a61af66fc99e Initial load
duke
parents:
diff changeset
52 AccessFlags access_flags, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int size = methodOopDesc::object_size(access_flags.is_native());
a61af66fc99e Initial load
duke
parents:
diff changeset
54 KlassHandle h_k(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
55 assert(xconst()->is_parsable(), "possible publication protocol violation");
a61af66fc99e Initial load
duke
parents:
diff changeset
56 methodOop m = (methodOop)CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 assert(!m->is_parsable(), "not expecting parsability yet.");
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 No_Safepoint_Verifier no_safepoint; // until m becomes parsable below
a61af66fc99e Initial load
duke
parents:
diff changeset
60 m->set_constMethod(xconst());
a61af66fc99e Initial load
duke
parents:
diff changeset
61 m->set_access_flags(access_flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 m->set_method_size(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 m->set_name_index(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 m->set_signature_index(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 #ifdef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
66 m->set_result_index(T_VOID);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
68 m->set_constants(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 m->set_max_stack(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 m->set_max_locals(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 m->clear_intrinsic_id_cache();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 m->set_method_data(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 m->set_interpreter_throwout_count(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 m->set_vtable_index(methodOopDesc::garbage_vtable_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Fix and bury in methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
77 m->set_interpreter_entry(NULL); // sets i2i entry and from_int
a61af66fc99e Initial load
duke
parents:
diff changeset
78 m->set_highest_tier_compile(CompLevel_none);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 m->set_adapter_entry(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 m->clear_code(); // from_c/from_i get set to c2i/i2i
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (access_flags.is_native()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 m->clear_native_function();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 m->set_signature_handler(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 NOT_PRODUCT(m->set_compiled_invocation_count(0);)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 m->set_interpreter_invocation_count(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 m->invocation_counter()->init();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 m->backedge_counter()->init();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 m->clear_number_of_breakpoints();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 assert(m->is_parsable(), "must be parsable here.");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(m->size() == size, "wrong size for object");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // We should not publish an uprasable object's reference
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // into one that is parsable, since that presents problems
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // for the concurrent parallel marking and precleaning phases
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // of concurrent gc (CMS).
a61af66fc99e Initial load
duke
parents:
diff changeset
98 xconst->set_method(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void methodKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 assert (obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // know that Universe::methodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 MarkSweep::mark_and_push(m->adr_constMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
109 MarkSweep::mark_and_push(m->adr_constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 MarkSweep::mark_and_push(m->adr_method_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void methodKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
117 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 assert (obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
119 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // know that Universe::methodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 PSParallelCompact::mark_and_push(cm, m->adr_constMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
123 PSParallelCompact::mark_and_push(cm, m->adr_constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 PSParallelCompact::mark_and_push(cm, m->adr_method_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 #endif // COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int methodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 assert (obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
137 int size = m->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // know that Universe::methodKlassObj never moves
a61af66fc99e Initial load
duke
parents:
diff changeset
140 blk->do_oop(m->adr_constMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
141 blk->do_oop(m->adr_constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 blk->do_oop(m->adr_method_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int methodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 assert (obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 int size = m->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // know that Universe::methodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
157 oop* adr;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 adr = m->adr_constMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 adr = m->adr_constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 adr = m->adr_method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int methodKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 assert(obj->is_method(), "should be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
175 int size = m->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // know that Universe::methodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
178 MarkSweep::adjust_pointer(m->adr_constMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
179 MarkSweep::adjust_pointer(m->adr_constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
180 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 MarkSweep::adjust_pointer(m->adr_method_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
187 void methodKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert(obj->is_method(), "should be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 void methodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 assert(obj->is_method(), "should be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert(obj->is_method(), "should be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 PSParallelCompact::adjust_pointer(m->adr_constMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
199 PSParallelCompact::adjust_pointer(m->adr_constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
200 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 PSParallelCompact::adjust_pointer(m->adr_method_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 #endif // COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return m->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
209 HeapWord* beg_addr, HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 assert(obj->is_method(), "should be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 oop* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 p = m->adr_constMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 p = m->adr_constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 p = m->adr_method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
223 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 #endif // COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return m->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 void methodKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 assert(obj->is_method(), "must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 Klass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 st->print (" - method holder: "); m->method_holder()->print_value_on(st); st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 st->print (" - constants: " INTPTR_FORMAT, " ", (address)m->constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
241 m->constants()->print_value_on(st); st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
242 st->print (" - access: 0x%x ", m->access_flags().as_int()); m->access_flags().print_on(st); st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 st->print (" - name: "); m->name()->print_value_on(st); st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
244 st->print (" - signature: "); m->signature()->print_value_on(st); st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
245 st->print_cr(" - max stack: %d", m->max_stack());
a61af66fc99e Initial load
duke
parents:
diff changeset
246 st->print_cr(" - max locals: %d", m->max_locals());
a61af66fc99e Initial load
duke
parents:
diff changeset
247 st->print_cr(" - size of params: %d", m->size_of_parameters());
a61af66fc99e Initial load
duke
parents:
diff changeset
248 st->print_cr(" - method size: %d", m->method_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
249 st->print_cr(" - vtable index: %d", m->_vtable_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 st->print_cr(" - code size: %d", m->code_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
251 st->print_cr(" - code start: " INTPTR_FORMAT, m->code_base());
a61af66fc99e Initial load
duke
parents:
diff changeset
252 st->print_cr(" - code end (excl): " INTPTR_FORMAT, m->code_base() + m->code_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
253 if (m->method_data() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 st->print_cr(" - method data: " INTPTR_FORMAT, (address)m->method_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 st->print_cr(" - checked ex length: %d", m->checked_exceptions_length());
a61af66fc99e Initial load
duke
parents:
diff changeset
257 if (m->checked_exceptions_length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 CheckedExceptionElement* table = m->checked_exceptions_start();
a61af66fc99e Initial load
duke
parents:
diff changeset
259 st->print_cr(" - checked ex start: " INTPTR_FORMAT, table);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 for (int i = 0; i < m->checked_exceptions_length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 st->print_cr(" - throws %s", m->constants()->printable_name_at(table[i].class_cp_index));
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (m->has_linenumber_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 u_char* table = m->compressed_linenumber_table();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 st->print_cr(" - linenumber start: " INTPTR_FORMAT, table);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 CompressedLineNumberReadStream stream(table);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 while (stream.read_pair()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 st->print_cr(" - line %d: %d", stream.line(), stream.bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 st->print_cr(" - localvar length: %d", m->localvariable_table_length());
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if (m->localvariable_table_length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 LocalVariableTableElement* table = m->localvariable_table_start();
a61af66fc99e Initial load
duke
parents:
diff changeset
279 st->print_cr(" - localvar start: " INTPTR_FORMAT, table);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 for (int i = 0; i < m->localvariable_table_length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 int bci = table[i].start_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 int len = table[i].length;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 const char* name = m->constants()->printable_name_at(table[i].name_cp_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 const char* desc = m->constants()->printable_name_at(table[i].descriptor_cp_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 int slot = table[i].slot;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 st->print_cr(" - %s %s bci=%d len=%d slot=%d", desc, name, bci, len, slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if (m->code() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 st->print (" - compiled code: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
293 m->code()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 void methodKlass::oop_print_value_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 assert(obj->is_method(), "must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
301 Klass::oop_print_value_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 st->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 m->name()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 st->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
306 m->signature()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 st->print(" in ");
a61af66fc99e Initial load
duke
parents:
diff changeset
308 m->method_holder()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (WizardMode) st->print("[%d,%d]", m->size_of_parameters(), m->max_locals());
a61af66fc99e Initial load
duke
parents:
diff changeset
310 if (WizardMode && m->code() != NULL) st->print(" ((nmethod*)%p)", m->code());
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 const char* methodKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return "{method}";
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 void methodKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 Klass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
324 guarantee(obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
325 if (!obj->partially_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 guarantee(m->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 guarantee(m->name()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
329 guarantee(m->name()->is_symbol(), "should be symbol");
a61af66fc99e Initial load
duke
parents:
diff changeset
330 guarantee(m->signature()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
331 guarantee(m->signature()->is_symbol(), "should be symbol");
a61af66fc99e Initial load
duke
parents:
diff changeset
332 guarantee(m->constants()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
333 guarantee(m->constants()->is_constantPool(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
334 guarantee(m->constMethod()->is_constMethod(), "should be constMethodOop");
a61af66fc99e Initial load
duke
parents:
diff changeset
335 guarantee(m->constMethod()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
336 methodDataOop method_data = m->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
337 guarantee(method_data == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
338 method_data->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
339 guarantee(method_data == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
340 method_data->is_methodData(), "should be method data");
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342 }
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 bool methodKlass::oop_partially_loaded(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 assert(obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
346 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 constMethodOop xconst = m->constMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
348 assert(xconst != NULL, "const method must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
349 constMethodKlass* ck = constMethodKlass::cast(xconst->klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
350 return ck->oop_partially_loaded(xconst);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 void methodKlass::oop_set_partially_loaded(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 assert(obj->is_method(), "object must be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
356 methodOop m = methodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 constMethodOop xconst = m->constMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
358 assert(xconst != NULL, "const method must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
359 constMethodKlass* ck = constMethodKlass::cast(xconst->klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
360 ck->oop_set_partially_loaded(xconst);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }