src/share/vm/oops/methodKlass.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  95 
  96   if (access_flags.is_native()) {
  97     m->clear_native_function();
  98     m->set_signature_handler(NULL);
  99   }
 100 
 101   NOT_PRODUCT(m->set_compiled_invocation_count(0);)
 102   m->set_interpreter_invocation_count(0);
 103   m->invocation_counter()->init();
 104   m->backedge_counter()->init();
 105   m->clear_number_of_breakpoints();
 106 
 107 #ifdef TIERED
 108   m->set_rate(0);
 109   m->set_prev_event_count(0);
 110   m->set_prev_time(0);
 111 #endif
 112 
 113   assert(m->is_parsable(), "must be parsable here.");
 114   assert(m->size() == size, "wrong size for object");
 115   // We should not publish an uprasable object's reference
 116   // into one that is parsable, since that presents problems
 117   // for the concurrent parallel marking and precleaning phases
 118   // of concurrent gc (CMS).
 119   xconst->set_method(m);
 120   return m;
 121 }
 122 
 123 
 124 void methodKlass::oop_follow_contents(oop obj) {
 125   assert (obj->is_method(), "object must be method");
 126   methodOop m = methodOop(obj);
 127   // Performance tweak: We skip iterating over the klass pointer since we
 128   // know that Universe::methodKlassObj never moves.
 129   MarkSweep::mark_and_push(m->adr_constMethod());
 130   MarkSweep::mark_and_push(m->adr_constants());
 131   if (m->method_data() != NULL) {
 132     MarkSweep::mark_and_push(m->adr_method_data());
 133   }
 134 }
 135 
 136 #ifndef SERIALGC
 137 void methodKlass::oop_follow_contents(ParCompactionManager* cm,
 138                                       oop obj) {
 139   assert (obj->is_method(), "object must be method");
 140   methodOop m = methodOop(obj);
 141   // Performance tweak: We skip iterating over the klass pointer since we
 142   // know that Universe::methodKlassObj never moves.
 143   PSParallelCompact::mark_and_push(cm, m->adr_constMethod());
 144   PSParallelCompact::mark_and_push(cm, m->adr_constants());
 145 #ifdef COMPILER2
 146   if (m->method_data() != NULL) {
 147     PSParallelCompact::mark_and_push(cm, m->adr_method_data());
 148   }
 149 #endif // COMPILER2
 150 }
 151 #endif // SERIALGC
 152 
 153 int methodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
 154   assert (obj->is_method(), "object must be method");
 155   methodOop m = methodOop(obj);
 156   // Get size before changing pointers.
 157   // Don't call size() or oop_size() since that is a virtual call.
 158   int size = m->object_size();
 159   // Performance tweak: We skip iterating over the klass pointer since we
 160   // know that Universe::methodKlassObj never moves
 161   blk->do_oop(m->adr_constMethod());
 162   blk->do_oop(m->adr_constants());
 163   if (m->method_data() != NULL) {
 164     blk->do_oop(m->adr_method_data());
 165   }
 166   return size;
 167 }
 168 
 169 
 170 int methodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
 171   assert (obj->is_method(), "object must 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   oop* adr;
 179   adr = m->adr_constMethod();
 180   if (mr.contains(adr)) blk->do_oop(adr);
 181   adr = m->adr_constants();
 182   if (mr.contains(adr)) blk->do_oop(adr);
 183   if (m->method_data() != NULL) {
 184     adr = m->adr_method_data();
 185     if (mr.contains(adr)) blk->do_oop(adr);
 186   }
 187   return size;
 188 }
 189 
 190 
 191 int methodKlass::oop_adjust_pointers(oop obj) {
 192   assert(obj->is_method(), "should be method");
 193   methodOop m = methodOop(obj);
 194   // Get size before changing pointers.
 195   // Don't call size() or oop_size() since that is a virtual call.
 196   int size = m->object_size();
 197   // Performance tweak: We skip iterating over the klass pointer since we
 198   // know that Universe::methodKlassObj never moves.
 199   MarkSweep::adjust_pointer(m->adr_constMethod());
 200   MarkSweep::adjust_pointer(m->adr_constants());
 201   if (m->method_data() != NULL) {
 202     MarkSweep::adjust_pointer(m->adr_method_data());
 203   }
 204   return size;
 205 }
 206 
 207 #ifndef SERIALGC
 208 void methodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
 209   assert(obj->is_method(), "should be method");
 210 }
 211 
 212 int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
 213   assert(obj->is_method(), "should be method");
 214   methodOop m = methodOop(obj);
 215   PSParallelCompact::adjust_pointer(m->adr_constMethod());
 216   PSParallelCompact::adjust_pointer(m->adr_constants());
 217 #ifdef COMPILER2
 218   if (m->method_data() != NULL) {
 219     PSParallelCompact::adjust_pointer(m->adr_method_data());
 220   }
 221 #endif // COMPILER2
 222   return m->object_size();
 223 }
 224 #endif // SERIALGC
 225 
 226 #ifndef PRODUCT
 227 
 228 // Printing
 229 
 230 void methodKlass::oop_print_on(oop obj, outputStream* st) {
 231   ResourceMark rm;
 232   assert(obj->is_method(), "must be method");
 233   Klass::oop_print_on(obj, st);
 234   methodOop m = methodOop(obj);
 235   // get the effect of PrintOopAddress, always, for methods:
 236   st->print_cr(" - this oop:          "INTPTR_FORMAT, (intptr_t)m);


 322   m->signature()->print_value_on(st);
 323   st->print(" in ");
 324   m->method_holder()->print_value_on(st);
 325   if (WizardMode) st->print("[%d,%d]", m->size_of_parameters(), m->max_locals());
 326   if (WizardMode && m->code() != NULL) st->print(" ((nmethod*)%p)", m->code());
 327 }
 328 
 329 const char* methodKlass::internal_name() const {
 330   return "{method}";
 331 }
 332 
 333 
 334 // Verification
 335 
 336 void methodKlass::oop_verify_on(oop obj, outputStream* st) {
 337   Klass::oop_verify_on(obj, st);
 338   guarantee(obj->is_method(), "object must be method");
 339   if (!obj->partially_loaded()) {
 340     methodOop m = methodOop(obj);
 341     guarantee(m->is_perm(),  "should be in permspace");
 342     guarantee(m->constants()->is_perm(), "should be in permspace");
 343     guarantee(m->constants()->is_constantPool(), "should be constant pool");
 344     guarantee(m->constMethod()->is_constMethod(), "should be constMethodOop");
 345     guarantee(m->constMethod()->is_perm(), "should be in permspace");
 346     methodDataOop method_data = m->method_data();
 347     guarantee(method_data == NULL ||
 348               method_data->is_perm(), "should be in permspace");
 349     guarantee(method_data == NULL ||
 350               method_data->is_methodData(), "should be method data");
 351   }
 352 }
 353 
 354 bool methodKlass::oop_partially_loaded(oop obj) const {
 355   assert(obj->is_method(), "object must be method");
 356   methodOop m = methodOop(obj);
 357   constMethodOop xconst = m->constMethod();
 358   assert(xconst != NULL, "const method must be set");
 359   constMethodKlass* ck = constMethodKlass::cast(xconst->klass());
 360   return ck->oop_partially_loaded(xconst);
 361 }
 362 
 363 
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  95 
  96   if (access_flags.is_native()) {
  97     m->clear_native_function();
  98     m->set_signature_handler(NULL);
  99   }
 100 
 101   NOT_PRODUCT(m->set_compiled_invocation_count(0);)
 102   m->set_interpreter_invocation_count(0);
 103   m->invocation_counter()->init();
 104   m->backedge_counter()->init();
 105   m->clear_number_of_breakpoints();
 106 
 107 #ifdef TIERED
 108   m->set_rate(0);
 109   m->set_prev_event_count(0);
 110   m->set_prev_time(0);
 111 #endif
 112 
 113   assert(m->is_parsable(), "must be parsable here.");
 114   assert(m->size() == size, "wrong size for object");





 115   return m;
 116 }
 117 
 118 
 119 void methodKlass::oop_follow_contents(oop obj) {
 120   assert (obj->is_method(), "object must be method");
 121   methodOop m = methodOop(obj);
 122   // Performance tweak: We skip iterating over the klass pointer since we
 123   // know that Universe::methodKlassObj never moves.
 124   MarkSweep::mark_and_push(m->adr_constMethod());

 125   if (m->method_data() != NULL) {
 126     MarkSweep::mark_and_push(m->adr_method_data());
 127   }
 128 }
 129 
 130 #ifndef SERIALGC
 131 void methodKlass::oop_follow_contents(ParCompactionManager* cm,
 132                                       oop obj) {
 133   assert (obj->is_method(), "object must be method");
 134   methodOop m = methodOop(obj);
 135   // Performance tweak: We skip iterating over the klass pointer since we
 136   // know that Universe::methodKlassObj never moves.
 137   PSParallelCompact::mark_and_push(cm, m->adr_constMethod());

 138 #ifdef COMPILER2
 139   if (m->method_data() != NULL) {
 140     PSParallelCompact::mark_and_push(cm, m->adr_method_data());
 141   }
 142 #endif // COMPILER2
 143 }
 144 #endif // SERIALGC
 145 
 146 int methodKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
 147   assert (obj->is_method(), "object must be method");
 148   methodOop m = methodOop(obj);
 149   // Get size before changing pointers.
 150   // Don't call size() or oop_size() since that is a virtual call.
 151   int size = m->object_size();
 152   // Performance tweak: We skip iterating over the klass pointer since we
 153   // know that Universe::methodKlassObj never moves
 154   blk->do_oop(m->adr_constMethod());

 155   if (m->method_data() != NULL) {
 156     blk->do_oop(m->adr_method_data());
 157   }
 158   return size;
 159 }
 160 
 161 
 162 int methodKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
 163   assert (obj->is_method(), "object must be method");
 164   methodOop m = methodOop(obj);
 165   // Get size before changing pointers.
 166   // Don't call size() or oop_size() since that is a virtual call.
 167   int size = m->object_size();
 168   // Performance tweak: We skip iterating over the klass pointer since we
 169   // know that Universe::methodKlassObj never moves.
 170   oop* adr;
 171   adr = m->adr_constMethod();
 172   if (mr.contains(adr)) blk->do_oop(adr);


 173   if (m->method_data() != NULL) {
 174     adr = m->adr_method_data();
 175     if (mr.contains(adr)) blk->do_oop(adr);
 176   }
 177   return size;
 178 }
 179 
 180 
 181 int methodKlass::oop_adjust_pointers(oop obj) {
 182   assert(obj->is_method(), "should be method");
 183   methodOop m = methodOop(obj);
 184   // Get size before changing pointers.
 185   // Don't call size() or oop_size() since that is a virtual call.
 186   int size = m->object_size();
 187   // Performance tweak: We skip iterating over the klass pointer since we
 188   // know that Universe::methodKlassObj never moves.
 189   MarkSweep::adjust_pointer(m->adr_constMethod());

 190   if (m->method_data() != NULL) {
 191     MarkSweep::adjust_pointer(m->adr_method_data());
 192   }
 193   return size;
 194 }
 195 
 196 #ifndef SERIALGC
 197 void methodKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
 198   assert(obj->is_method(), "should be method");
 199 }
 200 
 201 int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
 202   assert(obj->is_method(), "should be method");
 203   methodOop m = methodOop(obj);
 204   PSParallelCompact::adjust_pointer(m->adr_constMethod());

 205 #ifdef COMPILER2
 206   if (m->method_data() != NULL) {
 207     PSParallelCompact::adjust_pointer(m->adr_method_data());
 208   }
 209 #endif // COMPILER2
 210   return m->object_size();
 211 }
 212 #endif // SERIALGC
 213 
 214 #ifndef PRODUCT
 215 
 216 // Printing
 217 
 218 void methodKlass::oop_print_on(oop obj, outputStream* st) {
 219   ResourceMark rm;
 220   assert(obj->is_method(), "must be method");
 221   Klass::oop_print_on(obj, st);
 222   methodOop m = methodOop(obj);
 223   // get the effect of PrintOopAddress, always, for methods:
 224   st->print_cr(" - this oop:          "INTPTR_FORMAT, (intptr_t)m);


 310   m->signature()->print_value_on(st);
 311   st->print(" in ");
 312   m->method_holder()->print_value_on(st);
 313   if (WizardMode) st->print("[%d,%d]", m->size_of_parameters(), m->max_locals());
 314   if (WizardMode && m->code() != NULL) st->print(" ((nmethod*)%p)", m->code());
 315 }
 316 
 317 const char* methodKlass::internal_name() const {
 318   return "{method}";
 319 }
 320 
 321 
 322 // Verification
 323 
 324 void methodKlass::oop_verify_on(oop obj, outputStream* st) {
 325   Klass::oop_verify_on(obj, st);
 326   guarantee(obj->is_method(), "object must be method");
 327   if (!obj->partially_loaded()) {
 328     methodOop m = methodOop(obj);
 329     guarantee(m->is_perm(),  "should be in permspace");


 330     guarantee(m->constMethod()->is_constMethod(), "should be constMethodOop");
 331     guarantee(m->constMethod()->is_perm(), "should be in permspace");
 332     methodDataOop method_data = m->method_data();
 333     guarantee(method_data == NULL ||
 334               method_data->is_perm(), "should be in permspace");
 335     guarantee(method_data == NULL ||
 336               method_data->is_methodData(), "should be method data");
 337   }
 338 }
 339 
 340 bool methodKlass::oop_partially_loaded(oop obj) const {
 341   assert(obj->is_method(), "object must be method");
 342   methodOop m = methodOop(obj);
 343   constMethodOop xconst = m->constMethod();
 344   assert(xconst != NULL, "const method must be set");
 345   constMethodKlass* ck = constMethodKlass::cast(xconst->klass());
 346   return ck->oop_partially_loaded(xconst);
 347 }
 348 
 349