changeset 56726:c6cbcc673cd3

8231949: [PPC64, s390]: Make async profiling more reliable Summary: Better checks if method from interpreter frame is valid. Reviewed-by: rrich, ghaug, goetz
author mdoerr
date Thu, 24 Oct 2019 16:28:51 +0200
parents 9019c186ae99
children 7909763ad193
files src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp
diffstat 2 files changed, 33 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp	Thu Oct 24 16:28:49 2019 +0200
+++ b/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp	Thu Oct 24 16:28:51 2019 +0200
@@ -65,21 +65,22 @@
     }
 
     if (ret_frame.is_interpreted_frame()) {
-       frame::ijava_state* istate = ret_frame.get_ijava_state();
-       if (MetaspaceObj::is_valid((Method*)(istate->method)) == false) {
-         return false;
-       }
-       uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
-       uint64_t istate_bcp = istate->bcp;
-       uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base());
-       uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size());
-       if (istate_bcp >= code_start && istate_bcp < code_end) {
-         // we have a valid bcp, don't touch it, do nothing
-       } else if (reg_bcp >= code_start && reg_bcp < code_end) {
-         istate->bcp = reg_bcp;
+      frame::ijava_state *istate = ret_frame.get_ijava_state();
+      const Method *m = (const Method*)(istate->method);
+      if (!Method::is_valid_method(m)) return false;
+      if (!Metaspace::contains(m->constMethod())) return false;
+
+      uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
+      uint64_t istate_bcp = istate->bcp;
+      uint64_t code_start = (uint64_t)(m->code_base());
+      uint64_t code_end = (uint64_t)(m->code_base() + m->code_size());
+      if (istate_bcp >= code_start && istate_bcp < code_end) {
+        // we have a valid bcp, don't touch it, do nothing
+      } else if (reg_bcp >= code_start && reg_bcp < code_end) {
+        istate->bcp = reg_bcp;
       } else {
-         return false;
-       }
+        return false;
+      }
     }
     if (!ret_frame.safe_for_sender(this)) {
       // nothing else to try if the frame isn't good
--- a/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp	Thu Oct 24 16:28:49 2019 +0200
+++ b/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp	Thu Oct 24 16:28:51 2019 +0200
@@ -63,21 +63,24 @@
 
     if (ret_frame.is_interpreted_frame()) {
       frame::z_ijava_state* istate = ret_frame.ijava_state_unchecked();
-       if ((stack_base() >= (address)istate && (address)istate > stack_end()) ||
-           MetaspaceObj::is_valid((Method*)(istate->method)) == false) {
-         return false;
-       }
-       uint64_t reg_bcp = uc->uc_mcontext.gregs[13/*Z_BCP*/];
-       uint64_t istate_bcp = istate->bcp;
-       uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base());
-       uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size());
-       if (istate_bcp >= code_start && istate_bcp < code_end) {
-         // we have a valid bcp, don't touch it, do nothing
-       } else if (reg_bcp >= code_start && reg_bcp < code_end) {
-         istate->bcp = reg_bcp;
-       } else {
-         return false;
-       }
+      if (stack_base() >= (address)istate && (address)istate > stack_end()) {
+        return false;
+      }
+      const Method *m = (const Method*)(istate->method);
+      if (!Method::is_valid_method(m)) return false;
+      if (!Metaspace::contains(m->constMethod())) return false;
+
+      uint64_t reg_bcp = uc->uc_mcontext.gregs[13/*Z_BCP*/];
+      uint64_t istate_bcp = istate->bcp;
+      uint64_t code_start = (uint64_t)(m->code_base());
+      uint64_t code_end = (uint64_t)(m->code_base() + m->code_size());
+      if (istate_bcp >= code_start && istate_bcp < code_end) {
+        // we have a valid bcp, don't touch it, do nothing
+      } else if (reg_bcp >= code_start && reg_bcp < code_end) {
+        istate->bcp = reg_bcp;
+      } else {
+        return false;
+      }
     }
     if (!ret_frame.safe_for_sender(this)) {
       // nothing else to try if the frame isn't good