mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8042235: redefining method used by multiple MethodHandles crashes VM
Note all MemberNames created on internal list for adjusting method entries. Reviewed-by: sspitsyn, dcubed, lfoltan
This commit is contained in:
parent
ac5d9dad16
commit
4151db8bfd
8 changed files with 264 additions and 85 deletions
|
@ -2931,28 +2931,27 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void InstanceKlass::add_member_name(int index, Handle mem_name) {
|
||||
bool InstanceKlass::add_member_name(Handle mem_name) {
|
||||
jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
|
||||
MutexLocker ml(MemberNameTable_lock);
|
||||
assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
|
||||
DEBUG_ONLY(No_Safepoint_Verifier nsv);
|
||||
|
||||
// Check if method has been redefined while taking out MemberNameTable_lock, if so
|
||||
// return false. We cannot cache obsolete methods. They will crash when the function
|
||||
// is called!
|
||||
Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name());
|
||||
if (method->is_obsolete()) {
|
||||
return false;
|
||||
} else if (method->is_old()) {
|
||||
// Replace method with redefined version
|
||||
java_lang_invoke_MemberName::set_vmtarget(mem_name(), method_with_idnum(method->method_idnum()));
|
||||
}
|
||||
|
||||
if (_member_names == NULL) {
|
||||
_member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count());
|
||||
}
|
||||
_member_names->add_member_name(index, mem_name_wref);
|
||||
}
|
||||
|
||||
oop InstanceKlass::get_member_name(int index) {
|
||||
MutexLocker ml(MemberNameTable_lock);
|
||||
assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
|
||||
DEBUG_ONLY(No_Safepoint_Verifier nsv);
|
||||
|
||||
if (_member_names == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
oop mem_name =_member_names->get_member_name(index);
|
||||
return mem_name;
|
||||
_member_names->add_member_name(mem_name_wref);
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue