jdk
74 строки · 2.6 Кб
1/*
2* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
3* Copyright (c) 2009, 2021, Red Hat, 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 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*/
25
26#include "precompiled.hpp"
27#include "runtime/frame.inline.hpp"
28#include "runtime/javaThread.hpp"
29
30frame JavaThread::pd_last_frame() {
31assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
32return frame(last_Java_fp(), last_Java_sp());
33}
34
35void JavaThread::cache_global_variables() {
36// nothing to do
37}
38
39bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
40void* ucontext,
41bool isInJava) {
42if (has_last_Java_frame()) {
43*fr_addr = pd_last_frame();
44return true;
45}
46
47if (isInJava) {
48// We know we are in Java, but there is no frame?
49// Try to find the top-most Java frame on Zero stack then.
50intptr_t* sp = zero_stack()->sp();
51ZeroFrame* zf = top_zero_frame();
52while (zf != nullptr) {
53if (zf->is_interpreter_frame()) {
54interpreterState istate = zf->as_interpreter_frame()->interpreter_state();
55if (istate->self_link() == istate) {
56// Valid interpreter state found, this is our frame.
57*fr_addr = frame(zf, sp);
58return true;
59}
60}
61sp = ((intptr_t *) zf) + 1;
62zf = zf->next();
63}
64}
65
66// No dice.
67return false;
68}
69
70bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr,
71void* ucontext,
72bool isInJava) {
73return pd_get_top_frame_for_signal_handler(fr_addr, ucontext, isInJava);
74}
75