< prev index next >

src/share/vm/code/compiledMethod.cpp

Print this page


   1 /*
   2  * Copyright (c) 2015, 2016, 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  *


 246         CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
 247         if( cb != NULL && cb->is_compiled() ) {
 248           CompiledMethod* nm = cb->as_compiled_method();
 249           // Clean inline caches pointing to zombie, non-entrant and unloaded methods
 250           if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive());
 251         }
 252         break;
 253       }
 254       case relocInfo::static_call_type: {
 255           CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
 256           CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
 257           if( cb != NULL && cb->is_compiled() ) {
 258             CompiledMethod* cm = cb->as_compiled_method();
 259             // Clean inline caches pointing to zombie, non-entrant and unloaded methods
 260             if (clean_all || !cm->is_in_use() || (cm->method()->code() != cm)) {
 261               csc->set_to_clean();
 262             }
 263           }
 264         break;
 265       }


 266     }
 267   }
 268 }
 269 
 270 int CompiledMethod::verify_icholder_relocations() {
 271   ResourceMark rm;
 272   int count = 0;
 273 
 274   RelocIterator iter(this);
 275   while(iter.next()) {
 276     if (iter.type() == relocInfo::virtual_call_type) {
 277       if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc(), this)) {
 278         CompiledIC *ic = CompiledIC_at(&iter);
 279         if (TraceCompiledIC) {
 280           tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
 281           ic->print();
 282         }
 283         assert(ic->cached_icholder() != NULL, "must be non-NULL");
 284         count++;
 285       }


 323 // (b) it is a deopt PC
 324 address CompiledMethod::get_deopt_original_pc(const frame* fr) {
 325   if (fr->cb() == NULL)  return NULL;
 326 
 327   CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
 328   if (cm != NULL && cm->is_deopt_pc(fr->pc()))
 329     return cm->get_original_pc(fr);
 330 
 331   return NULL;
 332 }
 333 
 334 Method* CompiledMethod::attached_method(address call_instr) {
 335   assert(code_contains(call_instr), "not part of the nmethod");
 336   RelocIterator iter(this, call_instr, call_instr + 1);
 337   while (iter.next()) {
 338     if (iter.addr() == call_instr) {
 339       switch(iter.type()) {
 340         case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
 341         case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
 342         case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();

 343       }
 344     }
 345   }
 346   return NULL; // not found
 347 }
 348 
 349 Method* CompiledMethod::attached_method_before_pc(address pc) {
 350   if (NativeCall::is_call_before(pc)) {
 351     NativeCall* ncall = nativeCall_before(pc);
 352     return attached_method(ncall->instruction_address());
 353   }
 354   return NULL; // not a call
 355 }
 356 
 357 void CompiledMethod::clear_inline_caches() {
 358   assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
 359   if (is_zombie()) {
 360     return;
 361   }
 362 


 633         clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive);
 634       }
 635 
 636       postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 637       break;
 638 
 639     case relocInfo::opt_virtual_call_type:
 640       postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 641       break;
 642 
 643     case relocInfo::static_call_type:
 644       postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
 645       break;
 646 
 647     case relocInfo::oop_type:
 648       // handled by do_unloading_oops below
 649       break;
 650 
 651     case relocInfo::metadata_type:
 652       break; // nothing to do.



 653     }
 654   }
 655 
 656   if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
 657     return postponed;
 658   }
 659 
 660 #if INCLUDE_JVMCI
 661   if (do_unloading_jvmci(is_alive, unloading_occurred)) {
 662     return postponed;
 663   }
 664 #endif
 665 
 666   // Ensure that all metadata is still alive
 667   verify_metadata_loaders(low_boundary, is_alive);
 668 
 669   return postponed;
 670 }
 671 
 672 void CompiledMethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) {


 686     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
 687     // (See comment above.)
 688   }
 689 
 690   RelocIterator iter(this, low_boundary);
 691   while(iter.next()) {
 692 
 693     switch (iter.type()) {
 694 
 695     case relocInfo::virtual_call_type:
 696       clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 697       break;
 698 
 699     case relocInfo::opt_virtual_call_type:
 700       clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 701       break;
 702 
 703     case relocInfo::static_call_type:
 704       clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
 705       break;



 706     }
 707   }
 708 }
   1 /*
   2  * Copyright (c) 2015, 2017, 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  *


 246         CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
 247         if( cb != NULL && cb->is_compiled() ) {
 248           CompiledMethod* nm = cb->as_compiled_method();
 249           // Clean inline caches pointing to zombie, non-entrant and unloaded methods
 250           if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive());
 251         }
 252         break;
 253       }
 254       case relocInfo::static_call_type: {
 255           CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
 256           CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
 257           if( cb != NULL && cb->is_compiled() ) {
 258             CompiledMethod* cm = cb->as_compiled_method();
 259             // Clean inline caches pointing to zombie, non-entrant and unloaded methods
 260             if (clean_all || !cm->is_in_use() || (cm->method()->code() != cm)) {
 261               csc->set_to_clean();
 262             }
 263           }
 264         break;
 265       }
 266       default:
 267         break;
 268     }
 269   }
 270 }
 271 
 272 int CompiledMethod::verify_icholder_relocations() {
 273   ResourceMark rm;
 274   int count = 0;
 275 
 276   RelocIterator iter(this);
 277   while(iter.next()) {
 278     if (iter.type() == relocInfo::virtual_call_type) {
 279       if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc(), this)) {
 280         CompiledIC *ic = CompiledIC_at(&iter);
 281         if (TraceCompiledIC) {
 282           tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
 283           ic->print();
 284         }
 285         assert(ic->cached_icholder() != NULL, "must be non-NULL");
 286         count++;
 287       }


 325 // (b) it is a deopt PC
 326 address CompiledMethod::get_deopt_original_pc(const frame* fr) {
 327   if (fr->cb() == NULL)  return NULL;
 328 
 329   CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
 330   if (cm != NULL && cm->is_deopt_pc(fr->pc()))
 331     return cm->get_original_pc(fr);
 332 
 333   return NULL;
 334 }
 335 
 336 Method* CompiledMethod::attached_method(address call_instr) {
 337   assert(code_contains(call_instr), "not part of the nmethod");
 338   RelocIterator iter(this, call_instr, call_instr + 1);
 339   while (iter.next()) {
 340     if (iter.addr() == call_instr) {
 341       switch(iter.type()) {
 342         case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
 343         case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
 344         case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();
 345         default:                               break;
 346       }
 347     }
 348   }
 349   return NULL; // not found
 350 }
 351 
 352 Method* CompiledMethod::attached_method_before_pc(address pc) {
 353   if (NativeCall::is_call_before(pc)) {
 354     NativeCall* ncall = nativeCall_before(pc);
 355     return attached_method(ncall->instruction_address());
 356   }
 357   return NULL; // not a call
 358 }
 359 
 360 void CompiledMethod::clear_inline_caches() {
 361   assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
 362   if (is_zombie()) {
 363     return;
 364   }
 365 


 636         clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive);
 637       }
 638 
 639       postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 640       break;
 641 
 642     case relocInfo::opt_virtual_call_type:
 643       postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 644       break;
 645 
 646     case relocInfo::static_call_type:
 647       postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
 648       break;
 649 
 650     case relocInfo::oop_type:
 651       // handled by do_unloading_oops below
 652       break;
 653 
 654     case relocInfo::metadata_type:
 655       break; // nothing to do.
 656 
 657     default:
 658       break;
 659     }
 660   }
 661 
 662   if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) {
 663     return postponed;
 664   }
 665 
 666 #if INCLUDE_JVMCI
 667   if (do_unloading_jvmci(is_alive, unloading_occurred)) {
 668     return postponed;
 669   }
 670 #endif
 671 
 672   // Ensure that all metadata is still alive
 673   verify_metadata_loaders(low_boundary, is_alive);
 674 
 675   return postponed;
 676 }
 677 
 678 void CompiledMethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) {


 692     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
 693     // (See comment above.)
 694   }
 695 
 696   RelocIterator iter(this, low_boundary);
 697   while(iter.next()) {
 698 
 699     switch (iter.type()) {
 700 
 701     case relocInfo::virtual_call_type:
 702       clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 703       break;
 704 
 705     case relocInfo::opt_virtual_call_type:
 706       clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
 707       break;
 708 
 709     case relocInfo::static_call_type:
 710       clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this);
 711       break;
 712 
 713     default:
 714       break;
 715     }
 716   }
 717 }
< prev index next >