author | vromero |
Mon, 08 Oct 2018 06:52:41 -0700 | |
changeset 52038 | 957de5be48bc |
parent 49364 | 601146c66cad |
child 52445 | a1eb4f1b94c1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2137
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2137
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2137
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_PRIMS_JVMTIIMPL_HPP |
26 |
#define SHARE_VM_PRIMS_JVMTIIMPL_HPP |
|
27 |
||
28 |
#include "classfile/systemDictionary.hpp" |
|
29 |
#include "jvmtifiles/jvmti.h" |
|
30 |
#include "oops/objArrayOop.hpp" |
|
31 |
#include "prims/jvmtiEnvThreadState.hpp" |
|
32 |
#include "prims/jvmtiEventController.hpp" |
|
33 |
#include "prims/jvmtiTrace.hpp" |
|
34 |
#include "prims/jvmtiUtil.hpp" |
|
35 |
#include "runtime/stackValueCollection.hpp" |
|
36 |
#include "runtime/vm_operations.hpp" |
|
37992 | 37 |
#include "utilities/ostream.hpp" |
7397 | 38 |
|
1 | 39 |
// |
40 |
// Forward Declarations |
|
41 |
// |
|
42 |
||
43 |
class JvmtiBreakpoint; |
|
44 |
class JvmtiBreakpoints; |
|
45 |
||
46 |
||
47 |
/////////////////////////////////////////////////////////////// |
|
48 |
// |
|
49 |
// class GrowableCache, GrowableElement |
|
50 |
// Used by : JvmtiBreakpointCache |
|
51 |
// Used by JVMTI methods: none directly. |
|
52 |
// |
|
53 |
// GrowableCache is a permanent CHeap growable array of <GrowableElement *> |
|
54 |
// |
|
55 |
// In addition, the GrowableCache maintains a NULL terminated cache array of type address |
|
56 |
// that's created from the element array using the function: |
|
57 |
// address GrowableElement::getCacheValue(). |
|
58 |
// |
|
59 |
// Whenever the GrowableArray changes size, the cache array gets recomputed into a new C_HEAP allocated |
|
60 |
// block of memory. Additionally, every time the cache changes its position in memory, the |
|
61 |
// void (*_listener_fun)(void *this_obj, address* cache) |
|
62 |
// gets called with the cache's new address. This gives the user of the GrowableCache a callback |
|
63 |
// to update its pointer to the address cache. |
|
64 |
// |
|
65 |
||
13195 | 66 |
class GrowableElement : public CHeapObj<mtInternal> { |
1 | 67 |
public: |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46438
diff
changeset
|
68 |
virtual ~GrowableElement() {} |
1 | 69 |
virtual address getCacheValue() =0; |
70 |
virtual bool equals(GrowableElement* e) =0; |
|
71 |
virtual bool lessThan(GrowableElement *e)=0; |
|
72 |
virtual GrowableElement *clone() =0; |
|
73 |
virtual void oops_do(OopClosure* f) =0; |
|
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
74 |
virtual void metadata_do(void f(Metadata*)) =0; |
1 | 75 |
}; |
76 |
||
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
47216
diff
changeset
|
77 |
class GrowableCache { |
1 | 78 |
|
79 |
private: |
|
80 |
// Object pointer passed into cache & listener functions. |
|
81 |
void *_this_obj; |
|
82 |
||
83 |
// Array of elements in the collection |
|
84 |
GrowableArray<GrowableElement *> *_elements; |
|
85 |
||
86 |
// Parallel array of cached values |
|
87 |
address *_cache; |
|
88 |
||
89 |
// Listener for changes to the _cache field. |
|
90 |
// Called whenever the _cache field has it's value changed |
|
91 |
// (but NOT when cached elements are recomputed). |
|
92 |
void (*_listener_fun)(void *, address*); |
|
93 |
||
94 |
static bool equals(void *, GrowableElement *); |
|
95 |
||
96 |
// recache all elements after size change, notify listener |
|
97 |
void recache(); |
|
98 |
||
99 |
public: |
|
100 |
GrowableCache(); |
|
101 |
~GrowableCache(); |
|
102 |
||
103 |
void initialize(void *this_obj, void listener_fun(void *, address*) ); |
|
104 |
||
105 |
// number of elements in the collection |
|
106 |
int length(); |
|
107 |
// get the value of the index element in the collection |
|
108 |
GrowableElement* at(int index); |
|
109 |
// find the index of the element, -1 if it doesn't exist |
|
110 |
int find(GrowableElement* e); |
|
111 |
// append a copy of the element to the end of the collection, notify listener |
|
112 |
void append(GrowableElement* e); |
|
113 |
// insert a copy of the element using lessthan(), notify listener |
|
114 |
void insert(GrowableElement* e); |
|
115 |
// remove the element at index, notify listener |
|
116 |
void remove (int index); |
|
117 |
// clear out all elements and release all heap space, notify listener |
|
118 |
void clear(); |
|
119 |
// apply f to every element and update the cache |
|
120 |
void oops_do(OopClosure* f); |
|
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
121 |
// walk metadata to preserve for RedefineClasses |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
122 |
void metadata_do(void f(Metadata*)); |
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7896
diff
changeset
|
123 |
// update the cache after a full gc |
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7896
diff
changeset
|
124 |
void gc_epilogue(); |
1 | 125 |
}; |
126 |
||
127 |
||
128 |
/////////////////////////////////////////////////////////////// |
|
129 |
// |
|
130 |
// class JvmtiBreakpointCache |
|
131 |
// Used by : JvmtiBreakpoints |
|
132 |
// Used by JVMTI methods: none directly. |
|
133 |
// Note : typesafe wrapper for GrowableCache of JvmtiBreakpoint |
|
134 |
// |
|
135 |
||
13195 | 136 |
class JvmtiBreakpointCache : public CHeapObj<mtInternal> { |
1 | 137 |
|
138 |
private: |
|
139 |
GrowableCache _cache; |
|
140 |
||
141 |
public: |
|
142 |
JvmtiBreakpointCache() {} |
|
143 |
~JvmtiBreakpointCache() {} |
|
144 |
||
145 |
void initialize(void *this_obj, void listener_fun(void *, address*) ) { |
|
146 |
_cache.initialize(this_obj,listener_fun); |
|
147 |
} |
|
148 |
||
149 |
int length() { return _cache.length(); } |
|
150 |
JvmtiBreakpoint& at(int index) { return (JvmtiBreakpoint&) *(_cache.at(index)); } |
|
151 |
int find(JvmtiBreakpoint& e) { return _cache.find((GrowableElement *) &e); } |
|
152 |
void append(JvmtiBreakpoint& e) { _cache.append((GrowableElement *) &e); } |
|
153 |
void remove (int index) { _cache.remove(index); } |
|
154 |
void clear() { _cache.clear(); } |
|
155 |
void oops_do(OopClosure* f) { _cache.oops_do(f); } |
|
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
156 |
void metadata_do(void f(Metadata*)) { _cache.metadata_do(f); } |
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7896
diff
changeset
|
157 |
void gc_epilogue() { _cache.gc_epilogue(); } |
1 | 158 |
}; |
159 |
||
160 |
||
161 |
/////////////////////////////////////////////////////////////// |
|
162 |
// |
|
163 |
// class JvmtiBreakpoint |
|
164 |
// Used by : JvmtiBreakpoints |
|
165 |
// Used by JVMTI methods: SetBreakpoint, ClearBreakpoint, ClearAllBreakpoints |
|
166 |
// Note: Extends GrowableElement for use in a GrowableCache |
|
167 |
// |
|
168 |
// A JvmtiBreakpoint describes a location (class, method, bci) to break at. |
|
169 |
// |
|
170 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
171 |
typedef void (Method::*method_action)(int _bci); |
1 | 172 |
|
173 |
class JvmtiBreakpoint : public GrowableElement { |
|
174 |
private: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
175 |
Method* _method; |
1 | 176 |
int _bci; |
177 |
Bytecodes::Code _orig_bytecode; |
|
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
178 |
oop _class_holder; // keeps _method memory from being deallocated |
1 | 179 |
|
180 |
public: |
|
181 |
JvmtiBreakpoint(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
182 |
JvmtiBreakpoint(Method* m_method, jlocation location); |
1 | 183 |
bool equals(JvmtiBreakpoint& bp); |
184 |
bool lessThan(JvmtiBreakpoint &bp); |
|
185 |
void copy(JvmtiBreakpoint& bp); |
|
186 |
bool is_valid(); |
|
38091
d7e51f40ba2d
8154719: JvmtiBreakpoint rename method print() to print_on()
rehn
parents:
37992
diff
changeset
|
187 |
address getBcp() const; |
1 | 188 |
void each_method_version_do(method_action meth_act); |
189 |
void set(); |
|
190 |
void clear(); |
|
38091
d7e51f40ba2d
8154719: JvmtiBreakpoint rename method print() to print_on()
rehn
parents:
37992
diff
changeset
|
191 |
void print_on(outputStream* out) const; |
1 | 192 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
193 |
Method* method() { return _method; } |
1 | 194 |
|
195 |
// GrowableElement implementation |
|
196 |
address getCacheValue() { return getBcp(); } |
|
197 |
bool lessThan(GrowableElement* e) { Unimplemented(); return false; } |
|
198 |
bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); } |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
199 |
void oops_do(OopClosure* f) { |
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
200 |
// Mark the method loader as live so the Method* class loader doesn't get |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
201 |
// unloaded and Method* memory reclaimed. |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
202 |
f->do_oop(&_class_holder); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
203 |
} |
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
204 |
void metadata_do(void f(Metadata*)) { |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
205 |
// walk metadata to preserve for RedefineClasses |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
206 |
f(_method); |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
207 |
} |
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
208 |
|
1 | 209 |
GrowableElement *clone() { |
210 |
JvmtiBreakpoint *bp = new JvmtiBreakpoint(); |
|
211 |
bp->copy(*this); |
|
212 |
return bp; |
|
213 |
} |
|
214 |
}; |
|
215 |
||
216 |
||
217 |
/////////////////////////////////////////////////////////////// |
|
218 |
// |
|
219 |
// class JvmtiBreakpoints |
|
220 |
// Used by : JvmtiCurrentBreakpoints |
|
221 |
// Used by JVMTI methods: none directly |
|
222 |
// Note: A Helper class |
|
223 |
// |
|
224 |
// JvmtiBreakpoints is a GrowableCache of JvmtiBreakpoint. |
|
225 |
// All changes to the GrowableCache occur at a safepoint using VM_ChangeBreakpoints. |
|
226 |
// |
|
227 |
// Because _bps is only modified at safepoints, its possible to always use the |
|
228 |
// cached byte code pointers from _bps without doing any synchronization (see JvmtiCurrentBreakpoints). |
|
229 |
// |
|
230 |
// It would be possible to make JvmtiBreakpoints a static class, but I've made it |
|
231 |
// CHeap allocated to emphasize its similarity to JvmtiFramePops. |
|
232 |
// |
|
233 |
||
13195 | 234 |
class JvmtiBreakpoints : public CHeapObj<mtInternal> { |
1 | 235 |
private: |
236 |
||
237 |
JvmtiBreakpointCache _bps; |
|
238 |
||
239 |
// These should only be used by VM_ChangeBreakpoints |
|
240 |
// to insure they only occur at safepoints. |
|
241 |
// Todo: add checks for safepoint |
|
242 |
friend class VM_ChangeBreakpoints; |
|
243 |
void set_at_safepoint(JvmtiBreakpoint& bp); |
|
244 |
void clear_at_safepoint(JvmtiBreakpoint& bp); |
|
245 |
||
246 |
static void do_element(GrowableElement *e); |
|
247 |
||
248 |
public: |
|
249 |
JvmtiBreakpoints(void listener_fun(void *, address *)); |
|
250 |
~JvmtiBreakpoints(); |
|
251 |
||
252 |
int length(); |
|
253 |
void oops_do(OopClosure* f); |
|
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
254 |
void metadata_do(void f(Metadata*)); |
1 | 255 |
void print(); |
256 |
||
257 |
int set(JvmtiBreakpoint& bp); |
|
258 |
int clear(JvmtiBreakpoint& bp); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
259 |
void clearall_in_class_at_safepoint(Klass* klass); |
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7896
diff
changeset
|
260 |
void gc_epilogue(); |
1 | 261 |
}; |
262 |
||
263 |
||
264 |
/////////////////////////////////////////////////////////////// |
|
265 |
// |
|
266 |
// class JvmtiCurrentBreakpoints |
|
267 |
// |
|
268 |
// A static wrapper class for the JvmtiBreakpoints that provides: |
|
269 |
// 1. a fast inlined function to check if a byte code pointer is a breakpoint (is_breakpoint). |
|
270 |
// 2. a function for lazily creating the JvmtiBreakpoints class (this is not strictly necessary, |
|
271 |
// but I'm copying the code from JvmtiThreadState which needs to lazily initialize |
|
272 |
// JvmtiFramePops). |
|
273 |
// 3. An oops_do entry point for GC'ing the breakpoint array. |
|
274 |
// |
|
275 |
||
276 |
class JvmtiCurrentBreakpoints : public AllStatic { |
|
277 |
||
278 |
private: |
|
279 |
||
280 |
// Current breakpoints, lazily initialized by get_jvmti_breakpoints(); |
|
281 |
static JvmtiBreakpoints *_jvmti_breakpoints; |
|
282 |
||
283 |
// NULL terminated cache of byte-code pointers corresponding to current breakpoints. |
|
284 |
// Updated only at safepoints (with listener_fun) when the cache is moved. |
|
285 |
// It exists only to make is_breakpoint fast. |
|
286 |
static address *_breakpoint_list; |
|
287 |
static inline void set_breakpoint_list(address *breakpoint_list) { _breakpoint_list = breakpoint_list; } |
|
288 |
static inline address *get_breakpoint_list() { return _breakpoint_list; } |
|
289 |
||
290 |
// Listener for the GrowableCache in _jvmti_breakpoints, updates _breakpoint_list. |
|
291 |
static void listener_fun(void *this_obj, address *cache); |
|
292 |
||
293 |
public: |
|
294 |
static void initialize(); |
|
295 |
static void destroy(); |
|
296 |
||
297 |
// lazily create _jvmti_breakpoints and _breakpoint_list |
|
298 |
static JvmtiBreakpoints& get_jvmti_breakpoints(); |
|
299 |
||
300 |
// quickly test whether the bcp matches a cached breakpoint in the list |
|
301 |
static inline bool is_breakpoint(address bcp); |
|
302 |
||
303 |
static void oops_do(OopClosure* f); |
|
21908
7f10463cc5a5
8028396: Minimal VM: undefined symbol: _ZN23JvmtiCurrentBreakpoints11metadata_doEPFvP8MetadataE
jprovino
parents:
21519
diff
changeset
|
304 |
static void metadata_do(void f(Metadata*)) NOT_JVMTI_RETURN; |
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7896
diff
changeset
|
305 |
static void gc_epilogue(); |
1 | 306 |
}; |
307 |
||
308 |
// quickly test whether the bcp matches a cached breakpoint in the list |
|
309 |
bool JvmtiCurrentBreakpoints::is_breakpoint(address bcp) { |
|
310 |
address *bps = get_breakpoint_list(); |
|
311 |
if (bps == NULL) return false; |
|
312 |
for ( ; (*bps) != NULL; bps++) { |
|
313 |
if ((*bps) == bcp) return true; |
|
314 |
} |
|
315 |
return false; |
|
316 |
} |
|
317 |
||
18025 | 318 |
|
319 |
/////////////////////////////////////////////////////////////// |
|
320 |
// |
|
321 |
// class VM_ChangeBreakpoints |
|
322 |
// Used by : JvmtiBreakpoints |
|
323 |
// Used by JVMTI methods: none directly. |
|
324 |
// Note: A Helper class. |
|
325 |
// |
|
326 |
// VM_ChangeBreakpoints implements a VM_Operation for ALL modifications to the JvmtiBreakpoints class. |
|
327 |
// |
|
328 |
||
329 |
class VM_ChangeBreakpoints : public VM_Operation { |
|
330 |
private: |
|
331 |
JvmtiBreakpoints* _breakpoints; |
|
332 |
int _operation; |
|
333 |
JvmtiBreakpoint* _bp; |
|
334 |
||
335 |
public: |
|
336 |
enum { SET_BREAKPOINT=0, CLEAR_BREAKPOINT=1 }; |
|
337 |
||
338 |
VM_ChangeBreakpoints(int operation, JvmtiBreakpoint *bp) { |
|
339 |
JvmtiBreakpoints& current_bps = JvmtiCurrentBreakpoints::get_jvmti_breakpoints(); |
|
340 |
_breakpoints = ¤t_bps; |
|
341 |
_bp = bp; |
|
342 |
_operation = operation; |
|
343 |
assert(bp != NULL, "bp != NULL"); |
|
344 |
} |
|
345 |
||
346 |
VMOp_Type type() const { return VMOp_ChangeBreakpoints; } |
|
347 |
void doit(); |
|
348 |
void oops_do(OopClosure* f); |
|
21519
72e63a0dbda2
8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents:
18025
diff
changeset
|
349 |
void metadata_do(void f(Metadata*)); |
18025 | 350 |
}; |
351 |
||
352 |
||
1 | 353 |
/////////////////////////////////////////////////////////////// |
354 |
// The get/set local operations must only be done by the VM thread |
|
355 |
// because the interpreter version needs to access oop maps, which can |
|
356 |
// only safely be done by the VM thread |
|
357 |
// |
|
358 |
// I'm told that in 1.5 oop maps are now protected by a lock and |
|
359 |
// we could get rid of the VM op |
|
360 |
// However if the VM op is removed then the target thread must |
|
361 |
// be suspended AND a lock will be needed to prevent concurrent |
|
362 |
// setting of locals to the same java thread. This lock is needed |
|
363 |
// to prevent compiledVFrames from trying to add deferred updates |
|
364 |
// to the thread simultaneously. |
|
365 |
// |
|
366 |
class VM_GetOrSetLocal : public VM_Operation { |
|
7444 | 367 |
protected: |
1 | 368 |
JavaThread* _thread; |
369 |
JavaThread* _calling_thread; |
|
370 |
jint _depth; |
|
371 |
jint _index; |
|
372 |
BasicType _type; |
|
373 |
jvalue _value; |
|
374 |
javaVFrame* _jvf; |
|
375 |
bool _set; |
|
376 |
||
7444 | 377 |
// It is possible to get the receiver out of a non-static native wrapper |
378 |
// frame. Use VM_GetReceiver to do this. |
|
379 |
virtual bool getting_receiver() const { return false; } |
|
380 |
||
1 | 381 |
jvmtiError _result; |
382 |
||
383 |
vframe* get_vframe(); |
|
384 |
javaVFrame* get_java_vframe(); |
|
385 |
bool check_slot_type(javaVFrame* vf); |
|
386 |
||
387 |
public: |
|
388 |
// Constructor for non-object getter |
|
389 |
VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type); |
|
390 |
||
391 |
// Constructor for object or non-object setter |
|
392 |
VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, jvalue value); |
|
393 |
||
394 |
// Constructor for object getter |
|
395 |
VM_GetOrSetLocal(JavaThread* thread, JavaThread* calling_thread, jint depth, |
|
396 |
int index); |
|
397 |
||
398 |
VMOp_Type type() const { return VMOp_GetOrSetLocal; } |
|
399 |
jvalue value() { return _value; } |
|
400 |
jvmtiError result() { return _result; } |
|
401 |
||
402 |
bool doit_prologue(); |
|
403 |
void doit(); |
|
404 |
bool allow_nested_vm_operations() const; |
|
405 |
const char* name() const { return "get/set locals"; } |
|
406 |
||
407 |
// Check that the klass is assignable to a type with the given signature. |
|
408 |
static bool is_assignable(const char* ty_sign, Klass* klass, Thread* thread); |
|
409 |
}; |
|
410 |
||
7444 | 411 |
class VM_GetReceiver : public VM_GetOrSetLocal { |
412 |
protected: |
|
413 |
virtual bool getting_receiver() const { return true; } |
|
414 |
||
415 |
public: |
|
416 |
VM_GetReceiver(JavaThread* thread, JavaThread* calling_thread, jint depth); |
|
417 |
const char* name() const { return "get receiver"; } |
|
418 |
}; |
|
419 |
||
1 | 420 |
|
421 |
/////////////////////////////////////////////////////////////// |
|
422 |
// |
|
423 |
// class JvmtiSuspendControl |
|
424 |
// |
|
425 |
// Convenience routines for suspending and resuming threads. |
|
426 |
// |
|
427 |
// All attempts by JVMTI to suspend and resume threads must go through the |
|
428 |
// JvmtiSuspendControl interface. |
|
429 |
// |
|
430 |
// methods return true if successful |
|
431 |
// |
|
432 |
class JvmtiSuspendControl : public AllStatic { |
|
433 |
public: |
|
434 |
// suspend the thread, taking it to a safepoint |
|
435 |
static bool suspend(JavaThread *java_thread); |
|
436 |
// resume the thread |
|
437 |
static bool resume(JavaThread *java_thread); |
|
438 |
||
439 |
static void print(); |
|
440 |
}; |
|
441 |
||
7408
c04a5c989f26
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
7397
diff
changeset
|
442 |
|
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
443 |
/** |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
444 |
* When a thread (such as the compiler thread or VM thread) cannot post a |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
445 |
* JVMTI event itself because the event needs to be posted from a Java |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
446 |
* thread, then it can defer the event to the Service thread for posting. |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
447 |
* The information needed to post the event is encapsulated into this class |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
448 |
* and then enqueued onto the JvmtiDeferredEventQueue, where the Service |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
449 |
* thread will pick it up and post it. |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
450 |
* |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
451 |
* This is currently only used for posting compiled-method-load and unload |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
452 |
* events, which we don't want posted from the compiler thread. |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
453 |
*/ |
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
47216
diff
changeset
|
454 |
class JvmtiDeferredEvent { |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
455 |
friend class JvmtiDeferredEventQueue; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
456 |
private: |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
457 |
typedef enum { |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
458 |
TYPE_NONE, |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
459 |
TYPE_COMPILED_METHOD_LOAD, |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
460 |
TYPE_COMPILED_METHOD_UNLOAD, |
8475
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
461 |
TYPE_DYNAMIC_CODE_GENERATED |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
462 |
} Type; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
463 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
464 |
Type _type; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
465 |
union { |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
466 |
nmethod* compiled_method_load; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
467 |
struct { |
8661
3dc8a18ac563
7024970: 2/3 assert(ServiceThread::is_service_thread(Thread::current())) failed: Service thread must post enqueue
dcubed
parents:
8475
diff
changeset
|
468 |
nmethod* nm; |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
469 |
jmethodID method_id; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
470 |
const void* code_begin; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
471 |
} compiled_method_unload; |
8475
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
472 |
struct { |
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
473 |
const char* name; |
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
474 |
const void* code_begin; |
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
475 |
const void* code_end; |
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
476 |
} dynamic_code_generated; |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
477 |
} _event_data; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
478 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
479 |
JvmtiDeferredEvent(Type t) : _type(t) {} |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
480 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
481 |
public: |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
482 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
483 |
JvmtiDeferredEvent() : _type(TYPE_NONE) {} |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
484 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
485 |
// Factory methods |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
486 |
static JvmtiDeferredEvent compiled_method_load_event(nmethod* nm) |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
487 |
NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
8661
3dc8a18ac563
7024970: 2/3 assert(ServiceThread::is_service_thread(Thread::current())) failed: Service thread must post enqueue
dcubed
parents:
8475
diff
changeset
|
488 |
static JvmtiDeferredEvent compiled_method_unload_event(nmethod* nm, |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
489 |
jmethodID id, const void* code) NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
8475
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
490 |
static JvmtiDeferredEvent dynamic_code_generated_event( |
c2b97a27943a
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
8110
diff
changeset
|
491 |
const char* name, const void* begin, const void* end) |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
492 |
NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
493 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
494 |
// Actually posts the event. |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
495 |
void post() NOT_JVMTI_RETURN; |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
496 |
}; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
497 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
498 |
/** |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
499 |
* Events enqueued on this queue wake up the Service thread which dequeues |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
500 |
* and posts the events. The Service_lock is required to be held |
46438
b093c3f1ab3d
8164563: Test nsk/jvmti/CompiledMethodUnload/compmethunload001 keeps reporting: PRODUCT BUG: class was not unloaded in 5
cjplummer
parents:
38091
diff
changeset
|
501 |
* when operating on the queue. |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
502 |
*/ |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
503 |
class JvmtiDeferredEventQueue : AllStatic { |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
504 |
friend class JvmtiDeferredEvent; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
505 |
private: |
13195 | 506 |
class QueueNode : public CHeapObj<mtInternal> { |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
507 |
private: |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
508 |
JvmtiDeferredEvent _event; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
509 |
QueueNode* _next; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
510 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
511 |
public: |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
512 |
QueueNode(const JvmtiDeferredEvent& event) |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
513 |
: _event(event), _next(NULL) {} |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
514 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
515 |
const JvmtiDeferredEvent& event() const { return _event; } |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
516 |
QueueNode* next() const { return _next; } |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
517 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
518 |
void set_next(QueueNode* next) { _next = next; } |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
519 |
}; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
520 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
521 |
static QueueNode* _queue_head; // Hold Service_lock to access |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
522 |
static QueueNode* _queue_tail; // Hold Service_lock to access |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
523 |
|
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
524 |
public: |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
525 |
// Must be holding Service_lock when calling these |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
526 |
static bool has_events() NOT_JVMTI_RETURN_(false); |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
527 |
static void enqueue(const JvmtiDeferredEvent& event) NOT_JVMTI_RETURN; |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
528 |
static JvmtiDeferredEvent dequeue() NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
529 |
}; |
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7918
diff
changeset
|
530 |
|
1 | 531 |
// Utility macro that checks for NULL pointers: |
532 |
#define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); } |
|
7397 | 533 |
|
534 |
#endif // SHARE_VM_PRIMS_JVMTIIMPL_HPP |