annotate src/os_cpu/solaris_sparc/vm/thread_solaris_sparc.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 93b6525e3b82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_thread_solaris_sparc.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // For Forte Analyzer AsyncGetCallTrace profiling support - thread is
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // currently interrupted by SIGPROF
a61af66fc99e Initial load
duke
parents:
diff changeset
30 //
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // NOTE: On Solaris, register windows are flushed in the signal handler
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // except for possibly the top frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //
a61af66fc99e Initial load
duke
parents:
diff changeset
34 bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 void* ucontext, bool isInJava) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 assert(Thread::current() == this, "caller must be current thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
38 assert(this->is_Java_thread(), "must be JavaThread");
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 JavaThread* jt = (JavaThread *)this;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 if (!isInJava) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // make_walkable flushes register windows and grabs last_Java_pc
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // which can not be done if the ucontext sp matches last_Java_sp
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // stack walking utilities assume last_Java_pc set if marked flushed
a61af66fc99e Initial load
duke
parents:
diff changeset
46 jt->frame_anchor()->make_walkable(jt);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // If we have a walkable last_Java_frame, then we should use it
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // even if isInJava == true. It should be more reliable than
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // ucontext info.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 #if 0
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // This sanity check may not be needed with the new frame
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // walking code. Remove it for now.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 if (!jt->frame_anchor()->post_Java_state_is_pc()
a61af66fc99e Initial load
duke
parents:
diff changeset
57 && frame::next_younger_sp_or_null(last_Java_sp(),
a61af66fc99e Initial load
duke
parents:
diff changeset
58 jt->frame_anchor()->post_Java_sp()) == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // the anchor contains an SP, but the frame is not walkable
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // because post_Java_sp isn't valid relative to last_Java_sp
a61af66fc99e Initial load
duke
parents:
diff changeset
61 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
64 *fr_addr = jt->pd_last_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ucontext_t* uc = (ucontext_t*) ucontext;
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // At this point, we don't have a walkable last_Java_frame, so
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // we try to glean some information out of the ucontext.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 intptr_t* ret_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 ExtendedPC addr = os::Solaris::fetch_frame_from_ucontext(this, uc,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 &ret_sp, NULL /* ret_fp only used on Solaris X86 */);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 if (addr.pc() == NULL || ret_sp == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // ucontext wasn't useful
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // we were running Java code when SIGPROF came in
a61af66fc99e Initial load
duke
parents:
diff changeset
81 if (isInJava) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // If we have a last_Java_sp, then the SIGPROF signal caught us
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // right when we were transitioning from _thread_in_Java to a new
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // JavaThreadState. We use last_Java_sp instead of the sp from
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // the ucontext since it should be more reliable.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (jt->has_last_Java_frame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 ret_sp = jt->last_Java_sp();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Implied else: we don't have a last_Java_sp so we use what we
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // got from the ucontext.
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 frame ret_frame(ret_sp, frame::unpatchable, addr.pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (!ret_frame.safe_for_sender(jt)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // nothing else to try if the frame isn't good
a61af66fc99e Initial load
duke
parents:
diff changeset
95 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 *fr_addr = ret_frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // At this point, we know we weren't running Java code. We might
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // have a last_Java_sp, but we don't have a walkable frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // However, we might still be able to construct something useful
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // if the thread was running native code.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (jt->has_last_Java_frame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(!jt->frame_anchor()->walkable(), "case covered above");
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (jt->thread_state() == _thread_in_native) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (!ret_frame.safe_for_sender(jt)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // nothing else to try if the frame isn't good
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 *fr_addr = ret_frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // nothing else to try
a61af66fc99e Initial load
duke
parents:
diff changeset
120 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }