annotate src/share/vm/prims/jvmtiThreadState.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children af739d5ab23c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1213
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1213
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1213
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: 1213
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_PRIMS_JVMTITHREADSTATE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_PRIMS_JVMTITHREADSTATE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "jvmtifiles/jvmti.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "prims/jvmtiEventController.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/thread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "utilities/growableArray.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Forward Declarations
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class JvmtiEnvBase;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class JvmtiEnvThreadState;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class JvmtiDynamicCodeEventCollector;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 enum JvmtiClassLoadKind {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 jvmti_class_load_kind_load = 100,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 jvmti_class_load_kind_retransform,
a61af66fc99e Initial load
duke
parents:
diff changeset
46 jvmti_class_load_kind_redefine
a61af66fc99e Initial load
duke
parents:
diff changeset
47 };
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 ///////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // class JvmtiEnvThreadStateIterator
a61af66fc99e Initial load
duke
parents:
diff changeset
52 //
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // The only safe means of iterating through the JvmtiEnvThreadStates
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // in a JvmtiThreadState.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Note that this iteratation includes invalid environments pending
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // deallocation -- in fact, some uses depend on this behavior.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 //
a61af66fc99e Initial load
duke
parents:
diff changeset
58 class JvmtiEnvThreadStateIterator : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 JvmtiThreadState* state;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
62 JvmtiEnvThreadStateIterator(JvmtiThreadState* thread_state);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 ~JvmtiEnvThreadStateIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 JvmtiEnvThreadState* first();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 JvmtiEnvThreadState* next(JvmtiEnvThreadState* ets);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 };
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 ///////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // class JvmtiThreadState
a61af66fc99e Initial load
duke
parents:
diff changeset
72 //
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // The Jvmti state for each thread (across all JvmtiEnv):
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // 1. Local table of enabled events.
a61af66fc99e Initial load
duke
parents:
diff changeset
75 class JvmtiThreadState : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 friend class JvmtiEnv;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 JavaThread *_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 bool _exception_detected;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 bool _exception_caught;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 bool _hide_single_stepping;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 bool _pending_step_for_popframe;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 bool _pending_step_for_earlyret;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int _hide_level;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Used to send class being redefined/retransformed and kind of transform
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // info to the class file load hook event handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
88 KlassHandle *_class_being_redefined;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 JvmtiClassLoadKind _class_load_kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // This is only valid when is_interp_only_mode() returns true
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int _cur_stack_depth;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 JvmtiThreadEventEnable _thread_event_enable;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // for support of JvmtiEnvThreadState
a61af66fc99e Initial load
duke
parents:
diff changeset
97 JvmtiEnvThreadState* _head_env_thread_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // doubly-linked linear list of active thread state
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // needed in order to iterate the list without holding Threads_lock
a61af66fc99e Initial load
duke
parents:
diff changeset
101 static JvmtiThreadState *_head;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 JvmtiThreadState *_next;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 JvmtiThreadState *_prev;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // holds the current dynamic code event collector, NULL if no event collector in use
a61af66fc99e Initial load
duke
parents:
diff changeset
106 JvmtiDynamicCodeEventCollector* _dynamic_code_event_collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // holds the current vm object alloc event collector, NULL if no event collector in use
a61af66fc99e Initial load
duke
parents:
diff changeset
108 JvmtiVMObjectAllocEventCollector* _vm_object_alloc_event_collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Should only be created by factory methods
a61af66fc99e Initial load
duke
parents:
diff changeset
111 JvmtiThreadState(JavaThread *thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 friend class JvmtiEnvThreadStateIterator;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 inline JvmtiEnvThreadState* head_env_thread_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 inline void set_head_env_thread_state(JvmtiEnvThreadState* ets);
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
118 ~JvmtiThreadState();
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // is event_type enabled and usable for this thread in any enviroments?
a61af66fc99e Initial load
duke
parents:
diff changeset
121 bool is_enabled(jvmtiEvent event_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return _thread_event_enable.is_enabled(event_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 JvmtiThreadEventEnable *thread_event_enable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return &_thread_event_enable;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Must only be called in situations where the state is for the current thread and
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // the environment can not go away. To be safe, the returned JvmtiEnvThreadState
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // must be used in such a way as there can be no intervening safepoints.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 inline JvmtiEnvThreadState* env_thread_state(JvmtiEnvBase *env);
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 static void periodic_clean_up();
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void add_env(JvmtiEnvBase *env);
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Used by the interpreter for fullspeed debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
139 bool is_interp_only_mode() { return _thread->is_interp_only_mode(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void enter_interp_only_mode();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 void leave_interp_only_mode();
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // access to the linked list of all JVMTI thread states
a61af66fc99e Initial load
duke
parents:
diff changeset
144 static JvmtiThreadState *first() {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return _head;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 JvmtiThreadState *next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Current stack depth is only valid when is_interp_only_mode() returns true.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // These functions should only be called at a safepoint - usually called from same thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Returns the number of Java activations on the stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 int cur_stack_depth();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 void invalidate_cur_stack_depth();
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void incr_cur_stack_depth();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void decr_cur_stack_depth();
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 int count_frames();
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 inline JavaThread *get_thread() { return _thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 inline bool is_exception_detected() { return _exception_detected; }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 inline bool is_exception_caught() { return _exception_caught; }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 inline void set_exception_detected() { _exception_detected = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 _exception_caught = false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 inline void set_exception_caught() { _exception_caught = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 _exception_detected = false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 inline void clear_hide_single_stepping() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (_hide_level > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 _hide_level--;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 assert(_hide_single_stepping, "hide_single_stepping is out of phase");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 _hide_single_stepping = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 inline bool hide_single_stepping() { return _hide_single_stepping; }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 inline void set_hide_single_stepping() {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (_hide_single_stepping) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 _hide_level++;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 assert(_hide_level == 0, "hide_level is out of phase");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _hide_single_stepping = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // Step pending flag is set when PopFrame is called and it is cleared
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // when step for the Pop Frame is completed.
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // This logic is used to distinguish b/w step for pop frame and repeat step.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 void set_pending_step_for_popframe() { _pending_step_for_popframe = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 void clr_pending_step_for_popframe() { _pending_step_for_popframe = false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 bool is_pending_step_for_popframe() { return _pending_step_for_popframe; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 void process_pending_step_for_popframe();
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Step pending flag is set when ForceEarlyReturn is called and it is cleared
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // when step for the ForceEarlyReturn is completed.
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // This logic is used to distinguish b/w step for early return and repeat step.
a61af66fc99e Initial load
duke
parents:
diff changeset
200 void set_pending_step_for_earlyret() { _pending_step_for_earlyret = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 void clr_pending_step_for_earlyret() { _pending_step_for_earlyret = false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 bool is_pending_step_for_earlyret() { return _pending_step_for_earlyret; }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void process_pending_step_for_earlyret();
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Setter and getter method is used to send redefined class info
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // when class file load hook event is posted.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // It is set while loading redefined class and cleared before the
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // class file load hook event is posted.
a61af66fc99e Initial load
duke
parents:
diff changeset
209 inline void set_class_being_redefined(KlassHandle *h_class, JvmtiClassLoadKind kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 _class_being_redefined = h_class;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 _class_load_kind = kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 inline void clear_class_being_redefined() {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 _class_being_redefined = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 _class_load_kind = jvmti_class_load_kind_load;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 inline KlassHandle *get_class_being_redefined() {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return _class_being_redefined;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 inline JvmtiClassLoadKind get_class_load_kind() {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 return _class_load_kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // RedefineClasses support
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // The bug 6214132 caused the verification to fail.
a61af66fc99e Initial load
duke
parents:
diff changeset
229 //
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Below is the detailed description of the fix approach taken:
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // 1. What's done in RedefineClasses() before verification:
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // a) A reference to the class being redefined (_the_class) and a
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // reference to new version of the class (_scratch_class) are
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // saved here for use during the bytecode verification phase of
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // RedefineClasses. See RedefineVerifyMark for how these fields
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // are managed.
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // b) The _java_mirror field from _the_class is copied to the
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // _java_mirror field in _scratch_class. This means that a jclass
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // returned for _the_class or _scratch_class will refer to the
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // same Java mirror. The verifier will see the "one true mirror"
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // for the class being verified.
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // 2. What is done at verification:
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // When the verifier makes calls into the VM to ask questions about
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // the class being verified, it will pass the jclass to JVM_* functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // The jclass is always pointing to the mirror of _the_class.
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // ~28 JVM_* functions called by the verifier for the information
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // about CP entries and klass structure should check the jvmtiThreadState
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // info about equivalent klass versions and use it to replace a klassOop
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // of _the_class with a klassOop of _scratch_class. The function
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // class_to_verify_considering_redefinition() must be called for it.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 //
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // Note again, that this redirection happens only for the verifier thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Other threads have very small overhead by checking the existence
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // of the jvmtiThreadSate and the information about klasses equivalence.
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // No JNI functions need to be changed, they don't reference the klass guts.
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // The JavaThread pointer is already available in all JVM_* functions
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // used by the verifier, so there is no extra performance issue with it.
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
260 KlassHandle *_the_class_for_redefinition_verification;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 KlassHandle *_scratch_class_for_redefinition_verification;
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
264 inline void set_class_versions_map(KlassHandle *the_class,
a61af66fc99e Initial load
duke
parents:
diff changeset
265 KlassHandle *scratch_class) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 _the_class_for_redefinition_verification = the_class;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 _scratch_class_for_redefinition_verification = scratch_class;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 inline void clear_class_versions_map() { set_class_versions_map(NULL, NULL); }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 static inline
a61af66fc99e Initial load
duke
parents:
diff changeset
273 klassOop class_to_verify_considering_redefinition(klassOop klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 JavaThread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 JvmtiThreadState *state = thread->jvmti_thread_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
276 if (state != NULL && state->_the_class_for_redefinition_verification != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if ((*(state->_the_class_for_redefinition_verification))() == klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 klass = (*(state->_scratch_class_for_redefinition_verification))();
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281 return klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // Todo: get rid of this!
a61af66fc99e Initial load
duke
parents:
diff changeset
285 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
286 bool _debuggable;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Should the thread be enumerated by jvmtiInternal::GetAllThreads?
a61af66fc99e Initial load
duke
parents:
diff changeset
289 bool is_debuggable() { return _debuggable; }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // If a thread cannot be suspended (has no valid last_java_frame) then it gets marked !debuggable
a61af66fc99e Initial load
duke
parents:
diff changeset
291 void set_debuggable(bool debuggable) { _debuggable = debuggable; }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 bool may_be_walked();
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // Thread local event collector setter and getter methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
298 JvmtiDynamicCodeEventCollector* get_dynamic_code_event_collector() {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return _dynamic_code_event_collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 JvmtiVMObjectAllocEventCollector* get_vm_object_alloc_event_collector() {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 return _vm_object_alloc_event_collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 void set_dynamic_code_event_collector(JvmtiDynamicCodeEventCollector* collector) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 _dynamic_code_event_collector = collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307 void set_vm_object_alloc_event_collector(JvmtiVMObjectAllocEventCollector* collector) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 _vm_object_alloc_event_collector = collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 //
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Frame routines
a61af66fc99e Initial load
duke
parents:
diff changeset
314 //
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // true when the thread was suspended with a pointer to the last Java frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
319 bool has_last_frame() { return _thread->has_last_Java_frame(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 void update_for_pop_top_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // already holding JvmtiThreadState_lock - retrieve or create JvmtiThreadState
609
ea20d7ce26b0 6800721: 3/4 JavaThread::jvmti_thread_state() and JvmtiThreadState::state_for() robustness
dcubed
parents: 608
diff changeset
324 // Can return NULL if JavaThread is exiting.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
325 inline static JvmtiThreadState *state_for_while_locked(JavaThread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 assert(JvmtiThreadState_lock->is_locked(), "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 JvmtiThreadState *state = thread->jvmti_thread_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
329 if (state == NULL) {
608
0386097d43d8 6700114: 3/4 Assertion (_thread->get_interp_only_mode() == 1,"leaving interp only when mode not one")
dcubed
parents: 0
diff changeset
330 if (thread->is_exiting()) {
0386097d43d8 6700114: 3/4 Assertion (_thread->get_interp_only_mode() == 1,"leaving interp only when mode not one")
dcubed
parents: 0
diff changeset
331 // don't add a JvmtiThreadState to a thread that is exiting
0386097d43d8 6700114: 3/4 Assertion (_thread->get_interp_only_mode() == 1,"leaving interp only when mode not one")
dcubed
parents: 0
diff changeset
332 return NULL;
0386097d43d8 6700114: 3/4 Assertion (_thread->get_interp_only_mode() == 1,"leaving interp only when mode not one")
dcubed
parents: 0
diff changeset
333 }
0386097d43d8 6700114: 3/4 Assertion (_thread->get_interp_only_mode() == 1,"leaving interp only when mode not one")
dcubed
parents: 0
diff changeset
334
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335 state = new JvmtiThreadState(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
337 return state;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // retrieve or create JvmtiThreadState
609
ea20d7ce26b0 6800721: 3/4 JavaThread::jvmti_thread_state() and JvmtiThreadState::state_for() robustness
dcubed
parents: 608
diff changeset
341 // Can return NULL if JavaThread is exiting.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
342 inline static JvmtiThreadState *state_for(JavaThread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 JvmtiThreadState *state = thread->jvmti_thread_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if (state == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 MutexLocker mu(JvmtiThreadState_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // check again with the lock held
a61af66fc99e Initial load
duke
parents:
diff changeset
347 state = state_for_while_locked(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351 return state;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // JVMTI ForceEarlyReturn support
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // This is set to earlyret_pending to signal that top Java frame
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // should be returned immediately
a61af66fc99e Initial load
duke
parents:
diff changeset
358 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
359 int _earlyret_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 TosState _earlyret_tos;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 jvalue _earlyret_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 oop _earlyret_oop; // Used to return an oop result into Java code from
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // ForceEarlyReturnObject, GC-preserved
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // Setting and clearing earlyret_state
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // earlyret_pending indicates that a ForceEarlyReturn() has been
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // requested and not yet been completed.
a61af66fc99e Initial load
duke
parents:
diff changeset
368 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
369 enum EarlyretState {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 earlyret_inactive = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
371 earlyret_pending = 1
a61af66fc99e Initial load
duke
parents:
diff changeset
372 };
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 void set_earlyret_pending(void) { _earlyret_state = earlyret_pending; }
a61af66fc99e Initial load
duke
parents:
diff changeset
375 void clr_earlyret_pending(void) { _earlyret_state = earlyret_inactive; }
a61af66fc99e Initial load
duke
parents:
diff changeset
376 bool is_earlyret_pending(void) { return (_earlyret_state == earlyret_pending); }
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 TosState earlyret_tos() { return _earlyret_tos; }
a61af66fc99e Initial load
duke
parents:
diff changeset
379 oop earlyret_oop() const { return _earlyret_oop; }
a61af66fc99e Initial load
duke
parents:
diff changeset
380 void set_earlyret_oop (oop x) { _earlyret_oop = x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 jvalue earlyret_value() { return _earlyret_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
382 void set_earlyret_value(jvalue val, TosState tos) { _earlyret_tos = tos; _earlyret_value = val; }
a61af66fc99e Initial load
duke
parents:
diff changeset
383 void clr_earlyret_value() { _earlyret_tos = ilgl; _earlyret_value.j = 0L; }
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 static ByteSize earlyret_state_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_state); }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 static ByteSize earlyret_tos_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_tos); }
a61af66fc99e Initial load
duke
parents:
diff changeset
387 static ByteSize earlyret_oop_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_oop); }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 static ByteSize earlyret_value_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 void oops_do(OopClosure* f); // GC support
1213
6deeaebad47a 6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents: 609
diff changeset
391
6deeaebad47a 6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents: 609
diff changeset
392 public:
6deeaebad47a 6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents: 609
diff changeset
393 void set_should_post_on_exceptions(bool val) { _thread->set_should_post_on_exceptions_flag(val ? JNI_TRUE : JNI_FALSE); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
394 };
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 class RedefineVerifyMark : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
398 JvmtiThreadState *_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
401 RedefineVerifyMark(KlassHandle *the_class, KlassHandle *scratch_class,
a61af66fc99e Initial load
duke
parents:
diff changeset
402 JvmtiThreadState *state) : _state(state)
a61af66fc99e Initial load
duke
parents:
diff changeset
403 {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 _state->set_class_versions_map(the_class, scratch_class);
a61af66fc99e Initial load
duke
parents:
diff changeset
405 (*scratch_class)->set_java_mirror((*the_class)->java_mirror());
a61af66fc99e Initial load
duke
parents:
diff changeset
406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 ~RedefineVerifyMark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 _state->clear_class_versions_map();
a61af66fc99e Initial load
duke
parents:
diff changeset
410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
411 };
a61af66fc99e Initial load
duke
parents:
diff changeset
412
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
413 #endif // SHARE_VM_PRIMS_JVMTITHREADSTATE_HPP