src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6515
71a71b0bc844
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2014 SAP AG. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  *
    24  */
    26 #include "precompiled.hpp"
    27 #include "runtime/frame.inline.hpp"
    28 #include "runtime/thread.hpp"
    30 bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) {
    31   assert(this->is_Java_thread(), "must be JavaThread");
    33   // If we have a last_Java_frame, then we should use it even if
    34   // isInJava == true.  It should be more reliable than ucontext info.
    35   if (has_last_Java_frame() && frame_anchor()->walkable()) {
    36     *fr_addr = pd_last_frame();
    37     return true;
    38   }
    40   // At this point, we don't have a last_Java_frame, so
    41   // we try to glean some information out of the ucontext
    42   // if we were running Java code when SIGPROF came in.
    43   if (isInJava) {
    44     ucontext_t* uc = (ucontext_t*) ucontext;
    45     frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/],
    46                      (address)uc->uc_mcontext.regs->nip);
    48     if (ret_frame.pc() == NULL) {
    49       // ucontext wasn't useful
    50       return false;
    51     }
    53     if (ret_frame.is_interpreted_frame()) {
    54        frame::ijava_state* istate = ret_frame.get_ijava_state();
    55        if (!((Method*)(istate->method))->is_metaspace_object()) {
    56          return false;
    57        }
    58        uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
    59        uint64_t istate_bcp = istate->bcp;
    60        uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base());
    61        uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size());
    62        if (istate_bcp >= code_start && istate_bcp < code_end) {
    63          // we have a valid bcp, don't touch it, do nothing
    64        } else if (reg_bcp >= code_start && reg_bcp < code_end) {
    65          istate->bcp = reg_bcp;
    66       } else {
    67          return false;
    68        }
    69     }
    70     if (!ret_frame.safe_for_sender(this)) {
    71       // nothing else to try if the frame isn't good
    72       return false;
    73     }
    74     *fr_addr = ret_frame;
    75     return true;
    76   }
    77   // nothing else to try
    78   return false;
    79 }
    81 // Forte Analyzer AsyncGetCallTrace profiling support is not implemented on Linux/PPC.
    82 bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava) {
    83   assert(this->is_Java_thread(), "must be JavaThread");
    84   return pd_get_top_frame_for_profiling(fr_addr, ucontext, isInJava);
    85 }
    87 void JavaThread::cache_global_variables() { }

mercurial