author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
34253 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49480
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
34253 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49480
diff
changeset
|
26 |
#ifndef SHARE_PRIMS_STACKWALK_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49480
diff
changeset
|
27 |
#define SHARE_PRIMS_STACKWALK_HPP |
34253 | 28 |
|
29 |
#include "oops/oop.hpp" |
|
30 |
#include "runtime/vframe.hpp" |
|
31 |
||
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
32 |
// BaseFrameStream is an abstract base class for encapsulating the VM-side |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
33 |
// implementation of the StackWalker API. There are two concrete subclasses: |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
34 |
// - JavaFrameStream: |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
35 |
// -based on vframeStream; used in most instances |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
36 |
// - LiveFrameStream: |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
37 |
// -based on javaVFrame; used for retrieving locals/monitors/operands for |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
38 |
// LiveStackFrame |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
39 |
class BaseFrameStream : public StackObj { |
34253 | 40 |
private: |
41 |
enum { |
|
42 |
magic_pos = 0 |
|
43 |
}; |
|
44 |
||
45 |
JavaThread* _thread; |
|
46 |
jlong _anchor; |
|
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
47 |
protected: |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
43677
diff
changeset
|
48 |
void fill_stackframe(Handle stackFrame, const methodHandle& method, TRAPS); |
34253 | 49 |
public: |
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
50 |
BaseFrameStream(JavaThread* thread) : _thread(thread), _anchor(0L) {} |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
51 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
52 |
virtual void next()=0; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
53 |
virtual bool at_end()=0; |
34253 | 54 |
|
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
55 |
virtual Method* method()=0; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
56 |
virtual int bci()=0; |
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
57 |
|
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
58 |
virtual void fill_frame(int index, objArrayHandle frames_array, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
59 |
const methodHandle& method, TRAPS)=0; |
34253 | 60 |
|
37438 | 61 |
void setup_magic_on_entry(objArrayHandle frames_array); |
62 |
bool check_magic(objArrayHandle frames_array); |
|
63 |
bool cleanup_magic_on_exit(objArrayHandle frames_array); |
|
34253 | 64 |
|
37438 | 65 |
bool is_valid_in(Thread* thread, objArrayHandle frames_array) { |
66 |
return (_thread == thread && check_magic(frames_array)); |
|
34253 | 67 |
} |
68 |
||
69 |
jlong address_value() { |
|
70 |
return (jlong) castable_address(this); |
|
71 |
} |
|
72 |
||
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
73 |
static BaseFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
74 |
}; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
75 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
76 |
class JavaFrameStream : public BaseFrameStream { |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
77 |
private: |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
78 |
vframeStream _vfst; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
79 |
bool _need_method_info; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
80 |
public: |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
81 |
JavaFrameStream(JavaThread* thread, int mode); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
82 |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
47216
diff
changeset
|
83 |
void next(); |
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
84 |
bool at_end() { return _vfst.at_end(); } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
85 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
86 |
Method* method() { return _vfst.method(); } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
87 |
int bci() { return _vfst.bci(); } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
88 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
89 |
void fill_frame(int index, objArrayHandle frames_array, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
90 |
const methodHandle& method, TRAPS); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
91 |
}; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
92 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
93 |
class LiveFrameStream : public BaseFrameStream { |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
94 |
private: |
43677
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
95 |
enum { |
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
96 |
MODE_INTERPRETED = 0x01, |
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
97 |
MODE_COMPILED = 0x02 |
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
98 |
}; |
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
99 |
|
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
100 |
javaVFrame* _jvf; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
101 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
102 |
void fill_live_stackframe(Handle stackFrame, const methodHandle& method, TRAPS); |
43677
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
103 |
static oop create_primitive_slot_instance(StackValueCollection* values, |
5228814c1da2
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
41280
diff
changeset
|
104 |
int i, BasicType type, TRAPS); |
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
105 |
static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
106 |
TRAPS); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
107 |
static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
108 |
public: |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
109 |
LiveFrameStream(JavaThread* thread, RegisterMap* rm) : BaseFrameStream(thread) { |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
110 |
_jvf = thread->last_java_vframe(rm); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
111 |
} |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
112 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
113 |
void next() { _jvf = _jvf->java_sender(); } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
114 |
bool at_end() { return _jvf == NULL; } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
115 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
116 |
Method* method() { return _jvf->method(); } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
117 |
int bci() { return _jvf->bci(); } |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
118 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
119 |
void fill_frame(int index, objArrayHandle frames_array, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
120 |
const methodHandle& method, TRAPS); |
34253 | 121 |
}; |
122 |
||
123 |
class StackWalk : public AllStatic { |
|
124 |
private: |
|
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
125 |
static int fill_in_frames(jlong mode, BaseFrameStream& stream, |
34253 | 126 |
int max_nframes, int start_index, |
127 |
objArrayHandle frames_array, |
|
128 |
int& end_index, TRAPS); |
|
129 |
||
41095
97cca074c2be
8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method
mchung
parents:
40001
diff
changeset
|
130 |
static inline bool get_caller_class(int mode) { |
97cca074c2be
8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method
mchung
parents:
40001
diff
changeset
|
131 |
return (mode & JVM_STACKWALK_GET_CALLER_CLASS) != 0; |
97cca074c2be
8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method
mchung
parents:
40001
diff
changeset
|
132 |
} |
34253 | 133 |
static inline bool skip_hidden_frames(int mode) { |
134 |
return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0; |
|
135 |
} |
|
136 |
static inline bool live_frame_info(int mode) { |
|
137 |
return (mode & JVM_STACKWALK_FILL_LIVE_STACK_FRAMES) != 0; |
|
138 |
} |
|
139 |
||
140 |
public: |
|
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
141 |
static inline bool need_method_info(int mode) { |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
142 |
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0; |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
143 |
} |
37438 | 144 |
static inline bool use_frames_array(int mode) { |
145 |
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0; |
|
146 |
} |
|
34253 | 147 |
static oop walk(Handle stackStream, jlong mode, |
148 |
int skip_frames, int frame_count, int start_index, |
|
149 |
objArrayHandle frames_array, |
|
150 |
TRAPS); |
|
151 |
||
41280
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
152 |
static oop fetchFirstBatch(BaseFrameStream& stream, Handle stackStream, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
153 |
jlong mode, int skip_frames, int frame_count, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
154 |
int start_index, objArrayHandle frames_array, TRAPS); |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
155 |
|
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
156 |
static jint fetchNextBatch(Handle stackStream, jlong mode, jlong magic, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
157 |
int frame_count, int start_index, |
74b314ad1e9a
8165372: StackWalker performance regression following JDK-8147039
bchristi
parents:
41095
diff
changeset
|
158 |
objArrayHandle frames_array, TRAPS); |
34253 | 159 |
}; |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49480
diff
changeset
|
160 |
#endif // SHARE_PRIMS_STACKWALK_HPP |