27 #include "compiler/compileBroker.hpp" |
27 #include "compiler/compileBroker.hpp" |
28 #include "interpreter/interpreter.hpp" |
28 #include "interpreter/interpreter.hpp" |
29 #include "interpreter/oopMapCache.hpp" |
29 #include "interpreter/oopMapCache.hpp" |
30 #include "memory/allocation.inline.hpp" |
30 #include "memory/allocation.inline.hpp" |
31 #include "memory/oopFactory.hpp" |
31 #include "memory/oopFactory.hpp" |
32 #include "prims/jvmtiRedefineClassesTrace.hpp" |
|
33 #include "prims/methodHandles.hpp" |
32 #include "prims/methodHandles.hpp" |
34 #include "runtime/compilationPolicy.hpp" |
33 #include "runtime/compilationPolicy.hpp" |
35 #include "runtime/javaCalls.hpp" |
34 #include "runtime/javaCalls.hpp" |
36 #include "runtime/reflection.hpp" |
35 #include "runtime/reflection.hpp" |
37 #include "runtime/signature.hpp" |
36 #include "runtime/signature.hpp" |
274 // root to help keep alive the Method*. |
273 // root to help keep alive the Method*. |
275 // If relevant, the vtable or itable value is stored as vmindex. |
274 // If relevant, the vtable or itable value is stored as vmindex. |
276 // This is done eagerly, since it is readily available without |
275 // This is done eagerly, since it is readily available without |
277 // constructing any new objects. |
276 // constructing any new objects. |
278 // TO DO: maybe intern mname_oop |
277 // TO DO: maybe intern mname_oop |
279 m->method_holder()->add_member_name(m->method_idnum(), mname); |
278 if (m->method_holder()->add_member_name(mname)) { |
280 |
279 return mname(); |
281 return mname(); |
280 } else { |
|
281 // Redefinition caused this to fail. Return NULL (and an exception?) |
|
282 return NULL; |
|
283 } |
282 } |
284 } |
283 |
285 |
284 oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) { |
286 oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) { |
285 int flags = (jushort)( fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS ); |
287 int flags = (jushort)( fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS ); |
286 flags |= IS_FIELD | ((fd.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT); |
288 flags |= IS_FIELD | ((fd.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT); |
949 jweak ref = this->at(idx); |
951 jweak ref = this->at(idx); |
950 JNIHandles::destroy_weak_global(ref); |
952 JNIHandles::destroy_weak_global(ref); |
951 } |
953 } |
952 } |
954 } |
953 |
955 |
954 void MemberNameTable::add_member_name(int index, jweak mem_name_wref) { |
956 void MemberNameTable::add_member_name(jweak mem_name_wref) { |
955 assert_locked_or_safepoint(MemberNameTable_lock); |
957 assert_locked_or_safepoint(MemberNameTable_lock); |
956 this->at_put_grow(index, mem_name_wref); |
958 this->push(mem_name_wref); |
957 } |
|
958 |
|
959 // Return a member name oop or NULL. |
|
960 oop MemberNameTable::get_member_name(int index) { |
|
961 assert_locked_or_safepoint(MemberNameTable_lock); |
|
962 |
|
963 jweak ref = this->at(index); |
|
964 oop mem_name = JNIHandles::resolve(ref); |
|
965 return mem_name; |
|
966 } |
959 } |
967 |
960 |
968 #if INCLUDE_JVMTI |
961 #if INCLUDE_JVMTI |
969 oop MemberNameTable::find_member_name_by_method(Method* old_method) { |
962 // It is called at safepoint only for RedefineClasses |
970 assert_locked_or_safepoint(MemberNameTable_lock); |
|
971 oop found = NULL; |
|
972 int len = this->length(); |
|
973 |
|
974 for (int idx = 0; idx < len; idx++) { |
|
975 oop mem_name = JNIHandles::resolve(this->at(idx)); |
|
976 if (mem_name == NULL) { |
|
977 continue; |
|
978 } |
|
979 Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name); |
|
980 if (method == old_method) { |
|
981 found = mem_name; |
|
982 break; |
|
983 } |
|
984 } |
|
985 return found; |
|
986 } |
|
987 |
|
988 // It is called at safepoint only |
|
989 void MemberNameTable::adjust_method_entries(Method** old_methods, Method** new_methods, |
963 void MemberNameTable::adjust_method_entries(Method** old_methods, Method** new_methods, |
990 int methods_length, bool *trace_name_printed) { |
964 int methods_length, bool *trace_name_printed) { |
991 assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
965 assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
992 // search the MemberNameTable for uses of either obsolete or EMCP methods |
966 // For each redefined method |
993 for (int j = 0; j < methods_length; j++) { |
967 for (int j = 0; j < methods_length; j++) { |
994 Method* old_method = old_methods[j]; |
968 Method* old_method = old_methods[j]; |
995 Method* new_method = new_methods[j]; |
969 Method* new_method = new_methods[j]; |
996 oop mem_name = find_member_name_by_method(old_method); |
970 |
997 if (mem_name != NULL) { |
971 // search the MemberNameTable for uses of either obsolete or EMCP methods |
998 java_lang_invoke_MemberName::adjust_vmtarget(mem_name, new_method); |
972 for (int idx = 0; idx < length(); idx++) { |
999 |
973 oop mem_name = JNIHandles::resolve(this->at(idx)); |
1000 if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { |
974 if (mem_name != NULL) { |
1001 if (!(*trace_name_printed)) { |
975 java_lang_invoke_MemberName::adjust_vmtarget(mem_name, old_method, new_method, |
1002 // RC_TRACE_MESG macro has an embedded ResourceMark |
976 trace_name_printed); |
1003 RC_TRACE_MESG(("adjust: name=%s", |
|
1004 old_method->method_holder()->external_name())); |
|
1005 *trace_name_printed = true; |
|
1006 } |
|
1007 // RC_TRACE macro has an embedded ResourceMark |
|
1008 RC_TRACE(0x00400000, ("MemberName method update: %s(%s)", |
|
1009 new_method->name()->as_C_string(), |
|
1010 new_method->signature()->as_C_string())); |
|
1011 } |
977 } |
1012 } |
978 } |
1013 } |
979 } |
1014 } |
980 } |
1015 #endif // INCLUDE_JVMTI |
981 #endif // INCLUDE_JVMTI |