Path: blob/master/src/hotspot/os_cpu/linux_arm/thread_linux_arm.cpp
40931 views
/*1* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc/shared/barrierSet.hpp"26#include "gc/shared/cardTable.hpp"27#include "gc/shared/cardTableBarrierSet.inline.hpp"28#include "gc/shared/collectedHeap.hpp"29#include "memory/universe.hpp"30#include "runtime/frame.inline.hpp"3132frame JavaThread::pd_last_frame() {33assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");34if (_anchor.last_Java_pc() != NULL) {35return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());36} else {37// This will pick up pc from sp38return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());39}40}4142void JavaThread::cache_global_variables() {43BarrierSet* bs = BarrierSet::barrier_set();4445const bool allow_shared_alloc =46Universe::heap()->supports_inline_contig_alloc();4748if (allow_shared_alloc) {49_heap_top_addr = (address) Universe::heap()->top_addr();50} else {51_heap_top_addr = NULL;52}5354if (bs->is_a(BarrierSet::CardTableBarrierSet)) {55_card_table_base = (address) (barrier_set_cast<CardTableBarrierSet>(bs)->card_table()->byte_map_base());56} else {57_card_table_base = NULL;58}5960}6162// For Forte Analyzer AsyncGetCallTrace profiling support - thread is63// currently interrupted by SIGPROF64bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,65void* ucontext, bool isInJava) {66assert(Thread::current() == this, "caller must be current thread");67return pd_get_top_frame(fr_addr, ucontext, isInJava);68}6970bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) {71return pd_get_top_frame(fr_addr, ucontext, isInJava);72}7374bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) {75// If we have a last_Java_frame, then we should use it even if76// isInJava == true. It should be more reliable than ucontext info.77if (has_last_Java_frame()) {78*fr_addr = pd_last_frame();79return true;80}8182// Could be in a code section that plays with the stack, like83// MacroAssembler::verify_heapbase()84if (in_top_frame_unsafe_section()) {85return false;86}8788// At this point, we don't have a last_Java_frame, so89// we try to glean some information out of the ucontext90// if we were running Java code when SIGPROF came in.91if (isInJava) {92ucontext_t* uc = (ucontext_t*) ucontext;9394intptr_t* ret_fp;95intptr_t* ret_sp;96address addr = os::fetch_frame_from_context(uc, &ret_sp, &ret_fp);97if (addr == NULL || ret_sp == NULL ) {98// ucontext wasn't useful99return false;100}101102frame ret_frame(ret_sp, ret_fp, addr);103if (!ret_frame.safe_for_sender(this)) {104#ifdef COMPILER2105// C2 uses ebp as a general register see if NULL fp helps106frame ret_frame2(ret_sp, NULL, addr);107if (!ret_frame2.safe_for_sender(this)) {108// nothing else to try if the frame isn't good109return false;110}111ret_frame = ret_frame2;112#else113// nothing else to try if the frame isn't good114return false;115#endif /* COMPILER2 */116}117*fr_addr = ret_frame;118return true;119}120121// nothing else to try122return false;123}124125126