< prev index next >

src/hotspot/share/code/codeCache.cpp

Print this page




 628 CodeBlob* CodeCache::find_blob(void* start) {
 629   CodeBlob* result = find_blob_unsafe(start);
 630   // We could potentially look up non_entrant methods
 631   guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || VMError::is_error_reported(), "unsafe access to zombie method");
 632   return result;
 633 }
 634 
 635 // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
 636 // what you are doing)
 637 CodeBlob* CodeCache::find_blob_unsafe(void* start) {
 638   // NMT can walk the stack before code cache is created
 639   if (_heaps != NULL) {
 640     CodeHeap* heap = get_code_heap_containing(start);
 641     if (heap != NULL) {
 642       return heap->find_blob_unsafe(start);
 643     }
 644   }
 645   return NULL;
 646 }
 647 




















 648 nmethod* CodeCache::find_nmethod(void* start) {
 649   CodeBlob* cb = find_blob(start);
 650   assert(cb->is_nmethod(), "did not find an nmethod");
 651   return (nmethod*)cb;
 652 }
 653 
 654 void CodeCache::blobs_do(void f(CodeBlob* nm)) {
 655   assert_locked_or_safepoint(CodeCache_lock);
 656   FOR_ALL_HEAPS(heap) {
 657     FOR_ALL_BLOBS(cb, *heap) {
 658       f(cb);
 659     }
 660   }
 661 }
 662 
 663 void CodeCache::nmethods_do(void f(nmethod* nm)) {
 664   assert_locked_or_safepoint(CodeCache_lock);
 665   NMethodIterator iter(NMethodIterator::all_blobs);
 666   while(iter.next()) {
 667     f(iter.method());




 628 CodeBlob* CodeCache::find_blob(void* start) {
 629   CodeBlob* result = find_blob_unsafe(start);
 630   // We could potentially look up non_entrant methods
 631   guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || VMError::is_error_reported(), "unsafe access to zombie method");
 632   return result;
 633 }
 634 
 635 // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
 636 // what you are doing)
 637 CodeBlob* CodeCache::find_blob_unsafe(void* start) {
 638   // NMT can walk the stack before code cache is created
 639   if (_heaps != NULL) {
 640     CodeHeap* heap = get_code_heap_containing(start);
 641     if (heap != NULL) {
 642       return heap->find_blob_unsafe(start);
 643     }
 644   }
 645   return NULL;
 646 }
 647 
 648 CodeBlob* CodeCache::patch_nop(NativePostCallNop* nop, void* pc, int& slot) {
 649   CodeBlob* cb = CodeCache::find_blob(pc);
 650   int oopmap_slot = cb->oop_maps()->find_slot_for_offset((intptr_t) pc - (intptr_t) cb->code_begin());
 651   intptr_t cbaddr = (intptr_t) cb;
 652   intptr_t offset = ((intptr_t) pc) - cbaddr;
 653 
 654   if (((oopmap_slot & 0xff) == oopmap_slot) && ((offset & 0xffffff) == offset)) {
 655     jint value = (oopmap_slot << 24) | (jint) offset;
 656     nop->patch(value);
 657     slot = oopmap_slot;
 658   } else {
 659     slot = -1;
 660     log_debug(codecache)("failed to encode %d %d", oopmap_slot, (int) offset);
 661   }
 662 #ifdef CONT_DOUBLE_NOP
 663   assert (!nop->is_mode2(), "");
 664 #endif
 665   return cb;
 666 }
 667 
 668 nmethod* CodeCache::find_nmethod(void* start) {
 669   CodeBlob* cb = find_blob(start);
 670   assert(cb->is_nmethod(), "did not find an nmethod");
 671   return (nmethod*)cb;
 672 }
 673 
 674 void CodeCache::blobs_do(void f(CodeBlob* nm)) {
 675   assert_locked_or_safepoint(CodeCache_lock);
 676   FOR_ALL_HEAPS(heap) {
 677     FOR_ALL_BLOBS(cb, *heap) {
 678       f(cb);
 679     }
 680   }
 681 }
 682 
 683 void CodeCache::nmethods_do(void f(nmethod* nm)) {
 684   assert_locked_or_safepoint(CodeCache_lock);
 685   NMethodIterator iter(NMethodIterator::all_blobs);
 686   while(iter.next()) {
 687     f(iter.method());


< prev index next >