Mercurial > hg > truffle
annotate src/share/vm/runtime/vframe.cpp @ 18065:e8d870411858
Merge
author | asaha |
---|---|
date | Thu, 05 Jun 2014 15:26:51 -0700 |
parents | 78bbf4d43a14 |
children | 4a1062dc52d1 |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
2 * Copyright (c) 1997, 2014, 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:
1547
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1547
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:
1547
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.hpp" | |
27 #include "classfile/systemDictionary.hpp" | |
28 #include "classfile/vmSymbols.hpp" | |
29 #include "code/codeCache.hpp" | |
30 #include "code/debugInfoRec.hpp" | |
31 #include "code/nmethod.hpp" | |
32 #include "code/pcDesc.hpp" | |
33 #include "code/scopeDesc.hpp" | |
34 #include "interpreter/interpreter.hpp" | |
35 #include "interpreter/oopMapCache.hpp" | |
36 #include "memory/resourceArea.hpp" | |
37 #include "oops/instanceKlass.hpp" | |
38 #include "oops/oop.inline.hpp" | |
39 #include "runtime/handles.inline.hpp" | |
40 #include "runtime/objectMonitor.hpp" | |
41 #include "runtime/objectMonitor.inline.hpp" | |
42 #include "runtime/signature.hpp" | |
43 #include "runtime/stubRoutines.hpp" | |
44 #include "runtime/synchronizer.hpp" | |
45 #include "runtime/vframe.hpp" | |
46 #include "runtime/vframeArray.hpp" | |
47 #include "runtime/vframe_hp.hpp" | |
0 | 48 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
49 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
50 |
0 | 51 vframe::vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread) |
52 : _reg_map(reg_map), _thread(thread) { | |
53 assert(fr != NULL, "must have frame"); | |
54 _fr = *fr; | |
55 } | |
56 | |
57 vframe::vframe(const frame* fr, JavaThread* thread) | |
58 : _reg_map(thread), _thread(thread) { | |
59 assert(fr != NULL, "must have frame"); | |
60 _fr = *fr; | |
61 } | |
62 | |
63 vframe* vframe::new_vframe(const frame* f, const RegisterMap* reg_map, JavaThread* thread) { | |
64 // Interpreter frame | |
65 if (f->is_interpreted_frame()) { | |
66 return new interpretedVFrame(f, reg_map, thread); | |
67 } | |
68 | |
69 // Compiled frame | |
70 CodeBlob* cb = f->cb(); | |
71 if (cb != NULL) { | |
72 if (cb->is_nmethod()) { | |
73 nmethod* nm = (nmethod*)cb; | |
74 return new compiledVFrame(f, reg_map, thread, nm); | |
75 } | |
76 | |
77 if (f->is_runtime_frame()) { | |
78 // Skip this frame and try again. | |
79 RegisterMap temp_map = *reg_map; | |
80 frame s = f->sender(&temp_map); | |
81 return new_vframe(&s, &temp_map, thread); | |
82 } | |
83 } | |
84 | |
85 // External frame | |
86 return new externalVFrame(f, reg_map, thread); | |
87 } | |
88 | |
89 vframe* vframe::sender() const { | |
90 RegisterMap temp_map = *register_map(); | |
91 assert(is_top(), "just checking"); | |
92 if (_fr.is_entry_frame() && _fr.is_first_frame()) return NULL; | |
93 frame s = _fr.real_sender(&temp_map); | |
94 if (s.is_first_frame()) return NULL; | |
95 return vframe::new_vframe(&s, &temp_map, thread()); | |
96 } | |
97 | |
98 vframe* vframe::top() const { | |
99 vframe* vf = (vframe*) this; | |
100 while (!vf->is_top()) vf = vf->sender(); | |
101 return vf; | |
102 } | |
103 | |
104 | |
105 javaVFrame* vframe::java_sender() const { | |
106 vframe* f = sender(); | |
107 while (f != NULL) { | |
108 if (f->is_java_frame()) return javaVFrame::cast(f); | |
109 f = f->sender(); | |
110 } | |
111 return NULL; | |
112 } | |
113 | |
114 // ------------- javaVFrame -------------- | |
115 | |
116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() { | |
117 assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(), | |
118 "must be at safepoint or it's a java frame of the current thread"); | |
119 | |
120 GrowableArray<MonitorInfo*>* mons = monitors(); | |
121 GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length()); | |
122 if (mons->is_empty()) return result; | |
123 | |
124 bool found_first_monitor = false; | |
125 ObjectMonitor *pending_monitor = thread()->current_pending_monitor(); | |
126 ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor(); | |
1547
fb1a39993f69
6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents:
1506
diff
changeset
|
127 oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL); |
fb1a39993f69
6951319: enable solaris builds using Sun Studio 12 update 1
jcoomes
parents:
1506
diff
changeset
|
128 oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL); |
0 | 129 |
130 for (int index = (mons->length()-1); index >= 0; index--) { | |
131 MonitorInfo* monitor = mons->at(index); | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
132 if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor |
0 | 133 oop obj = monitor->owner(); |
134 if (obj == NULL) continue; // skip unowned monitor | |
135 // | |
136 // Skip the monitor that the thread is blocked to enter or waiting on | |
137 // | |
138 if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) { | |
139 continue; | |
140 } | |
141 found_first_monitor = true; | |
142 result->append(monitor); | |
143 } | |
144 return result; | |
145 } | |
146 | |
147 static void print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) { | |
148 if (obj.not_null()) { | |
149 st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, (address)obj()); | |
1142 | 150 if (obj->klass() == SystemDictionary::Class_klass()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
151 Klass* target_klass = java_lang_Class::as_Klass(obj()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
152 st->print_cr("(a java.lang.Class for %s)", InstanceKlass::cast(target_klass)->external_name()); |
0 | 153 } else { |
6983 | 154 Klass* k = obj->klass(); |
0 | 155 st->print_cr("(a %s)", k->external_name()); |
156 } | |
157 } | |
158 } | |
159 | |
160 void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) { | |
161 ResourceMark rm; | |
162 | |
163 // If this is the first frame, and java.lang.Object.wait(...) then print out the receiver. | |
164 if (frame_count == 0) { | |
165 if (method()->name() == vmSymbols::wait_name() && | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6725
diff
changeset
|
166 method()->method_holder()->name() == vmSymbols::java_lang_Object()) { |
0 | 167 StackValueCollection* locs = locals(); |
168 if (!locs->is_empty()) { | |
169 StackValue* sv = locs->at(0); | |
170 if (sv->type() == T_OBJECT) { | |
171 Handle o = locs->at(0)->get_obj(); | |
172 print_locked_object_class_name(st, o, "waiting on"); | |
173 } | |
174 } | |
175 } else if (thread()->current_park_blocker() != NULL) { | |
176 oop obj = thread()->current_park_blocker(); | |
6983 | 177 Klass* k = obj->klass(); |
0 | 178 st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name()); |
179 } | |
180 } | |
181 | |
182 | |
183 // Print out all monitors that we have locked or are trying to lock | |
184 GrowableArray<MonitorInfo*>* mons = monitors(); | |
185 if (!mons->is_empty()) { | |
186 bool found_first_monitor = false; | |
187 for (int index = (mons->length()-1); index >= 0; index--) { | |
188 MonitorInfo* monitor = mons->at(index); | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
189 if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
190 if (monitor->owner_is_scalar_replaced()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
191 Klass* k = java_lang_Class::as_Klass(monitor->owner_klass()); |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
192 st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name()); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
193 } else { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
194 oop obj = monitor->owner(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
195 if (obj != NULL) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
196 print_locked_object_class_name(st, obj, "eliminated"); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
197 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
198 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
199 continue; |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
200 } |
0 | 201 if (monitor->owner() != NULL) { |
202 | |
203 // First, assume we have the monitor locked. If we haven't found an | |
204 // owned monitor before and this is the first frame, then we need to | |
205 // see if we have completed the lock or we are blocked trying to | |
206 // acquire it - we can only be blocked if the monitor is inflated | |
207 | |
208 const char *lock_state = "locked"; // assume we have the monitor locked | |
209 if (!found_first_monitor && frame_count == 0) { | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
210 markOop mark = monitor->owner()->mark(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
211 if (mark->has_monitor() && |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
212 mark->monitor() == thread()->current_pending_monitor()) { |
0 | 213 lock_state = "waiting to lock"; |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
214 } |
0 | 215 } |
216 | |
217 found_first_monitor = true; | |
218 print_locked_object_class_name(st, monitor->owner(), lock_state); | |
219 } | |
220 } | |
221 } | |
222 } | |
223 | |
224 // ------------- interpretedVFrame -------------- | |
225 | |
226 u_char* interpretedVFrame::bcp() const { | |
227 return fr().interpreter_frame_bcp(); | |
228 } | |
229 | |
230 void interpretedVFrame::set_bcp(u_char* bcp) { | |
231 fr().interpreter_frame_set_bcp(bcp); | |
232 } | |
233 | |
234 intptr_t* interpretedVFrame::locals_addr_at(int offset) const { | |
235 assert(fr().is_interpreted_frame(), "frame should be an interpreted frame"); | |
236 return fr().interpreter_frame_local_at(offset); | |
237 } | |
238 | |
239 | |
240 GrowableArray<MonitorInfo*>* interpretedVFrame::monitors() const { | |
241 GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(5); | |
242 for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin())); | |
243 current >= fr().interpreter_frame_monitor_end(); | |
244 current = fr().previous_monitor_in_interpreter_frame(current)) { | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
245 result->push(new MonitorInfo(current->obj(), current->lock(), false, false)); |
0 | 246 } |
247 return result; | |
248 } | |
249 | |
250 int interpretedVFrame::bci() const { | |
251 return method()->bci_from(bcp()); | |
252 } | |
253 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
254 Method* interpretedVFrame::method() const { |
0 | 255 return fr().interpreter_frame_method(); |
256 } | |
257 | |
258 StackValueCollection* interpretedVFrame::locals() const { | |
259 int length = method()->max_locals(); | |
260 | |
261 if (method()->is_native()) { | |
262 // If the method is native, max_locals is not telling the truth. | |
263 // maxlocals then equals the size of parameters | |
264 length = method()->size_of_parameters(); | |
265 } | |
266 | |
267 StackValueCollection* result = new StackValueCollection(length); | |
268 | |
269 // Get oopmap describing oops and int for current bci | |
1506 | 270 InterpreterOopMap oop_mask; |
271 if (TraceDeoptimization && Verbose) { | |
272 methodHandle m_h(thread(), method()); | |
273 OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); | |
0 | 274 } else { |
1506 | 275 method()->mask_for(bci(), &oop_mask); |
276 } | |
277 // handle locals | |
278 for(int i=0; i < length; i++) { | |
279 // Find stack location | |
280 intptr_t *addr = locals_addr_at(i); | |
0 | 281 |
1506 | 282 // Depending on oop/int put it in the right package |
283 StackValue *sv; | |
284 if (oop_mask.is_oop(i)) { | |
285 // oop value | |
286 Handle h(*(oop *)addr); | |
287 sv = new StackValue(h); | |
288 } else { | |
289 // integer | |
290 sv = new StackValue(*addr); | |
0 | 291 } |
1506 | 292 assert(sv != NULL, "sanity check"); |
293 result->add(sv); | |
0 | 294 } |
295 return result; | |
296 } | |
297 | |
298 void interpretedVFrame::set_locals(StackValueCollection* values) const { | |
299 if (values == NULL || values->size() == 0) return; | |
300 | |
301 int length = method()->max_locals(); | |
302 if (method()->is_native()) { | |
303 // If the method is native, max_locals is not telling the truth. | |
304 // maxlocals then equals the size of parameters | |
305 length = method()->size_of_parameters(); | |
306 } | |
307 | |
308 assert(length == values->size(), "Mismatch between actual stack format and supplied data"); | |
309 | |
310 // handle locals | |
311 for (int i = 0; i < length; i++) { | |
312 // Find stack location | |
313 intptr_t *addr = locals_addr_at(i); | |
314 | |
315 // Depending on oop/int put it in the right package | |
316 StackValue *sv = values->at(i); | |
317 assert(sv != NULL, "sanity check"); | |
318 if (sv->type() == T_OBJECT) { | |
319 *(oop *) addr = (sv->get_obj())(); | |
320 } else { // integer | |
321 *addr = sv->get_int(); | |
322 } | |
323 } | |
324 } | |
325 | |
326 StackValueCollection* interpretedVFrame::expressions() const { | |
327 int length = fr().interpreter_frame_expression_stack_size(); | |
328 if (method()->is_native()) { | |
329 // If the method is native, there is no expression stack | |
330 length = 0; | |
331 } | |
332 | |
333 int nof_locals = method()->max_locals(); | |
334 StackValueCollection* result = new StackValueCollection(length); | |
335 | |
1506 | 336 InterpreterOopMap oop_mask; |
337 // Get oopmap describing oops and int for current bci | |
338 if (TraceDeoptimization && Verbose) { | |
339 methodHandle m_h(method()); | |
340 OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); | |
0 | 341 } else { |
1506 | 342 method()->mask_for(bci(), &oop_mask); |
343 } | |
344 // handle expressions | |
345 for(int i=0; i < length; i++) { | |
346 // Find stack location | |
347 intptr_t *addr = fr().interpreter_frame_expression_stack_at(i); | |
0 | 348 |
1506 | 349 // Depending on oop/int put it in the right package |
350 StackValue *sv; | |
351 if (oop_mask.is_oop(i + nof_locals)) { | |
352 // oop value | |
353 Handle h(*(oop *)addr); | |
354 sv = new StackValue(h); | |
355 } else { | |
356 // integer | |
357 sv = new StackValue(*addr); | |
0 | 358 } |
1506 | 359 assert(sv != NULL, "sanity check"); |
360 result->add(sv); | |
0 | 361 } |
362 return result; | |
363 } | |
364 | |
365 | |
366 // ------------- cChunk -------------- | |
367 | |
368 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread) | |
369 : externalVFrame(fr, reg_map, thread) {} | |
370 | |
371 | |
372 void vframeStreamCommon::found_bad_method_frame() { | |
373 // 6379830 Cut point for an assertion that occasionally fires when | |
374 // we are using the performance analyzer. | |
375 // Disable this assert when testing the analyzer with fastdebug. | |
376 // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number) | |
377 assert(false, "invalid bci or invalid scope desc"); | |
378 } | |
379 | |
380 // top-frame will be skipped | |
381 vframeStream::vframeStream(JavaThread* thread, frame top_frame, | |
382 bool stop_at_java_call_stub) : vframeStreamCommon(thread) { | |
383 _stop_at_java_call_stub = stop_at_java_call_stub; | |
384 | |
385 // skip top frame, as it may not be at safepoint | |
386 _frame = top_frame.sender(&_reg_map); | |
387 while (!fill_from_frame()) { | |
388 _frame = _frame.sender(&_reg_map); | |
389 } | |
390 } | |
391 | |
392 | |
393 // Step back n frames, skip any pseudo frames in between. | |
394 // This function is used in Class.forName, Class.newInstance, Method.Invoke, | |
395 // AccessController.doPrivileged. | |
396 void vframeStreamCommon::security_get_caller_frame(int depth) { | |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
397 assert(depth >= 0, err_msg("invalid depth: %d", depth)); |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
398 for (int n = 0; !at_end(); security_next()) { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
399 if (!method()->is_ignored_by_security_stack_walk()) { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
400 if (n == depth) { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
401 // We have reached the desired depth; return. |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
402 return; |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
403 } |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
404 n++; // this is a non-skipped frame; count it against the depth |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
405 } |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
406 } |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
407 // NOTE: At this point there were not enough frames on the stack |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
408 // to walk to depth. Callers of this method have to check for at_end. |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
409 } |
0 | 410 |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
411 |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
412 void vframeStreamCommon::security_next() { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
413 if (method()->is_prefixed_native()) { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
414 skip_prefixed_method_and_wrappers(); // calls next() |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
415 } else { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
6983
diff
changeset
|
416 next(); |
0 | 417 } |
418 } | |
419 | |
420 | |
421 void vframeStreamCommon::skip_prefixed_method_and_wrappers() { | |
422 ResourceMark rm; | |
423 HandleMark hm; | |
424 | |
425 int method_prefix_count = 0; | |
426 char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count); | |
427 KlassHandle prefixed_klass(method()->method_holder()); | |
428 const char* prefixed_name = method()->name()->as_C_string(); | |
429 size_t prefixed_name_len = strlen(prefixed_name); | |
430 int prefix_index = method_prefix_count-1; | |
431 | |
432 while (!at_end()) { | |
433 next(); | |
434 if (method()->method_holder() != prefixed_klass()) { | |
435 break; // classes don't match, can't be a wrapper | |
436 } | |
437 const char* name = method()->name()->as_C_string(); | |
438 size_t name_len = strlen(name); | |
439 size_t prefix_len = prefixed_name_len - name_len; | |
440 if (prefix_len <= 0 || strcmp(name, prefixed_name + prefix_len) != 0) { | |
441 break; // prefixed name isn't prefixed version of method name, can't be a wrapper | |
442 } | |
443 for (; prefix_index >= 0; --prefix_index) { | |
444 const char* possible_prefix = method_prefixes[prefix_index]; | |
445 size_t possible_prefix_len = strlen(possible_prefix); | |
446 if (possible_prefix_len == prefix_len && | |
447 strncmp(possible_prefix, prefixed_name, prefix_len) == 0) { | |
448 break; // matching prefix found | |
449 } | |
450 } | |
451 if (prefix_index < 0) { | |
452 break; // didn't find the prefix, can't be a wrapper | |
453 } | |
454 prefixed_name = name; | |
455 prefixed_name_len = name_len; | |
456 } | |
457 } | |
458 | |
459 | |
460 void vframeStreamCommon::skip_reflection_related_frames() { | |
461 while (!at_end() && | |
462 (JDK_Version::is_gte_jdk14x_version() && UseNewReflection && | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6725
diff
changeset
|
463 (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) || |
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6725
diff
changeset
|
464 method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass())))) { |
0 | 465 next(); |
466 } | |
467 } | |
468 | |
469 | |
470 #ifndef PRODUCT | |
471 void vframe::print() { | |
472 if (WizardMode) _fr.print_value_on(tty,NULL); | |
473 } | |
474 | |
475 | |
476 void vframe::print_value() const { | |
477 ((vframe*)this)->print(); | |
478 } | |
479 | |
480 | |
481 void entryVFrame::print_value() const { | |
482 ((entryVFrame*)this)->print(); | |
483 } | |
484 | |
485 void entryVFrame::print() { | |
486 vframe::print(); | |
487 tty->print_cr("C Chunk inbetween Java"); | |
488 tty->print_cr("C link " INTPTR_FORMAT, _fr.link()); | |
489 } | |
490 | |
491 | |
492 // ------------- javaVFrame -------------- | |
493 | |
494 static void print_stack_values(const char* title, StackValueCollection* values) { | |
495 if (values->is_empty()) return; | |
496 tty->print_cr("\t%s:", title); | |
497 values->print(); | |
498 } | |
499 | |
500 | |
501 void javaVFrame::print() { | |
502 ResourceMark rm; | |
503 vframe::print(); | |
504 tty->print("\t"); | |
505 method()->print_value(); | |
506 tty->cr(); | |
507 tty->print_cr("\tbci: %d", bci()); | |
508 | |
509 print_stack_values("locals", locals()); | |
510 print_stack_values("expressions", expressions()); | |
511 | |
512 GrowableArray<MonitorInfo*>* list = monitors(); | |
513 if (list->is_empty()) return; | |
514 tty->print_cr("\tmonitor list:"); | |
515 for (int index = (list->length()-1); index >= 0; index--) { | |
516 MonitorInfo* monitor = list->at(index); | |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
517 tty->print("\t obj\t"); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
518 if (monitor->owner_is_scalar_replaced()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
519 Klass* k = java_lang_Class::as_Klass(monitor->owner_klass()); |
818
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
520 tty->print("( is scalar replaced %s)", k->external_name()); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
521 } else if (monitor->owner() == NULL) { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
522 tty->print("( null )"); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
523 } else { |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
524 monitor->owner()->print_value(); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
525 tty->print("(" INTPTR_FORMAT ")", (address)monitor->owner()); |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
526 } |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
527 if (monitor->eliminated() && is_compiled_frame()) |
b109e761e927
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
793
diff
changeset
|
528 tty->print(" ( lock is eliminated )"); |
0 | 529 tty->cr(); |
530 tty->print("\t "); | |
531 monitor->lock()->print_on(tty); | |
532 tty->cr(); | |
533 } | |
534 } | |
535 | |
536 | |
537 void javaVFrame::print_value() const { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
538 Method* m = method(); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6725
diff
changeset
|
539 InstanceKlass* k = m->method_holder(); |
0 | 540 tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")", |
541 _fr.sp(), _fr.unextended_sp(), _fr.fp(), _fr.pc()); | |
6983 | 542 tty->print("%s.%s", k->internal_name(), m->name()->as_C_string()); |
0 | 543 |
544 if (!m->is_native()) { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6725
diff
changeset
|
545 Symbol* source_name = k->source_file_name(); |
0 | 546 int line_number = m->line_number_from_bci(bci()); |
547 if (source_name != NULL && (line_number != -1)) { | |
548 tty->print("(%s:%d)", source_name->as_C_string(), line_number); | |
549 } | |
550 } else { | |
551 tty->print("(Native Method)"); | |
552 } | |
553 // Check frame size and print warning if it looks suspiciously large | |
554 if (fr().sp() != NULL) { | |
793
eacd97c88873
6848466: frame::frame_size() assertion failure with -XX:+DebugDeoptimization
cfang
parents:
196
diff
changeset
|
555 RegisterMap map = *register_map(); |
eacd97c88873
6848466: frame::frame_size() assertion failure with -XX:+DebugDeoptimization
cfang
parents:
196
diff
changeset
|
556 uint size = fr().frame_size(&map); |
0 | 557 #ifdef _LP64 |
558 if (size > 8*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); | |
559 #else | |
560 if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); | |
561 #endif | |
562 } | |
563 } | |
564 | |
565 | |
566 bool javaVFrame::structural_compare(javaVFrame* other) { | |
567 // Check static part | |
568 if (method() != other->method()) return false; | |
569 if (bci() != other->bci()) return false; | |
570 | |
571 // Check locals | |
572 StackValueCollection *locs = locals(); | |
573 StackValueCollection *other_locs = other->locals(); | |
574 assert(locs->size() == other_locs->size(), "sanity check"); | |
575 int i; | |
576 for(i = 0; i < locs->size(); i++) { | |
577 // it might happen the compiler reports a conflict and | |
578 // the interpreter reports a bogus int. | |
579 if ( is_compiled_frame() && locs->at(i)->type() == T_CONFLICT) continue; | |
580 if (other->is_compiled_frame() && other_locs->at(i)->type() == T_CONFLICT) continue; | |
581 | |
582 if (!locs->at(i)->equal(other_locs->at(i))) | |
583 return false; | |
584 } | |
585 | |
586 // Check expressions | |
587 StackValueCollection* exprs = expressions(); | |
588 StackValueCollection* other_exprs = other->expressions(); | |
589 assert(exprs->size() == other_exprs->size(), "sanity check"); | |
590 for(i = 0; i < exprs->size(); i++) { | |
591 if (!exprs->at(i)->equal(other_exprs->at(i))) | |
592 return false; | |
593 } | |
594 | |
595 return true; | |
596 } | |
597 | |
598 | |
599 void javaVFrame::print_activation(int index) const { | |
600 // frame number and method | |
601 tty->print("%2d - ", index); | |
602 ((vframe*)this)->print_value(); | |
603 tty->cr(); | |
604 | |
605 if (WizardMode) { | |
606 ((vframe*)this)->print(); | |
607 tty->cr(); | |
608 } | |
609 } | |
610 | |
611 | |
612 void javaVFrame::verify() const { | |
613 } | |
614 | |
615 | |
616 void interpretedVFrame::verify() const { | |
617 } | |
618 | |
619 | |
620 // ------------- externalVFrame -------------- | |
621 | |
622 void externalVFrame::print() { | |
623 _fr.print_value_on(tty,NULL); | |
624 } | |
625 | |
626 | |
627 void externalVFrame::print_value() const { | |
628 ((vframe*)this)->print(); | |
629 } | |
630 #endif // PRODUCT |