annotate src/share/vm/oops/constMethodKlass.cpp @ 579:0fbdb4381b99

6814575: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 03/09 Reviewed-by: katleman, tbell, ohair
author xdono
date Mon, 09 Mar 2009 13:28:46 -0700
parents 0af8b0718fc9
children 4e6abf09f540
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
579
0fbdb4381b99 6814575: Update copyright year
xdono
parents: 518
diff changeset
2 * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
0
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/_constMethodKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 klassOop constMethodKlass::create_klass(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 constMethodKlass o;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
32 KlassHandle k = base_create_klass(h_this_klass, header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
33 o.vtbl_value(), CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // Make sure size calculation is right
a61af66fc99e Initial load
duke
parents:
diff changeset
35 assert(k()->size() == align_object_size(header_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
36 "wrong size for object");
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
38 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 int constMethodKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 assert(obj->is_constMethod(), "must be constMethod oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
44 return constMethodOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 bool constMethodKlass::oop_is_parsable(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 assert(obj->is_constMethod(), "must be constMethod oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
49 return constMethodOop(obj)->object_is_parsable();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
518
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
52 bool constMethodKlass::oop_is_conc_safe(oop obj) const {
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
53 assert(obj->is_constMethod(), "must be constMethod oop");
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
54 return constMethodOop(obj)->is_conc_safe();
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
55 }
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
56
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 constMethodOop constMethodKlass::allocate(int byte_code_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 int localvariable_table_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
60 int checked_exceptions_length,
518
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
61 bool is_conc_safe,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 int size = constMethodOopDesc::object_size(byte_code_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 localvariable_table_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 checked_exceptions_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 KlassHandle h_k(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
69 constMethodOop cm = (constMethodOop)
a61af66fc99e Initial load
duke
parents:
diff changeset
70 CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(!cm->is_parsable(), "Not yet safely parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 No_Safepoint_Verifier no_safepoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 cm->set_interpreter_kind(Interpreter::invalid);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 cm->init_fingerprint();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 cm->set_method(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 cm->set_stackmap_data(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 cm->set_exception_table(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 cm->set_code_size(byte_code_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 cm->set_constMethod_size(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 cm->set_inlined_tables_length(checked_exceptions_length,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 compressed_line_number_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 localvariable_table_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 assert(cm->size() == size, "wrong size for object");
518
0af8b0718fc9 6692899: CMS: many vm.parallel_class_loading tests fail with assert "missing Printezis mark"
jmasa
parents: 0
diff changeset
84 cm->set_is_conc_safe(is_conc_safe);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
85 cm->set_partially_loaded();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert(cm->is_parsable(), "Is safely parsable by gc");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return cm;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 void constMethodKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
92 constMethodOop cm = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 MarkSweep::mark_and_push(cm->adr_method());
a61af66fc99e Initial load
duke
parents:
diff changeset
94 MarkSweep::mark_and_push(cm->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
95 MarkSweep::mark_and_push(cm->adr_exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void constMethodKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 constMethodOop cm_oop = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 PSParallelCompact::mark_and_push(cm, cm_oop->adr_method());
a61af66fc99e Initial load
duke
parents:
diff changeset
106 PSParallelCompact::mark_and_push(cm, cm_oop->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
107 PSParallelCompact::mark_and_push(cm, cm_oop->adr_exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 int constMethodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 constMethodOop cm = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 blk->do_oop(cm->adr_method());
a61af66fc99e Initial load
duke
parents:
diff changeset
117 blk->do_oop(cm->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
118 blk->do_oop(cm->adr_exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int size = cm->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 int constMethodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 assert (obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 constMethodOop cm = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 oop* adr;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 adr = cm->adr_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 adr = cm->adr_stackmap_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 adr = cm->adr_exception_table();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if (mr.contains(adr)) blk->do_oop(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int size = cm->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 int constMethodKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
147 constMethodOop cm = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 MarkSweep::adjust_pointer(cm->adr_method());
a61af66fc99e Initial load
duke
parents:
diff changeset
149 MarkSweep::adjust_pointer(cm->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
150 MarkSweep::adjust_pointer(cm->adr_exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
153 int size = cm->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // know that Universe::constMethodKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void constMethodKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 void constMethodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 constMethodOop cm_oop = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 #if 0
a61af66fc99e Initial load
duke
parents:
diff changeset
172 PSParallelCompact::adjust_pointer(cm_oop->adr_method());
a61af66fc99e Initial load
duke
parents:
diff changeset
173 PSParallelCompact::adjust_pointer(cm_oop->adr_exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
174 PSParallelCompact::adjust_pointer(cm_oop->adr_stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
175 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
176 oop* const beg_oop = cm_oop->oop_block_beg();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 oop* const end_oop = cm_oop->oop_block_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 PSParallelCompact::adjust_pointer(cur_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return cm_oop->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
185 HeapWord* beg_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
186 HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 assert(obj->is_constMethod(), "should be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
188 constMethodOop cm_oop = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 oop* const beg_oop = MAX2((oop*)beg_addr, cm_oop->oop_block_beg());
a61af66fc99e Initial load
duke
parents:
diff changeset
191 oop* const end_oop = MIN2((oop*)end_addr, cm_oop->oop_block_end());
a61af66fc99e Initial load
duke
parents:
diff changeset
192 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 PSParallelCompact::adjust_pointer(cur_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return cm_oop->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 void constMethodKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(obj->is_constMethod(), "must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 Klass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 st->print(" - method: " INTPTR_FORMAT " ", (address)m->method());
a61af66fc99e Initial load
duke
parents:
diff changeset
210 m->method()->print_value_on(st); st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 st->print(" - exceptions: " INTPTR_FORMAT "\n", (address)m->exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (m->has_stackmap_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 st->print(" - stackmap data: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 m->stackmap_data()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // Short version of printing constMethodOop - just print the name of the
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // method it belongs to.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 void constMethodKlass::oop_print_value_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 assert(obj->is_constMethod(), "must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
224 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 st->print(" const part of method " );
a61af66fc99e Initial load
duke
parents:
diff changeset
226 m->method()->print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 const char* constMethodKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return "{constMethod}";
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void constMethodKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 Klass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 guarantee(obj->is_constMethod(), "object must be constMethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
241 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 guarantee(m->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Verification can occur during oop construction before the method or
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // other fields have been initialized.
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if (!obj->partially_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 guarantee(m->method()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
248 guarantee(m->method()->is_method(), "should be method");
a61af66fc99e Initial load
duke
parents:
diff changeset
249 typeArrayOop stackmap_data = m->stackmap_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
250 guarantee(stackmap_data == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
251 stackmap_data->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
252 guarantee(m->exception_table()->is_perm(), "should be in permspace");
a61af66fc99e Initial load
duke
parents:
diff changeset
253 guarantee(m->exception_table()->is_typeArray(), "should be type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 address m_end = (address)((oop*) m + m->size());
a61af66fc99e Initial load
duke
parents:
diff changeset
256 address compressed_table_start = m->code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 guarantee(compressed_table_start <= m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 address compressed_table_end = compressed_table_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Verify line number table
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (m->has_linenumber_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 CompressedLineNumberReadStream stream(m->compressed_linenumber_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
262 while (stream.read_pair()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 guarantee(stream.bci() >= 0 && stream.bci() <= m->code_size(), "invalid bci in line number table");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 compressed_table_end += stream.position();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 guarantee(compressed_table_end <= m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Verify checked exceptions and local variable tables
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (m->has_checked_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 u2* addr = m->checked_exceptions_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if (m->has_localvariable_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 u2* addr = m->localvariable_table_length_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // Check compressed_table_end relative to uncompressed_table_start
a61af66fc99e Initial load
duke
parents:
diff changeset
278 u2* uncompressed_table_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 if (m->has_localvariable_table()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 uncompressed_table_start = (u2*) m->localvariable_table_start();
a61af66fc99e Initial load
duke
parents:
diff changeset
281 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 if (m->has_checked_exceptions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 uncompressed_table_start = (u2*) m->checked_exceptions_start();
a61af66fc99e Initial load
duke
parents:
diff changeset
284 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 uncompressed_table_start = (u2*) m_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 int max_gap = align_object_size(1)*BytesPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 bool constMethodKlass::oop_partially_loaded(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 assert(obj->is_constMethod(), "object must be klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
296 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // check whether exception_table points to self (flag for partially loaded)
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return m->exception_table() == (typeArrayOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // The exception_table is the last field set when loading an object.
a61af66fc99e Initial load
duke
parents:
diff changeset
303 void constMethodKlass::oop_set_partially_loaded(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 assert(obj->is_constMethod(), "object must be klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
305 constMethodOop m = constMethodOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Temporarily set exception_table to point to self
a61af66fc99e Initial load
duke
parents:
diff changeset
307 m->set_exception_table((typeArrayOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }