src/share/vm/oops/constMethodKlass.cpp

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 953
0af8b0718fc9
child 1590
4e6abf09f540
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

duke@435 1 /*
xdono@1014 2 * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_constMethodKlass.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 klassOop constMethodKlass::create_klass(TRAPS) {
duke@435 30 constMethodKlass o;
duke@435 31 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
duke@435 32 KlassHandle k = base_create_klass(h_this_klass, header_size(),
duke@435 33 o.vtbl_value(), CHECK_NULL);
duke@435 34 // Make sure size calculation is right
duke@435 35 assert(k()->size() == align_object_size(header_size()),
duke@435 36 "wrong size for object");
duke@435 37 //java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
duke@435 38 return k();
duke@435 39 }
duke@435 40
duke@435 41
duke@435 42 int constMethodKlass::oop_size(oop obj) const {
duke@435 43 assert(obj->is_constMethod(), "must be constMethod oop");
duke@435 44 return constMethodOop(obj)->object_size();
duke@435 45 }
duke@435 46
duke@435 47 bool constMethodKlass::oop_is_parsable(oop obj) const {
duke@435 48 assert(obj->is_constMethod(), "must be constMethod oop");
duke@435 49 return constMethodOop(obj)->object_is_parsable();
duke@435 50 }
duke@435 51
jmasa@953 52 bool constMethodKlass::oop_is_conc_safe(oop obj) const {
jmasa@953 53 assert(obj->is_constMethod(), "must be constMethod oop");
jmasa@953 54 return constMethodOop(obj)->is_conc_safe();
jmasa@953 55 }
jmasa@953 56
duke@435 57 constMethodOop constMethodKlass::allocate(int byte_code_size,
duke@435 58 int compressed_line_number_size,
duke@435 59 int localvariable_table_length,
duke@435 60 int checked_exceptions_length,
jmasa@953 61 bool is_conc_safe,
duke@435 62 TRAPS) {
duke@435 63
duke@435 64 int size = constMethodOopDesc::object_size(byte_code_size,
duke@435 65 compressed_line_number_size,
duke@435 66 localvariable_table_length,
duke@435 67 checked_exceptions_length);
duke@435 68 KlassHandle h_k(THREAD, as_klassOop());
duke@435 69 constMethodOop cm = (constMethodOop)
duke@435 70 CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
duke@435 71 assert(!cm->is_parsable(), "Not yet safely parsable");
duke@435 72 No_Safepoint_Verifier no_safepoint;
duke@435 73 cm->set_interpreter_kind(Interpreter::invalid);
duke@435 74 cm->init_fingerprint();
duke@435 75 cm->set_method(NULL);
duke@435 76 cm->set_stackmap_data(NULL);
duke@435 77 cm->set_exception_table(NULL);
duke@435 78 cm->set_code_size(byte_code_size);
duke@435 79 cm->set_constMethod_size(size);
duke@435 80 cm->set_inlined_tables_length(checked_exceptions_length,
duke@435 81 compressed_line_number_size,
duke@435 82 localvariable_table_length);
duke@435 83 assert(cm->size() == size, "wrong size for object");
jmasa@953 84 cm->set_is_conc_safe(is_conc_safe);
duke@435 85 cm->set_partially_loaded();
duke@435 86 assert(cm->is_parsable(), "Is safely parsable by gc");
duke@435 87 return cm;
duke@435 88 }
duke@435 89
duke@435 90 void constMethodKlass::oop_follow_contents(oop obj) {
duke@435 91 assert (obj->is_constMethod(), "object must be constMethod");
duke@435 92 constMethodOop cm = constMethodOop(obj);
duke@435 93 MarkSweep::mark_and_push(cm->adr_method());
duke@435 94 MarkSweep::mark_and_push(cm->adr_stackmap_data());
duke@435 95 MarkSweep::mark_and_push(cm->adr_exception_table());
duke@435 96 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 97 // know that Universe::constMethodKlassObj never moves.
duke@435 98 }
duke@435 99
duke@435 100 #ifndef SERIALGC
duke@435 101 void constMethodKlass::oop_follow_contents(ParCompactionManager* cm,
duke@435 102 oop obj) {
duke@435 103 assert (obj->is_constMethod(), "object must be constMethod");
duke@435 104 constMethodOop cm_oop = constMethodOop(obj);
duke@435 105 PSParallelCompact::mark_and_push(cm, cm_oop->adr_method());
duke@435 106 PSParallelCompact::mark_and_push(cm, cm_oop->adr_stackmap_data());
duke@435 107 PSParallelCompact::mark_and_push(cm, cm_oop->adr_exception_table());
duke@435 108 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 109 // know that Universe::constMethodKlassObj never moves.
duke@435 110 }
duke@435 111 #endif // SERIALGC
duke@435 112
duke@435 113 int constMethodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
duke@435 114 assert (obj->is_constMethod(), "object must be constMethod");
duke@435 115 constMethodOop cm = constMethodOop(obj);
duke@435 116 blk->do_oop(cm->adr_method());
duke@435 117 blk->do_oop(cm->adr_stackmap_data());
duke@435 118 blk->do_oop(cm->adr_exception_table());
duke@435 119 // Get size before changing pointers.
duke@435 120 // Don't call size() or oop_size() since that is a virtual call.
duke@435 121 int size = cm->object_size();
duke@435 122 return size;
duke@435 123 }
duke@435 124
duke@435 125
duke@435 126 int constMethodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
duke@435 127 assert (obj->is_constMethod(), "object must be constMethod");
duke@435 128 constMethodOop cm = constMethodOop(obj);
duke@435 129 oop* adr;
duke@435 130 adr = cm->adr_method();
duke@435 131 if (mr.contains(adr)) blk->do_oop(adr);
duke@435 132 adr = cm->adr_stackmap_data();
duke@435 133 if (mr.contains(adr)) blk->do_oop(adr);
duke@435 134 adr = cm->adr_exception_table();
duke@435 135 if (mr.contains(adr)) blk->do_oop(adr);
duke@435 136 // Get size before changing pointers.
duke@435 137 // Don't call size() or oop_size() since that is a virtual call.
duke@435 138 int size = cm->object_size();
duke@435 139 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 140 // know that Universe::constMethodKlassObj never moves.
duke@435 141 return size;
duke@435 142 }
duke@435 143
duke@435 144
duke@435 145 int constMethodKlass::oop_adjust_pointers(oop obj) {
duke@435 146 assert(obj->is_constMethod(), "should be constMethod");
duke@435 147 constMethodOop cm = constMethodOop(obj);
duke@435 148 MarkSweep::adjust_pointer(cm->adr_method());
duke@435 149 MarkSweep::adjust_pointer(cm->adr_stackmap_data());
duke@435 150 MarkSweep::adjust_pointer(cm->adr_exception_table());
duke@435 151 // Get size before changing pointers.
duke@435 152 // Don't call size() or oop_size() since that is a virtual call.
duke@435 153 int size = cm->object_size();
duke@435 154 // Performance tweak: We skip iterating over the klass pointer since we
duke@435 155 // know that Universe::constMethodKlassObj never moves.
duke@435 156 return size;
duke@435 157 }
duke@435 158
duke@435 159 #ifndef SERIALGC
duke@435 160 void constMethodKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
duke@435 161 assert(obj->is_constMethod(), "should be constMethod");
duke@435 162 }
duke@435 163
duke@435 164 void constMethodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
duke@435 165 assert(obj->is_constMethod(), "should be constMethod");
duke@435 166 }
duke@435 167
duke@435 168 int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
duke@435 169 assert(obj->is_constMethod(), "should be constMethod");
duke@435 170 constMethodOop cm_oop = constMethodOop(obj);
duke@435 171 #if 0
duke@435 172 PSParallelCompact::adjust_pointer(cm_oop->adr_method());
duke@435 173 PSParallelCompact::adjust_pointer(cm_oop->adr_exception_table());
duke@435 174 PSParallelCompact::adjust_pointer(cm_oop->adr_stackmap_data());
duke@435 175 #endif
duke@435 176 oop* const beg_oop = cm_oop->oop_block_beg();
duke@435 177 oop* const end_oop = cm_oop->oop_block_end();
duke@435 178 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
duke@435 179 PSParallelCompact::adjust_pointer(cur_oop);
duke@435 180 }
duke@435 181 return cm_oop->object_size();
duke@435 182 }
duke@435 183
duke@435 184 int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
duke@435 185 HeapWord* beg_addr,
duke@435 186 HeapWord* end_addr) {
duke@435 187 assert(obj->is_constMethod(), "should be constMethod");
duke@435 188 constMethodOop cm_oop = constMethodOop(obj);
duke@435 189
duke@435 190 oop* const beg_oop = MAX2((oop*)beg_addr, cm_oop->oop_block_beg());
duke@435 191 oop* const end_oop = MIN2((oop*)end_addr, cm_oop->oop_block_end());
duke@435 192 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
duke@435 193 PSParallelCompact::adjust_pointer(cur_oop);
duke@435 194 }
duke@435 195
duke@435 196 return cm_oop->object_size();
duke@435 197 }
duke@435 198 #endif // SERIALGC
duke@435 199
duke@435 200 #ifndef PRODUCT
duke@435 201
duke@435 202 // Printing
duke@435 203
duke@435 204 void constMethodKlass::oop_print_on(oop obj, outputStream* st) {
duke@435 205 ResourceMark rm;
duke@435 206 assert(obj->is_constMethod(), "must be constMethod");
duke@435 207 Klass::oop_print_on(obj, st);
duke@435 208 constMethodOop m = constMethodOop(obj);
duke@435 209 st->print(" - method: " INTPTR_FORMAT " ", (address)m->method());
duke@435 210 m->method()->print_value_on(st); st->cr();
duke@435 211 st->print(" - exceptions: " INTPTR_FORMAT "\n", (address)m->exception_table());
duke@435 212 if (m->has_stackmap_table()) {
duke@435 213 st->print(" - stackmap data: ");
duke@435 214 m->stackmap_data()->print_value_on(st);
duke@435 215 st->cr();
duke@435 216 }
duke@435 217 }
duke@435 218
duke@435 219
duke@435 220 // Short version of printing constMethodOop - just print the name of the
duke@435 221 // method it belongs to.
duke@435 222 void constMethodKlass::oop_print_value_on(oop obj, outputStream* st) {
duke@435 223 assert(obj->is_constMethod(), "must be constMethod");
duke@435 224 constMethodOop m = constMethodOop(obj);
duke@435 225 st->print(" const part of method " );
duke@435 226 m->method()->print_value_on(st);
duke@435 227 }
duke@435 228
duke@435 229 #endif // PRODUCT
duke@435 230
duke@435 231 const char* constMethodKlass::internal_name() const {
duke@435 232 return "{constMethod}";
duke@435 233 }
duke@435 234
duke@435 235
duke@435 236 // Verification
duke@435 237
duke@435 238 void constMethodKlass::oop_verify_on(oop obj, outputStream* st) {
duke@435 239 Klass::oop_verify_on(obj, st);
duke@435 240 guarantee(obj->is_constMethod(), "object must be constMethod");
duke@435 241 constMethodOop m = constMethodOop(obj);
duke@435 242 guarantee(m->is_perm(), "should be in permspace");
duke@435 243
duke@435 244 // Verification can occur during oop construction before the method or
duke@435 245 // other fields have been initialized.
duke@435 246 if (!obj->partially_loaded()) {
duke@435 247 guarantee(m->method()->is_perm(), "should be in permspace");
duke@435 248 guarantee(m->method()->is_method(), "should be method");
duke@435 249 typeArrayOop stackmap_data = m->stackmap_data();
duke@435 250 guarantee(stackmap_data == NULL ||
duke@435 251 stackmap_data->is_perm(), "should be in permspace");
duke@435 252 guarantee(m->exception_table()->is_perm(), "should be in permspace");
duke@435 253 guarantee(m->exception_table()->is_typeArray(), "should be type array");
duke@435 254
duke@435 255 address m_end = (address)((oop*) m + m->size());
duke@435 256 address compressed_table_start = m->code_end();
duke@435 257 guarantee(compressed_table_start <= m_end, "invalid method layout");
duke@435 258 address compressed_table_end = compressed_table_start;
duke@435 259 // Verify line number table
duke@435 260 if (m->has_linenumber_table()) {
duke@435 261 CompressedLineNumberReadStream stream(m->compressed_linenumber_table());
duke@435 262 while (stream.read_pair()) {
duke@435 263 guarantee(stream.bci() >= 0 && stream.bci() <= m->code_size(), "invalid bci in line number table");
duke@435 264 }
duke@435 265 compressed_table_end += stream.position();
duke@435 266 }
duke@435 267 guarantee(compressed_table_end <= m_end, "invalid method layout");
duke@435 268 // Verify checked exceptions and local variable tables
duke@435 269 if (m->has_checked_exceptions()) {
duke@435 270 u2* addr = m->checked_exceptions_length_addr();
duke@435 271 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
duke@435 272 }
duke@435 273 if (m->has_localvariable_table()) {
duke@435 274 u2* addr = m->localvariable_table_length_addr();
duke@435 275 guarantee(*addr > 0 && (address) addr >= compressed_table_end && (address) addr < m_end, "invalid method layout");
duke@435 276 }
duke@435 277 // Check compressed_table_end relative to uncompressed_table_start
duke@435 278 u2* uncompressed_table_start;
duke@435 279 if (m->has_localvariable_table()) {
duke@435 280 uncompressed_table_start = (u2*) m->localvariable_table_start();
duke@435 281 } else {
duke@435 282 if (m->has_checked_exceptions()) {
duke@435 283 uncompressed_table_start = (u2*) m->checked_exceptions_start();
duke@435 284 } else {
duke@435 285 uncompressed_table_start = (u2*) m_end;
duke@435 286 }
duke@435 287 }
duke@435 288 int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
duke@435 289 int max_gap = align_object_size(1)*BytesPerWord;
duke@435 290 guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
duke@435 291 }
duke@435 292 }
duke@435 293
duke@435 294 bool constMethodKlass::oop_partially_loaded(oop obj) const {
duke@435 295 assert(obj->is_constMethod(), "object must be klass");
duke@435 296 constMethodOop m = constMethodOop(obj);
duke@435 297 // check whether exception_table points to self (flag for partially loaded)
duke@435 298 return m->exception_table() == (typeArrayOop)obj;
duke@435 299 }
duke@435 300
duke@435 301
duke@435 302 // The exception_table is the last field set when loading an object.
duke@435 303 void constMethodKlass::oop_set_partially_loaded(oop obj) {
duke@435 304 assert(obj->is_constMethod(), "object must be klass");
duke@435 305 constMethodOop m = constMethodOop(obj);
duke@435 306 // Temporarily set exception_table to point to self
duke@435 307 m->set_exception_table((typeArrayOop)obj);
duke@435 308 }

mercurial