hotspot/src/share/vm/code/nmethod.cpp
changeset 35108 ccb4e1f2a6cf
parent 35092 82170e5767c3
child 35132 07bc696c7fdb
--- a/hotspot/src/share/vm/code/nmethod.cpp	Thu Dec 10 14:51:54 2015 +0300
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Fri Dec 11 15:03:11 2015 +0300
@@ -2332,11 +2332,22 @@
 void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
 #ifndef SHARK
   if (method() != NULL && !method()->is_native()) {
-    SimpleScopeDesc ssd(this, fr.pc());
+    address pc = fr.pc();
+    SimpleScopeDesc ssd(this, pc);
     Bytecode_invoke call(ssd.method(), ssd.bci());
     bool has_receiver = call.has_receiver();
     bool has_appendix = call.has_appendix();
     Symbol* signature = call.signature();
+
+    // The method attached by JIT-compilers should be used, if present.
+    // Bytecode can be inaccurate in such case.
+    Method* callee = attached_method_before_pc(pc);
+    if (callee != NULL) {
+      has_receiver = !(callee->access_flags().is_static());
+      has_appendix = false;
+      signature = callee->signature();
+    }
+
     fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
   }
 #endif // !SHARK
@@ -3526,3 +3537,11 @@
   return NULL; // not found
 }
 
+Method* nmethod::attached_method_before_pc(address pc) {
+  if (NativeCall::is_call_before(pc)) {
+    NativeCall* ncall = nativeCall_before(pc);
+    return attached_method(ncall->instruction_address());
+  }
+  return NULL; // not a call
+}
+