Path: blob/master/src/hotspot/os_cpu/bsd_aarch64/thread_bsd_aarch64.cpp
40930 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. All rights reserved.3* Copyright (c) 2021, Azul Systems, Inc. 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 it7* under the terms of the GNU General Public License version 2 only, as8* published by the Free Software Foundation.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*24*/2526#include "precompiled.hpp"27#include "cds/metaspaceShared.hpp"28#include "runtime/frame.inline.hpp"29#include "runtime/thread.inline.hpp"3031frame JavaThread::pd_last_frame() {32assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");33vmassert(_anchor.last_Java_pc() != NULL, "not walkable");34return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());35}3637// For Forte Analyzer AsyncGetCallTrace profiling support - thread is38// currently interrupted by SIGPROF39bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,40void* ucontext, bool isInJava) {41assert(Thread::current() == this, "caller must be current thread");42return pd_get_top_frame(fr_addr, ucontext, isInJava);43}4445bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) {46return pd_get_top_frame(fr_addr, ucontext, isInJava);47}4849bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) {50assert(this->is_Java_thread(), "must be JavaThread");51JavaThread* jt = (JavaThread *)this;5253// If we have a last_Java_frame, then we should use it even if54// isInJava == true. It should be more reliable than ucontext info.55if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {56*fr_addr = jt->pd_last_frame();57return true;58}5960// At this point, we don't have a last_Java_frame, so61// we try to glean some information out of the ucontext62// if we were running Java code when SIGPROF came in.63if (isInJava) {64ucontext_t* uc = (ucontext_t*) ucontext;6566intptr_t* ret_fp;67intptr_t* ret_sp;68address addr = os::fetch_frame_from_context(uc, &ret_sp, &ret_fp);69if (addr == NULL || ret_sp == NULL ) {70// ucontext wasn't useful71return false;72}7374frame ret_frame(ret_sp, ret_fp, addr);75if (!ret_frame.safe_for_sender(jt)) {76#if COMPILER2_OR_JVMCI77// C2 and JVMCI use ebp as a general register see if NULL fp helps78frame ret_frame2(ret_sp, NULL, addr);79if (!ret_frame2.safe_for_sender(jt)) {80// nothing else to try if the frame isn't good81return false;82}83ret_frame = ret_frame2;84#else85// nothing else to try if the frame isn't good86return false;87#endif // COMPILER2_OR_JVMCI88}89*fr_addr = ret_frame;90return true;91}9293// nothing else to try94return false;95}9697void JavaThread::cache_global_variables() { }9899100101