Mercurial > hg > truffle
annotate src/share/vm/prims/forte.cpp @ 7788:dbbe8ce3bfa5
commands: accept 'server0' as a vm, accept version number which have '-...' suffix (-internal, -ea...)
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 13 Feb 2013 18:33:54 +0100 |
parents | 59c790074993 |
children | dcb062bea05b |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "code/debugInfoRec.hpp" | |
27 #include "code/pcDesc.hpp" | |
28 #include "gc_interface/collectedHeap.inline.hpp" | |
29 #include "memory/space.hpp" | |
30 #include "memory/universe.inline.hpp" | |
31 #include "oops/oop.inline.hpp" | |
32 #include "oops/oop.inline2.hpp" | |
33 #include "prims/forte.hpp" | |
34 #include "runtime/thread.hpp" | |
35 #include "runtime/vframe.hpp" | |
36 #include "runtime/vframeArray.hpp" | |
0 | 37 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
38 // These name match the names reported by the forte quality kit |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
39 enum { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
40 ticks_no_Java_frame = 0, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
41 ticks_no_class_load = -1, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
42 ticks_GC_active = -2, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
43 ticks_unknown_not_Java = -3, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
44 ticks_not_walkable_not_Java = -4, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
45 ticks_unknown_Java = -5, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
46 ticks_not_walkable_Java = -6, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
47 ticks_unknown_state = -7, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
48 ticks_thread_exit = -8, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
49 ticks_deopt = -9, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
50 ticks_safepoint = -10 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
51 }; |
0 | 52 |
53 //------------------------------------------------------- | |
54 | |
55 // Native interfaces for use by Forte tools. | |
56 | |
57 | |
58 #ifndef IA64 | |
59 | |
60 class vframeStreamForte : public vframeStreamCommon { | |
61 public: | |
62 // constructor that starts with sender of frame fr (top_frame) | |
63 vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub); | |
64 void forte_next(); | |
65 }; | |
66 | |
67 | |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
68 static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm); |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
69 static bool is_decipherable_interpreted_frame(JavaThread* thread, |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
70 frame* fr, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
71 Method** method_p, |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
72 int* bci_p); |
0 | 73 |
74 | |
75 | |
76 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
77 vframeStreamForte::vframeStreamForte(JavaThread *jt, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
78 frame fr, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
79 bool stop_at_java_call_stub) : vframeStreamCommon(jt) { |
0 | 80 |
81 _stop_at_java_call_stub = stop_at_java_call_stub; | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
82 _frame = fr; |
0 | 83 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
84 // We must always have a valid frame to start filling |
0 | 85 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
86 bool filled_in = fill_from_frame(); |
0 | 87 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
88 assert(filled_in, "invariant"); |
0 | 89 |
90 } | |
91 | |
92 | |
93 // Solaris SPARC Compiler1 needs an additional check on the grandparent | |
94 // of the top_frame when the parent of the top_frame is interpreted and | |
95 // the grandparent is compiled. However, in this method we do not know | |
96 // the relationship of the current _frame relative to the top_frame so | |
97 // we implement a more broad sanity check. When the previous callee is | |
98 // interpreted and the current sender is compiled, we verify that the | |
99 // current sender is also walkable. If it is not walkable, then we mark | |
100 // the current vframeStream as at the end. | |
101 void vframeStreamForte::forte_next() { | |
102 // handle frames with inlining | |
103 if (_mode == compiled_mode && | |
104 vframeStreamCommon::fill_in_compiled_inlined_sender()) { | |
105 return; | |
106 } | |
107 | |
108 // handle general case | |
109 | |
110 int loop_count = 0; | |
111 int loop_max = MaxJavaStackTraceDepth * 2; | |
112 | |
113 | |
114 do { | |
115 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
116 loop_count++; |
0 | 117 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
118 // By the time we get here we should never see unsafe but better |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
119 // safe then segv'd |
0 | 120 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
121 if (loop_count > loop_max || !_frame.safe_for_sender(_thread)) { |
0 | 122 _mode = at_end_mode; |
123 return; | |
124 } | |
125 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
126 _frame = _frame.sender(&_reg_map); |
0 | 127 |
128 } while (!fill_from_frame()); | |
129 } | |
130 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
131 // Determine if 'fr' is a decipherable compiled frame. We are already |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
132 // assured that fr is for a java nmethod. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
133 |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
134 static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm) { |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
135 assert(nm->is_java_method(), "invariant"); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
136 |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
137 if (thread->has_last_Java_frame() && thread->last_Java_pc() == fr->pc()) { |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
138 // We're stopped at a call into the JVM so look for a PcDesc with |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
139 // the actual pc reported by the frame. |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
140 PcDesc* pc_desc = nm->pc_desc_at(fr->pc()); |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
141 |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
142 // Did we find a useful PcDesc? |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
143 if (pc_desc != NULL && |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
144 pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) { |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
145 return true; |
0 | 146 } |
147 } | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
148 |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
149 // We're at some random pc in the nmethod so search for the PcDesc |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
150 // whose pc is greater than the current PC. It's done this way |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
151 // because the extra PcDescs that are recorded for improved debug |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
152 // info record the end of the region covered by the ScopeDesc |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
153 // instead of the beginning. |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
154 PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1); |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
155 |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
156 // Now do we have a useful PcDesc? |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
157 if (pc_desc == NULL || |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
158 pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) { |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
159 // No debug information available for this pc |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
160 // vframeStream would explode if we try and walk the frames. |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
161 return false; |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
162 } |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
163 |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
164 // This PcDesc is useful however we must adjust the frame's pc |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
165 // so that the vframeStream lookups will use this same pc |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
166 fr->set_pc(pc_desc->real_pc(nm)); |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
167 return true; |
0 | 168 } |
169 | |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
170 |
0 | 171 // Determine if 'fr' is a walkable interpreted frame. Returns false |
172 // if it is not. *method_p, and *bci_p are not set when false is | |
173 // returned. *method_p is non-NULL if frame was executing a Java | |
174 // method. *bci_p is != -1 if a valid BCI in the Java method could | |
175 // be found. | |
176 // Note: this method returns true when a valid Java method is found | |
177 // even if a valid BCI cannot be found. | |
178 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
179 static bool is_decipherable_interpreted_frame(JavaThread* thread, |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
180 frame* fr, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
181 Method** method_p, |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
182 int* bci_p) { |
0 | 183 assert(fr->is_interpreted_frame(), "just checking"); |
184 | |
185 // top frame is an interpreted frame | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
186 // check if it is walkable (i.e. valid Method* and valid bci) |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
187 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
188 // Because we may be racing a gc thread the method and/or bci |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
189 // of a valid interpreter frame may look bad causing us to |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
190 // fail the is_interpreted_frame_valid test. If the thread |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
191 // is in any of the following states we are assured that the |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
192 // frame is in fact valid and we must have hit the race. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
193 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
194 JavaThreadState state = thread->thread_state(); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
195 bool known_valid = (state == _thread_in_native || |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
196 state == _thread_in_vm || |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
197 state == _thread_blocked ); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
198 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
199 if (known_valid || fr->is_interpreted_frame_valid(thread)) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
200 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
201 // The frame code should completely validate the frame so that |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
202 // references to Method* and bci are completely safe to access |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
203 // If they aren't the frame code should be fixed not this |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
204 // code. However since gc isn't locked out the values could be |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
205 // stale. This is a race we can never completely win since we can't |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
206 // lock out gc so do one last check after retrieving their values |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
207 // from the frame for additional safety |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
208 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
209 Method* method = fr->interpreter_frame_method(); |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
210 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
211 // We've at least found a method. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
212 // NOTE: there is something to be said for the approach that |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
213 // if we don't find a valid bci then the method is not likely |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
214 // a valid method. Then again we may have caught an interpreter |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
215 // frame in the middle of construction and the bci field is |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
216 // not yet valid. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
217 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
218 *method_p = method; |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6725
diff
changeset
|
219 if (!method->is_valid_method()) return false; |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
220 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
221 intptr_t bcx = fr->interpreter_frame_bcx(); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
222 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
223 int bci = method->validate_bci_from_bcx(bcx); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
224 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
225 // note: bci is set to -1 if not a valid bci |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
226 *bci_p = bci; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
227 return true; |
0 | 228 } |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
229 |
0 | 230 return false; |
231 } | |
232 | |
233 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
234 // Determine if 'fr' can be used to find an initial Java frame. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
235 // Return false if it can not find a fully decipherable Java frame |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
236 // (in other words a frame that isn't safe to use in a vframe stream). |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
237 // Obviously if it can't even find a Java frame false will also be returned. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
238 // |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
239 // If we find a Java frame decipherable or not then by definition we have |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
240 // identified a method and that will be returned to the caller via method_p. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
241 // If we can determine a bci that is returned also. (Hmm is it possible |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
242 // to return a method and bci and still return false? ) |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
243 // |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
244 // The initial Java frame we find (if any) is return via initial_frame_p. |
0 | 245 // |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
246 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
247 static bool find_initial_Java_frame(JavaThread* thread, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
248 frame* fr, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
249 frame* initial_frame_p, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
250 Method** method_p, |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
251 int* bci_p) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
252 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
253 // It is possible that for a frame containing an nmethod |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
254 // we can capture the method but no bci. If we get no |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
255 // bci the frame isn't walkable but the method is usable. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
256 // Therefore we init the returned Method* to NULL so the |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
257 // caller can make the distinction. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
258 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
259 *method_p = NULL; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
260 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
261 // On the initial call to this method the frame we get may not be |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
262 // recognizable to us. This should only happen if we are in a JRT_LEAF |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
263 // or something called by a JRT_LEAF method. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
264 |
0 | 265 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
266 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
267 frame candidate = *fr; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
268 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
269 // If the starting frame we were given has no codeBlob associated with |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
270 // it see if we can find such a frame because only frames with codeBlobs |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
271 // are possible Java frames. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
272 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
273 if (fr->cb() == NULL) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
274 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
275 // See if we can find a useful frame |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
276 int loop_count; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
277 int loop_max = MaxJavaStackTraceDepth * 2; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
278 RegisterMap map(thread, false); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
279 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
280 for (loop_count = 0; loop_count < loop_max; loop_count++) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
281 if (!candidate.safe_for_sender(thread)) return false; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
282 candidate = candidate.sender(&map); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
283 if (candidate.cb() != NULL) break; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
284 } |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
285 if (candidate.cb() == NULL) return false; |
0 | 286 } |
287 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
288 // We have a frame known to be in the codeCache |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
289 // We will hopefully be able to figure out something to do with it. |
0 | 290 int loop_count; |
291 int loop_max = MaxJavaStackTraceDepth * 2; | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
292 RegisterMap map(thread, false); |
0 | 293 |
294 for (loop_count = 0; loop_count < loop_max; loop_count++) { | |
295 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
296 if (candidate.is_first_frame()) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
297 // If initial frame is frame from StubGenerator and there is no |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
298 // previous anchor, there are no java frames associated with a method |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
299 return false; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
300 } |
0 | 301 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
302 if (candidate.is_interpreted_frame()) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
303 if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
304 *initial_frame_p = candidate; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
305 return true; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
306 } |
0 | 307 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
308 // Hopefully we got some data |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
309 return false; |
0 | 310 } |
311 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
312 if (candidate.cb()->is_nmethod()) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
313 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
314 nmethod* nm = (nmethod*) candidate.cb(); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
315 *method_p = nm->method(); |
0 | 316 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
317 // If the frame isn't fully decipherable then the default |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
318 // value for the bci is a signal that we don't have a bci. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
319 // If we have a decipherable frame this bci value will |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
320 // not be used. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
321 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
322 *bci_p = -1; |
0 | 323 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
324 *initial_frame_p = candidate; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
325 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
326 // Native wrapper code is trivial to decode by vframeStream |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
327 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
328 if (nm->is_native_method()) return true; |
0 | 329 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
330 // If it isn't decipherable then we have found a pc that doesn't |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
331 // have a PCDesc that can get us a bci however we did find |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
332 // a method |
0 | 333 |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
334 if (!is_decipherable_compiled_frame(thread, &candidate, nm)) { |
0 | 335 return false; |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
336 } |
0 | 337 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
338 // is_decipherable_compiled_frame may modify candidate's pc |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
339 *initial_frame_p = candidate; |
0 | 340 |
1349
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
341 assert(nm->pc_desc_at(candidate.pc()) != NULL, "if it's decipherable then pc must be valid"); |
547cbe6dacc5
6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents:
196
diff
changeset
|
342 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
343 return true; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
344 } |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
345 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
346 // Must be some stub frame that we don't care about |
0 | 347 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
348 if (!candidate.safe_for_sender(thread)) return false; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
349 candidate = candidate.sender(&map); |
0 | 350 |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
351 // If it isn't in the code cache something is wrong |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
352 // since once we find a frame in the code cache they |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
353 // all should be there. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
354 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
355 if (candidate.cb() == NULL) return false; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
356 |
0 | 357 } |
358 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
359 return false; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
360 |
0 | 361 } |
362 | |
363 | |
364 // call frame copied from old .h file and renamed | |
365 typedef struct { | |
366 jint lineno; // line number in the source file | |
367 jmethodID method_id; // method executed in this frame | |
368 } ASGCT_CallFrame; | |
369 | |
370 // call trace copied from old .h file and renamed | |
371 typedef struct { | |
372 JNIEnv *env_id; // Env where trace was recorded | |
373 jint num_frames; // number of frames in this trace | |
374 ASGCT_CallFrame *frames; // frames | |
375 } ASGCT_CallTrace; | |
376 | |
377 static void forte_fill_call_trace_given_top(JavaThread* thd, | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
378 ASGCT_CallTrace* trace, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
379 int depth, |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
380 frame top_frame) { |
0 | 381 NoHandleMark nhm; |
382 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
383 frame initial_Java_frame; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
384 Method* method; |
0 | 385 int bci; |
386 int count; | |
387 | |
388 count = 0; | |
389 assert(trace->frames != NULL, "trace->frames must be non-NULL"); | |
390 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
391 bool fully_decipherable = find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
392 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
393 // The frame might not be walkable but still recovered a method |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6725
diff
changeset
|
394 // (e.g. an nmethod with no scope info for the pc) |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
395 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
396 if (method == NULL) return; |
0 | 397 |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6725
diff
changeset
|
398 if (!method->is_valid_method()) { |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
399 trace->num_frames = ticks_GC_active; // -2 |
0 | 400 return; |
401 } | |
402 | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
403 // We got a Java frame however it isn't fully decipherable |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
404 // so it won't necessarily be safe to use it for the |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
405 // initial frame in the vframe stream. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
406 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
407 if (!fully_decipherable) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
408 // Take whatever method the top-frame decoder managed to scrape up. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
409 // We look further at the top frame only if non-safepoint |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
410 // debugging information is available. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
411 count++; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
412 trace->num_frames = count; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
413 trace->frames[0].method_id = method->find_jmethod_id_or_null(); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
414 if (!method->is_native()) { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
415 trace->frames[0].lineno = bci; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
416 } else { |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
417 trace->frames[0].lineno = -3; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
418 } |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
419 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
420 if (!initial_Java_frame.safe_for_sender(thd)) return; |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
421 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
422 RegisterMap map(thd, false); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
423 initial_Java_frame = initial_Java_frame.sender(&map); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
424 } |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
425 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
426 vframeStreamForte st(thd, initial_Java_frame, false); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
427 |
0 | 428 for (; !st.at_end() && count < depth; st.forte_next(), count++) { |
429 bci = st.bci(); | |
430 method = st.method(); | |
431 | |
7176
59c790074993
8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents:
6725
diff
changeset
|
432 if (!method->is_valid_method()) { |
0 | 433 // we throw away everything we've gathered in this sample since |
434 // none of it is safe | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
435 trace->num_frames = ticks_GC_active; // -2 |
0 | 436 return; |
437 } | |
438 | |
439 trace->frames[count].method_id = method->find_jmethod_id_or_null(); | |
440 if (!method->is_native()) { | |
441 trace->frames[count].lineno = bci; | |
442 } else { | |
443 trace->frames[count].lineno = -3; | |
444 } | |
445 } | |
446 trace->num_frames = count; | |
447 return; | |
448 } | |
449 | |
450 | |
451 // Forte Analyzer AsyncGetCallTrace() entry point. Currently supported | |
452 // on Linux X86, Solaris SPARC and Solaris X86. | |
453 // | |
454 // Async-safe version of GetCallTrace being called from a signal handler | |
455 // when a LWP gets interrupted by SIGPROF but the stack traces are filled | |
456 // with different content (see below). | |
457 // | |
458 // This function must only be called when JVM/TI | |
459 // CLASS_LOAD events have been enabled since agent startup. The enabled | |
460 // event will cause the jmethodIDs to be allocated at class load time. | |
461 // The jmethodIDs cannot be allocated in a signal handler because locks | |
462 // cannot be grabbed in a signal handler safely. | |
463 // | |
464 // void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext) | |
465 // | |
466 // Called by the profiler to obtain the current method call stack trace for | |
467 // a given thread. The thread is identified by the env_id field in the | |
468 // ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace | |
469 // structure with enough memory for the requested stack depth. The VM fills in | |
470 // the frames buffer and the num_frames field. | |
471 // | |
472 // Arguments: | |
473 // | |
474 // trace - trace data structure to be filled by the VM. | |
475 // depth - depth of the call stack trace. | |
476 // ucontext - ucontext_t of the LWP | |
477 // | |
478 // ASGCT_CallTrace: | |
479 // typedef struct { | |
480 // JNIEnv *env_id; | |
481 // jint num_frames; | |
482 // ASGCT_CallFrame *frames; | |
483 // } ASGCT_CallTrace; | |
484 // | |
485 // Fields: | |
486 // env_id - ID of thread which executed this trace. | |
487 // num_frames - number of frames in the trace. | |
488 // (< 0 indicates the frame is not walkable). | |
489 // frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers. | |
490 // | |
491 // ASGCT_CallFrame: | |
492 // typedef struct { | |
493 // jint lineno; | |
494 // jmethodID method_id; | |
495 // } ASGCT_CallFrame; | |
496 // | |
497 // Fields: | |
498 // 1) For Java frame (interpreted and compiled), | |
499 // lineno - bci of the method being executed or -1 if bci is not available | |
500 // method_id - jmethodID of the method being executed | |
501 // 2) For native method | |
502 // lineno - (-3) | |
503 // method_id - jmethodID of the method being executed | |
504 | |
505 extern "C" { | |
2191 | 506 JNIEXPORT |
0 | 507 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { |
508 JavaThread* thread; | |
509 | |
510 if (trace->env_id == NULL || | |
511 (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL || | |
512 thread->is_exiting()) { | |
513 | |
514 // bad env_id, thread has exited or thread is exiting | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
515 trace->num_frames = ticks_thread_exit; // -8 |
0 | 516 return; |
517 } | |
518 | |
519 if (thread->in_deopt_handler()) { | |
520 // thread is in the deoptimization handler so return no frames | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
521 trace->num_frames = ticks_deopt; // -9 |
0 | 522 return; |
523 } | |
524 | |
525 assert(JavaThread::current() == thread, | |
526 "AsyncGetCallTrace must be called by the current interrupted thread"); | |
527 | |
528 if (!JvmtiExport::should_post_class_load()) { | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
529 trace->num_frames = ticks_no_class_load; // -1 |
0 | 530 return; |
531 } | |
532 | |
533 if (Universe::heap()->is_gc_active()) { | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
534 trace->num_frames = ticks_GC_active; // -2 |
0 | 535 return; |
536 } | |
537 | |
538 switch (thread->thread_state()) { | |
539 case _thread_new: | |
540 case _thread_uninitialized: | |
541 case _thread_new_trans: | |
542 // We found the thread on the threads list above, but it is too | |
543 // young to be useful so return that there are no Java frames. | |
544 trace->num_frames = 0; | |
545 break; | |
546 case _thread_in_native: | |
547 case _thread_in_native_trans: | |
548 case _thread_blocked: | |
549 case _thread_blocked_trans: | |
550 case _thread_in_vm: | |
551 case _thread_in_vm_trans: | |
552 { | |
553 frame fr; | |
554 | |
555 // param isInJava == false - indicate we aren't in Java code | |
556 if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, false)) { | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
557 trace->num_frames = ticks_unknown_not_Java; // -3 unknown frame |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
558 } else { |
0 | 559 if (!thread->has_last_Java_frame()) { |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
560 trace->num_frames = 0; // No Java frames |
0 | 561 } else { |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
562 trace->num_frames = ticks_not_walkable_not_Java; // -4 non walkable frame by default |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
563 forte_fill_call_trace_given_top(thread, trace, depth, fr); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
564 |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
565 // This assert would seem to be valid but it is not. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
566 // It would be valid if we weren't possibly racing a gc |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
567 // thread. A gc thread can make a valid interpreted frame |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
568 // look invalid. It's a small window but it does happen. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
569 // The assert is left here commented out as a reminder. |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
570 // assert(trace->num_frames != ticks_not_walkable_not_Java, "should always be walkable"); |
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
571 |
0 | 572 } |
573 } | |
574 } | |
575 break; | |
576 case _thread_in_Java: | |
577 case _thread_in_Java_trans: | |
578 { | |
579 frame fr; | |
580 | |
581 // param isInJava == true - indicate we are in Java code | |
582 if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, true)) { | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
583 trace->num_frames = ticks_unknown_Java; // -5 unknown frame |
0 | 584 } else { |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
585 trace->num_frames = ticks_not_walkable_Java; // -6, non walkable frame by default |
0 | 586 forte_fill_call_trace_given_top(thread, trace, depth, fr); |
587 } | |
588 } | |
589 break; | |
590 default: | |
591 // Unknown thread state | |
107
93b6525e3b82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
0
diff
changeset
|
592 trace->num_frames = ticks_unknown_state; // -7 |
0 | 593 break; |
594 } | |
595 } | |
596 | |
597 | |
598 #ifndef _WINDOWS | |
599 // Support for the Forte(TM) Peformance Tools collector. | |
600 // | |
601 // The method prototype is derived from libcollector.h. For more | |
602 // information, please see the libcollect man page. | |
603 | |
604 // Method to let libcollector know about a dynamically loaded function. | |
605 // Because it is weakly bound, the calls become NOP's when the library | |
606 // isn't present. | |
3960 | 607 #ifdef __APPLE__ |
608 // XXXDARWIN: Link errors occur even when __attribute__((weak_import)) | |
609 // is added | |
610 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) (0) | |
611 #else | |
0 | 612 void collector_func_load(char* name, |
613 void* null_argument_1, | |
614 void* null_argument_2, | |
615 void *vaddr, | |
616 int size, | |
617 int zero_argument, | |
618 void* null_argument_3); | |
619 #pragma weak collector_func_load | |
620 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \ | |
621 ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 ) | |
3960 | 622 #endif // __APPLE__ |
0 | 623 #endif // !_WINDOWS |
624 | |
625 } // end extern "C" | |
626 #endif // !IA64 | |
627 | |
628 void Forte::register_stub(const char* name, address start, address end) { | |
629 #if !defined(_WINDOWS) && !defined(IA64) | |
630 assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX, | |
1489
cff162798819
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
1349
diff
changeset
|
631 "Code size exceeds maximum range"); |
0 | 632 |
633 collector_func_load((char*)name, NULL, NULL, start, | |
634 pointer_delta(end, start, sizeof(jbyte)), 0, NULL); | |
635 #endif // !_WINDOWS && !IA64 | |
636 } |