6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined

Mon, 02 Mar 2009 14:03:03 -0700

author
dcubed
date
Mon, 02 Mar 2009 14:03:03 -0700
changeset 1045
70998f2e05ef
parent 1044
ea20d7ce26b0
child 1046
2f716c0acb64

6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
Summary: Remove incorrect optimization in klassItable::adjust_method_entries(). Add RedefineClasses() tracing support for obsolete method entry.
Reviewed-by: acorn, swamyv

src/cpu/sparc/vm/interp_masm_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/sharedRuntime_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/interp_masm_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/interp_masm_x86_64.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/sharedRuntime_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/sharedRuntime_x86_64.cpp file | annotate | diff | comparison | revisions
src/share/vm/includeDB_core file | annotate | diff | comparison | revisions
src/share/vm/oops/klassVtable.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/jvmtiRedefineClassesTrace.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/sharedRuntime.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/sharedRuntime.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/sparc/vm/interp_masm_sparc.cpp	Mon Mar 02 14:00:23 2009 -0700
     1.2 +++ b/src/cpu/sparc/vm/interp_masm_sparc.cpp	Mon Mar 02 14:03:03 2009 -0700
     1.3 @@ -2465,7 +2465,10 @@
     1.4  //   InterpreterRuntime::post_method_entry();
     1.5  // }
     1.6  // if (DTraceMethodProbes) {
     1.7 -//   SharedRuntime::dtrace_method_entry(method, reciever);
     1.8 +//   SharedRuntime::dtrace_method_entry(method, receiver);
     1.9 +// }
    1.10 +// if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
    1.11 +//   SharedRuntime::rc_trace_method_entry(method, receiver);
    1.12  // }
    1.13  
    1.14  void InterpreterMacroAssembler::notify_method_entry() {
    1.15 @@ -2497,6 +2500,13 @@
    1.16        CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
    1.17        G2_thread, Lmethod);
    1.18    }
    1.19 +
    1.20 +  // RedefineClasses() tracing support for obsolete method entry
    1.21 +  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
    1.22 +    call_VM_leaf(noreg,
    1.23 +      CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
    1.24 +      G2_thread, Lmethod);
    1.25 +  }
    1.26  }
    1.27  
    1.28  
     2.1 --- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Mar 02 14:00:23 2009 -0700
     2.2 +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Mar 02 14:03:03 2009 -0700
     2.3 @@ -2161,6 +2161,18 @@
     2.4      __ restore();
     2.5    }
     2.6  
     2.7 +  // RedefineClasses() tracing support for obsolete method entry
     2.8 +  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
     2.9 +    // create inner frame
    2.10 +    __ save_frame(0);
    2.11 +    __ mov(G2_thread, L7_thread_cache);
    2.12 +    __ set_oop_constant(JNIHandles::make_local(method()), O1);
    2.13 +    __ call_VM_leaf(L7_thread_cache,
    2.14 +         CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
    2.15 +         G2_thread, O1);
    2.16 +    __ restore();
    2.17 +  }
    2.18 +
    2.19    // We are in the jni frame unless saved_frame is true in which case
    2.20    // we are in one frame deeper (the "inner" frame). If we are in the
    2.21    // "inner" frames the args are in the Iregs and if the jni frame then
     3.1 --- a/src/cpu/x86/vm/interp_masm_x86_32.cpp	Mon Mar 02 14:00:23 2009 -0700
     3.2 +++ b/src/cpu/x86/vm/interp_masm_x86_32.cpp	Mon Mar 02 14:03:03 2009 -0700
     3.3 @@ -1512,6 +1512,15 @@
     3.4      call_VM_leaf(
     3.5        CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), rcx, rbx);
     3.6    }
     3.7 +
     3.8 +  // RedefineClasses() tracing support for obsolete method entry
     3.9 +  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
    3.10 +    get_thread(rcx);
    3.11 +    get_method(rbx);
    3.12 +    call_VM_leaf(
    3.13 +      CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
    3.14 +      rcx, rbx);
    3.15 +  }
    3.16  }
    3.17  
    3.18  
     4.1 --- a/src/cpu/x86/vm/interp_masm_x86_64.cpp	Mon Mar 02 14:00:23 2009 -0700
     4.2 +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp	Mon Mar 02 14:03:03 2009 -0700
     4.3 @@ -1593,6 +1593,14 @@
     4.4      call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
     4.5                   r15_thread, c_rarg1);
     4.6    }
     4.7 +
     4.8 +  // RedefineClasses() tracing support for obsolete method entry
     4.9 +  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
    4.10 +    get_method(c_rarg1);
    4.11 +    call_VM_leaf(
    4.12 +      CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
    4.13 +      r15_thread, c_rarg1);
    4.14 +  }
    4.15  }
    4.16  
    4.17  
     5.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Mar 02 14:00:23 2009 -0700
     5.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Mar 02 14:03:03 2009 -0700
     5.3 @@ -1532,6 +1532,14 @@
     5.4           thread, rax);
     5.5    }
     5.6  
     5.7 +  // RedefineClasses() tracing support for obsolete method entry
     5.8 +  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
     5.9 +    __ movoop(rax, JNIHandles::make_local(method()));
    5.10 +    __ call_VM_leaf(
    5.11 +         CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
    5.12 +         thread, rax);
    5.13 +  }
    5.14 +
    5.15  
    5.16    // These are register definitions we need for locking/unlocking
    5.17    const Register swap_reg = rax;  // Must use rax, for cmpxchg instruction
     6.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Mar 02 14:00:23 2009 -0700
     6.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Mar 02 14:03:03 2009 -0700
     6.3 @@ -1506,6 +1506,17 @@
     6.4      restore_args(masm, total_c_args, c_arg, out_regs);
     6.5    }
     6.6  
     6.7 +  // RedefineClasses() tracing support for obsolete method entry
     6.8 +  if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) {
     6.9 +    // protect the args we've loaded
    6.10 +    save_args(masm, total_c_args, c_arg, out_regs);
    6.11 +    __ movoop(c_rarg1, JNIHandles::make_local(method()));
    6.12 +    __ call_VM_leaf(
    6.13 +      CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry),
    6.14 +      r15_thread, c_rarg1);
    6.15 +    restore_args(masm, total_c_args, c_arg, out_regs);
    6.16 +  }
    6.17 +
    6.18    // Lock a synchronized method
    6.19  
    6.20    // Register definitions used by locking and unlocking
     7.1 --- a/src/share/vm/includeDB_core	Mon Mar 02 14:00:23 2009 -0700
     7.2 +++ b/src/share/vm/includeDB_core	Mon Mar 02 14:03:03 2009 -0700
     7.3 @@ -2093,6 +2093,7 @@
     7.4  interp_masm_<arch_model>.cpp            interpreterRuntime.hpp
     7.5  interp_masm_<arch_model>.cpp            interpreter.hpp
     7.6  interp_masm_<arch_model>.cpp            jvmtiExport.hpp
     7.7 +interp_masm_<arch_model>.cpp            jvmtiRedefineClassesTrace.hpp
     7.8  interp_masm_<arch_model>.cpp            jvmtiThreadState.hpp
     7.9  interp_masm_<arch_model>.cpp            markOop.hpp
    7.10  interp_masm_<arch_model>.cpp            methodDataOop.hpp
    7.11 @@ -3669,6 +3670,7 @@
    7.12  sharedRuntime.cpp                       interpreter.hpp
    7.13  sharedRuntime.cpp                       javaCalls.hpp
    7.14  sharedRuntime.cpp                       jvmtiExport.hpp
    7.15 +sharedRuntime.cpp                       jvmtiRedefineClassesTrace.hpp
    7.16  sharedRuntime.cpp                       nativeInst_<arch>.hpp
    7.17  sharedRuntime.cpp                       nativeLookup.hpp
    7.18  sharedRuntime.cpp                       oop.inline.hpp
    7.19 @@ -3698,6 +3700,7 @@
    7.20  sharedRuntime_<arch_model>.cpp          debugInfoRec.hpp
    7.21  sharedRuntime_<arch_model>.cpp          icBuffer.hpp
    7.22  sharedRuntime_<arch_model>.cpp          interpreter.hpp
    7.23 +sharedRuntime_<arch_model>.cpp          jvmtiRedefineClassesTrace.hpp
    7.24  sharedRuntime_<arch_model>.cpp          sharedRuntime.hpp
    7.25  sharedRuntime_<arch_model>.cpp          vframeArray.hpp
    7.26  sharedRuntime_<arch_model>.cpp          vmreg_<arch>.inline.hpp
     8.1 --- a/src/share/vm/oops/klassVtable.cpp	Mon Mar 02 14:00:23 2009 -0700
     8.2 +++ b/src/share/vm/oops/klassVtable.cpp	Mon Mar 02 14:03:03 2009 -0700
     8.3 @@ -992,6 +992,10 @@
     8.4      methodOop new_method = new_methods[j];
     8.5      itableMethodEntry* ime = method_entry(0);
     8.6  
     8.7 +    // The itable can describe more than one interface and the same
     8.8 +    // method signature can be specified by more than one interface.
     8.9 +    // This means we have to do an exhaustive search to find all the
    8.10 +    // old_method references.
    8.11      for (int i = 0; i < _size_method_table; i++) {
    8.12        if (ime->method() == old_method) {
    8.13          ime->initialize(new_method);
    8.14 @@ -1008,7 +1012,6 @@
    8.15              new_method->name()->as_C_string(),
    8.16              new_method->signature()->as_C_string()));
    8.17          }
    8.18 -        break;
    8.19        }
    8.20        ime++;
    8.21      }
     9.1 --- a/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp	Mon Mar 02 14:00:23 2009 -0700
     9.2 +++ b/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp	Mon Mar 02 14:03:03 2009 -0700
     9.3 @@ -49,8 +49,8 @@
     9.4  //    0x00000400 |       1024 - previous class weak reference mgmt during
     9.5  //                              add previous ops (GC)
     9.6  //    0x00000800 |       2048 - previous class breakpoint mgmt
     9.7 -//    0x00001000 |       4096 - unused
     9.8 -//    0x00002000 |       8192 - unused
     9.9 +//    0x00001000 |       4096 - detect calls to obsolete methods
    9.10 +//    0x00002000 |       8192 - fail a guarantee() in addition to detection
    9.11  //    0x00004000 |      16384 - unused
    9.12  //    0x00008000 |      32768 - old/new method matching/add/delete
    9.13  //    0x00010000 |      65536 - impl details: CP size info
    10.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Mon Mar 02 14:00:23 2009 -0700
    10.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Mon Mar 02 14:03:03 2009 -0700
    10.3 @@ -395,6 +395,32 @@
    10.4    throw_and_post_jvmti_exception(thread, h_exception);
    10.5  }
    10.6  
    10.7 +// The interpreter code to call this tracing function is only
    10.8 +// called/generated when TraceRedefineClasses has the right bits
    10.9 +// set. Since obsolete methods are never compiled, we don't have
   10.10 +// to modify the compilers to generate calls to this function.
   10.11 +//
   10.12 +JRT_LEAF(int, SharedRuntime::rc_trace_method_entry(
   10.13 +    JavaThread* thread, methodOopDesc* method))
   10.14 +  assert(RC_TRACE_IN_RANGE(0x00001000, 0x00002000), "wrong call");
   10.15 +
   10.16 +  if (method->is_obsolete()) {
   10.17 +    // We are calling an obsolete method, but this is not necessarily
   10.18 +    // an error. Our method could have been redefined just after we
   10.19 +    // fetched the methodOop from the constant pool.
   10.20 +
   10.21 +    // RC_TRACE macro has an embedded ResourceMark
   10.22 +    RC_TRACE_WITH_THREAD(0x00001000, thread,
   10.23 +                         ("calling obsolete method '%s'",
   10.24 +                          method->name_and_sig_as_C_string()));
   10.25 +    if (RC_TRACE_ENABLED(0x00002000)) {
   10.26 +      // this option is provided to debug calls to obsolete methods
   10.27 +      guarantee(false, "faulting at call to an obsolete method.");
   10.28 +    }
   10.29 +  }
   10.30 +  return 0;
   10.31 +JRT_END
   10.32 +
   10.33  // ret_pc points into caller; we are returning caller's exception handler
   10.34  // for given exception
   10.35  address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
    11.1 --- a/src/share/vm/runtime/sharedRuntime.hpp	Mon Mar 02 14:00:23 2009 -0700
    11.2 +++ b/src/share/vm/runtime/sharedRuntime.hpp	Mon Mar 02 14:03:03 2009 -0700
    11.3 @@ -166,6 +166,9 @@
    11.4    static void throw_and_post_jvmti_exception(JavaThread *thread, Handle h_exception);
    11.5    static void throw_and_post_jvmti_exception(JavaThread *thread, symbolOop name, const char *message = NULL);
    11.6  
    11.7 +  // RedefineClasses() tracing support for obsolete method entry
    11.8 +  static int rc_trace_method_entry(JavaThread* thread, methodOopDesc* m);
    11.9 +
   11.10    // To be used as the entry point for unresolved native methods.
   11.11    static address native_method_throw_unsatisfied_link_error_entry();
   11.12  

mercurial