changeset 9433:7ab0ec535776

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 e5a0eb0db9e1
children 2d0ba7271ce2 6b0109a8a153
files src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp
diffstat 1 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp	Fri Jun 12 14:33:20 2020 -0700
+++ b/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp	Thu Oct 24 16:28:51 2019 +0200
@@ -51,21 +51,22 @@
     }
 
     if (ret_frame.is_interpreted_frame()) {
-       frame::ijava_state* istate = ret_frame.get_ijava_state();
-       if (!((Method*)(istate->method))->is_metaspace_object()) {
-         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 (m == NULL || !m->is_valid_method()) return false;
+      if (!Metaspace::contains((const void*)m)) 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