Path: blob/master/src/hotspot/os_cpu/windows_x86/thread_windows_x86.cpp
40930 views
/*1* Copyright (c) 2003, 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 "runtime/frame.inline.hpp"26#include "runtime/thread.inline.hpp"2728frame JavaThread::pd_last_frame() {29assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");30vmassert(_anchor.last_Java_pc() != NULL, "not walkable");31return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());32}3334// For Forte Analyzer AsyncGetCallTrace profiling support - thread is35// currently interrupted by SIGPROF36bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,37void* ucontext, bool isInJava) {3839assert(Thread::current() == this, "caller must be current thread");40return pd_get_top_frame(fr_addr, ucontext, isInJava);41}4243bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) {44return pd_get_top_frame(fr_addr, ucontext, isInJava);45}4647bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) {48// If we have a last_Java_frame, then we should use it even if49// isInJava == true. It should be more reliable than CONTEXT info.50if (has_last_Java_frame() && frame_anchor()->walkable()) {51*fr_addr = pd_last_frame();52return true;53}5455// At this point, we don't have a last_Java_frame, so56// we try to glean some information out of the CONTEXT57// if we were running Java code when SIGPROF came in.58if (isInJava) {59frame ret_frame = os::fetch_frame_from_context(ucontext);60if (ret_frame.pc() == NULL || ret_frame.sp() == NULL ) {61// CONTEXT wasn't useful62return false;63}6465if (!ret_frame.safe_for_sender(this)) {66#if COMPILER2_OR_JVMCI67// C2 and JVMCI use ebp as a general register see if NULL fp helps68frame ret_frame2(ret_frame.sp(), NULL, ret_frame.pc());69if (!ret_frame2.safe_for_sender(this)) {70// nothing else to try if the frame isn't good71return false;72}73ret_frame = ret_frame2;74#else75// nothing else to try if the frame isn't good76return false;77#endif // COMPILER2_OR_JVMCI78}79*fr_addr = ret_frame;80return true;81}8283// nothing else to try84return false;85}8687void JavaThread::cache_global_variables() { }888990