< prev index next >

src/hotspot/share/code/compiledMethod.cpp

Print this page




 598       // that violates the invariant that all metadata relocations have an oop
 599       // in the compiled method (due to deferred resolution and code patching).
 600 
 601       // This causes dead metadata to remain in compiled methods that are not
 602       // unloading. Unless these slippery metadata relocations of the static
 603       // stubs are at least cleared, subsequent class redefinition operations
 604       // will access potentially free memory, and JavaThread execution
 605       // concurrent to class unloading may call c2i adapters with dead methods.
 606       if (!is_in_static_stub) {
 607         // The first metadata relocation after a static stub relocation is the
 608         // metadata relocation of the static stub used to pass the Method* to
 609         // c2i adapters.
 610         continue;
 611       }
 612       is_in_static_stub = false;
 613       metadata_Relocation* r = iter.metadata_reloc();
 614       Metadata* md = r->metadata_value();
 615       if (md != NULL && md->is_method()) {
 616         Method* method = static_cast<Method*>(md);
 617         if (!method->method_holder()->is_loader_alive()) {
 618           Atomic::store((Method*)NULL, r->metadata_addr());
 619 
 620           if (!r->metadata_is_immediate()) {
 621             r->fix_metadata_relocation();
 622           }
 623         }
 624       }
 625       break;
 626     }
 627 
 628     default:
 629       break;
 630     }
 631   }
 632 
 633   return true;
 634 }
 635 
 636 // Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found
 637 // to not be inherently safe. There is a chance that fields are seen which are not properly
 638 // initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock




 598       // that violates the invariant that all metadata relocations have an oop
 599       // in the compiled method (due to deferred resolution and code patching).
 600 
 601       // This causes dead metadata to remain in compiled methods that are not
 602       // unloading. Unless these slippery metadata relocations of the static
 603       // stubs are at least cleared, subsequent class redefinition operations
 604       // will access potentially free memory, and JavaThread execution
 605       // concurrent to class unloading may call c2i adapters with dead methods.
 606       if (!is_in_static_stub) {
 607         // The first metadata relocation after a static stub relocation is the
 608         // metadata relocation of the static stub used to pass the Method* to
 609         // c2i adapters.
 610         continue;
 611       }
 612       is_in_static_stub = false;
 613       metadata_Relocation* r = iter.metadata_reloc();
 614       Metadata* md = r->metadata_value();
 615       if (md != NULL && md->is_method()) {
 616         Method* method = static_cast<Method*>(md);
 617         if (!method->method_holder()->is_loader_alive()) {
 618           Atomic::store(r->metadata_addr(), (Method*)NULL);
 619 
 620           if (!r->metadata_is_immediate()) {
 621             r->fix_metadata_relocation();
 622           }
 623         }
 624       }
 625       break;
 626     }
 627 
 628     default:
 629       break;
 630     }
 631   }
 632 
 633   return true;
 634 }
 635 
 636 // Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found
 637 // to not be inherently safe. There is a chance that fields are seen which are not properly
 638 // initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock


< prev index next >