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