Mercurial > hg > truffle
annotate src/share/vm/prims/jvmtiImpl.hpp @ 11722:ff05c78a7f64
use time passed to decide what methods to compile or inline
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Thu, 19 Sep 2013 10:36:56 +0200 |
parents | f2110083203d |
children | 910026b800b8 |
rev | line source |
---|---|
0 | 1 /* |
7951 | 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
611
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
611
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:
611
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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" | |
37 | |
0 | 38 // |
39 // Forward Declarations | |
40 // | |
41 | |
42 class JvmtiBreakpoint; | |
43 class JvmtiBreakpoints; | |
44 | |
45 | |
46 /////////////////////////////////////////////////////////////// | |
47 // | |
48 // class GrowableCache, GrowableElement | |
49 // Used by : JvmtiBreakpointCache | |
50 // Used by JVMTI methods: none directly. | |
51 // | |
52 // GrowableCache is a permanent CHeap growable array of <GrowableElement *> | |
53 // | |
54 // In addition, the GrowableCache maintains a NULL terminated cache array of type address | |
55 // that's created from the element array using the function: | |
56 // address GrowableElement::getCacheValue(). | |
57 // | |
58 // Whenever the GrowableArray changes size, the cache array gets recomputed into a new C_HEAP allocated | |
59 // block of memory. Additionally, every time the cache changes its position in memory, the | |
60 // void (*_listener_fun)(void *this_obj, address* cache) | |
61 // gets called with the cache's new address. This gives the user of the GrowableCache a callback | |
62 // to update its pointer to the address cache. | |
63 // | |
64 | |
6197 | 65 class GrowableElement : public CHeapObj<mtInternal> { |
0 | 66 public: |
67 virtual address getCacheValue() =0; | |
68 virtual bool equals(GrowableElement* e) =0; | |
69 virtual bool lessThan(GrowableElement *e)=0; | |
70 virtual GrowableElement *clone() =0; | |
71 virtual void oops_do(OopClosure* f) =0; | |
72 }; | |
73 | |
74 class GrowableCache VALUE_OBJ_CLASS_SPEC { | |
75 | |
76 private: | |
77 // Object pointer passed into cache & listener functions. | |
78 void *_this_obj; | |
79 | |
80 // Array of elements in the collection | |
81 GrowableArray<GrowableElement *> *_elements; | |
82 | |
83 // Parallel array of cached values | |
84 address *_cache; | |
85 | |
86 // Listener for changes to the _cache field. | |
87 // Called whenever the _cache field has it's value changed | |
88 // (but NOT when cached elements are recomputed). | |
89 void (*_listener_fun)(void *, address*); | |
90 | |
91 static bool equals(void *, GrowableElement *); | |
92 | |
93 // recache all elements after size change, notify listener | |
94 void recache(); | |
95 | |
96 public: | |
97 GrowableCache(); | |
98 ~GrowableCache(); | |
99 | |
100 void initialize(void *this_obj, void listener_fun(void *, address*) ); | |
101 | |
102 // number of elements in the collection | |
103 int length(); | |
104 // get the value of the index element in the collection | |
105 GrowableElement* at(int index); | |
106 // find the index of the element, -1 if it doesn't exist | |
107 int find(GrowableElement* e); | |
108 // append a copy of the element to the end of the collection, notify listener | |
109 void append(GrowableElement* e); | |
110 // insert a copy of the element using lessthan(), notify listener | |
111 void insert(GrowableElement* e); | |
112 // remove the element at index, notify listener | |
113 void remove (int index); | |
114 // clear out all elements and release all heap space, notify listener | |
115 void clear(); | |
116 // apply f to every element and update the cache | |
117 void oops_do(OopClosure* f); | |
2147
9afee0b9fc1d
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
2125
diff
changeset
|
118 // update the cache after a full gc |
9afee0b9fc1d
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
2125
diff
changeset
|
119 void gc_epilogue(); |
0 | 120 }; |
121 | |
122 | |
123 /////////////////////////////////////////////////////////////// | |
124 // | |
125 // class JvmtiBreakpointCache | |
126 // Used by : JvmtiBreakpoints | |
127 // Used by JVMTI methods: none directly. | |
128 // Note : typesafe wrapper for GrowableCache of JvmtiBreakpoint | |
129 // | |
130 | |
6197 | 131 class JvmtiBreakpointCache : public CHeapObj<mtInternal> { |
0 | 132 |
133 private: | |
134 GrowableCache _cache; | |
135 | |
136 public: | |
137 JvmtiBreakpointCache() {} | |
138 ~JvmtiBreakpointCache() {} | |
139 | |
140 void initialize(void *this_obj, void listener_fun(void *, address*) ) { | |
141 _cache.initialize(this_obj,listener_fun); | |
142 } | |
143 | |
144 int length() { return _cache.length(); } | |
145 JvmtiBreakpoint& at(int index) { return (JvmtiBreakpoint&) *(_cache.at(index)); } | |
146 int find(JvmtiBreakpoint& e) { return _cache.find((GrowableElement *) &e); } | |
147 void append(JvmtiBreakpoint& e) { _cache.append((GrowableElement *) &e); } | |
148 void remove (int index) { _cache.remove(index); } | |
149 void clear() { _cache.clear(); } | |
150 void oops_do(OopClosure* f) { _cache.oops_do(f); } | |
2147
9afee0b9fc1d
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
2125
diff
changeset
|
151 void gc_epilogue() { _cache.gc_epilogue(); } |
0 | 152 }; |
153 | |
154 | |
155 /////////////////////////////////////////////////////////////// | |
156 // | |
157 // class JvmtiBreakpoint | |
158 // Used by : JvmtiBreakpoints | |
159 // Used by JVMTI methods: SetBreakpoint, ClearBreakpoint, ClearAllBreakpoints | |
160 // Note: Extends GrowableElement for use in a GrowableCache | |
161 // | |
162 // A JvmtiBreakpoint describes a location (class, method, bci) to break at. | |
163 // | |
164 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
165 typedef void (Method::*method_action)(int _bci); |
0 | 166 |
167 class JvmtiBreakpoint : public GrowableElement { | |
168 private: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
169 Method* _method; |
0 | 170 int _bci; |
171 Bytecodes::Code _orig_bytecode; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
172 oop _class_loader; |
0 | 173 |
174 public: | |
175 JvmtiBreakpoint(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
176 JvmtiBreakpoint(Method* m_method, jlocation location); |
0 | 177 bool equals(JvmtiBreakpoint& bp); |
178 bool lessThan(JvmtiBreakpoint &bp); | |
179 void copy(JvmtiBreakpoint& bp); | |
180 bool is_valid(); | |
181 address getBcp(); | |
182 void each_method_version_do(method_action meth_act); | |
183 void set(); | |
184 void clear(); | |
185 void print(); | |
186 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
187 Method* method() { return _method; } |
0 | 188 |
189 // GrowableElement implementation | |
190 address getCacheValue() { return getBcp(); } | |
191 bool lessThan(GrowableElement* e) { Unimplemented(); return false; } | |
192 bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
193 void oops_do(OopClosure* f) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
194 // Mark the method loader as live |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
195 f->do_oop(&_class_loader); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
196 } |
0 | 197 GrowableElement *clone() { |
198 JvmtiBreakpoint *bp = new JvmtiBreakpoint(); | |
199 bp->copy(*this); | |
200 return bp; | |
201 } | |
202 }; | |
203 | |
204 | |
205 /////////////////////////////////////////////////////////////// | |
206 // | |
207 // class JvmtiBreakpoints | |
208 // Used by : JvmtiCurrentBreakpoints | |
209 // Used by JVMTI methods: none directly | |
210 // Note: A Helper class | |
211 // | |
212 // JvmtiBreakpoints is a GrowableCache of JvmtiBreakpoint. | |
213 // All changes to the GrowableCache occur at a safepoint using VM_ChangeBreakpoints. | |
214 // | |
215 // Because _bps is only modified at safepoints, its possible to always use the | |
216 // cached byte code pointers from _bps without doing any synchronization (see JvmtiCurrentBreakpoints). | |
217 // | |
218 // It would be possible to make JvmtiBreakpoints a static class, but I've made it | |
219 // CHeap allocated to emphasize its similarity to JvmtiFramePops. | |
220 // | |
221 | |
6197 | 222 class JvmtiBreakpoints : public CHeapObj<mtInternal> { |
0 | 223 private: |
224 | |
225 JvmtiBreakpointCache _bps; | |
226 | |
227 // These should only be used by VM_ChangeBreakpoints | |
228 // to insure they only occur at safepoints. | |
229 // Todo: add checks for safepoint | |
230 friend class VM_ChangeBreakpoints; | |
231 void set_at_safepoint(JvmtiBreakpoint& bp); | |
232 void clear_at_safepoint(JvmtiBreakpoint& bp); | |
233 | |
234 static void do_element(GrowableElement *e); | |
235 | |
236 public: | |
237 JvmtiBreakpoints(void listener_fun(void *, address *)); | |
238 ~JvmtiBreakpoints(); | |
239 | |
240 int length(); | |
241 void oops_do(OopClosure* f); | |
242 void print(); | |
243 | |
244 int set(JvmtiBreakpoint& bp); | |
245 int clear(JvmtiBreakpoint& bp); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
246 void clearall_in_class_at_safepoint(Klass* klass); |
2147
9afee0b9fc1d
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
2125
diff
changeset
|
247 void gc_epilogue(); |
0 | 248 }; |
249 | |
250 | |
251 /////////////////////////////////////////////////////////////// | |
252 // | |
253 // class JvmtiCurrentBreakpoints | |
254 // | |
255 // A static wrapper class for the JvmtiBreakpoints that provides: | |
256 // 1. a fast inlined function to check if a byte code pointer is a breakpoint (is_breakpoint). | |
257 // 2. a function for lazily creating the JvmtiBreakpoints class (this is not strictly necessary, | |
258 // but I'm copying the code from JvmtiThreadState which needs to lazily initialize | |
259 // JvmtiFramePops). | |
260 // 3. An oops_do entry point for GC'ing the breakpoint array. | |
261 // | |
262 | |
263 class JvmtiCurrentBreakpoints : public AllStatic { | |
264 | |
265 private: | |
266 | |
267 // Current breakpoints, lazily initialized by get_jvmti_breakpoints(); | |
268 static JvmtiBreakpoints *_jvmti_breakpoints; | |
269 | |
270 // NULL terminated cache of byte-code pointers corresponding to current breakpoints. | |
271 // Updated only at safepoints (with listener_fun) when the cache is moved. | |
272 // It exists only to make is_breakpoint fast. | |
273 static address *_breakpoint_list; | |
274 static inline void set_breakpoint_list(address *breakpoint_list) { _breakpoint_list = breakpoint_list; } | |
275 static inline address *get_breakpoint_list() { return _breakpoint_list; } | |
276 | |
277 // Listener for the GrowableCache in _jvmti_breakpoints, updates _breakpoint_list. | |
278 static void listener_fun(void *this_obj, address *cache); | |
279 | |
280 public: | |
281 static void initialize(); | |
282 static void destroy(); | |
283 | |
284 // lazily create _jvmti_breakpoints and _breakpoint_list | |
285 static JvmtiBreakpoints& get_jvmti_breakpoints(); | |
286 | |
287 // quickly test whether the bcp matches a cached breakpoint in the list | |
288 static inline bool is_breakpoint(address bcp); | |
289 | |
290 static void oops_do(OopClosure* f); | |
2147
9afee0b9fc1d
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
2125
diff
changeset
|
291 static void gc_epilogue(); |
0 | 292 }; |
293 | |
294 // quickly test whether the bcp matches a cached breakpoint in the list | |
295 bool JvmtiCurrentBreakpoints::is_breakpoint(address bcp) { | |
296 address *bps = get_breakpoint_list(); | |
297 if (bps == NULL) return false; | |
298 for ( ; (*bps) != NULL; bps++) { | |
299 if ((*bps) == bcp) return true; | |
300 } | |
301 return false; | |
302 } | |
303 | |
10405 | 304 |
305 /////////////////////////////////////////////////////////////// | |
306 // | |
307 // class VM_ChangeBreakpoints | |
308 // Used by : JvmtiBreakpoints | |
309 // Used by JVMTI methods: none directly. | |
310 // Note: A Helper class. | |
311 // | |
312 // VM_ChangeBreakpoints implements a VM_Operation for ALL modifications to the JvmtiBreakpoints class. | |
313 // | |
314 | |
315 class VM_ChangeBreakpoints : public VM_Operation { | |
316 private: | |
317 JvmtiBreakpoints* _breakpoints; | |
318 int _operation; | |
319 JvmtiBreakpoint* _bp; | |
320 | |
321 public: | |
322 enum { SET_BREAKPOINT=0, CLEAR_BREAKPOINT=1 }; | |
323 | |
324 VM_ChangeBreakpoints(int operation, JvmtiBreakpoint *bp) { | |
325 JvmtiBreakpoints& current_bps = JvmtiCurrentBreakpoints::get_jvmti_breakpoints(); | |
326 _breakpoints = ¤t_bps; | |
327 _bp = bp; | |
328 _operation = operation; | |
329 assert(bp != NULL, "bp != NULL"); | |
330 } | |
331 | |
332 VMOp_Type type() const { return VMOp_ChangeBreakpoints; } | |
333 void doit(); | |
334 void oops_do(OopClosure* f); | |
335 }; | |
336 | |
337 | |
0 | 338 /////////////////////////////////////////////////////////////// |
339 // The get/set local operations must only be done by the VM thread | |
340 // because the interpreter version needs to access oop maps, which can | |
341 // only safely be done by the VM thread | |
342 // | |
343 // I'm told that in 1.5 oop maps are now protected by a lock and | |
344 // we could get rid of the VM op | |
345 // However if the VM op is removed then the target thread must | |
346 // be suspended AND a lock will be needed to prevent concurrent | |
347 // setting of locals to the same java thread. This lock is needed | |
348 // to prevent compiledVFrames from trying to add deferred updates | |
349 // to the thread simultaneously. | |
350 // | |
351 class VM_GetOrSetLocal : public VM_Operation { | |
2019 | 352 protected: |
0 | 353 JavaThread* _thread; |
354 JavaThread* _calling_thread; | |
355 jint _depth; | |
356 jint _index; | |
357 BasicType _type; | |
358 jvalue _value; | |
359 javaVFrame* _jvf; | |
360 bool _set; | |
361 | |
2019 | 362 // It is possible to get the receiver out of a non-static native wrapper |
363 // frame. Use VM_GetReceiver to do this. | |
364 virtual bool getting_receiver() const { return false; } | |
365 | |
0 | 366 jvmtiError _result; |
367 | |
368 vframe* get_vframe(); | |
369 javaVFrame* get_java_vframe(); | |
370 bool check_slot_type(javaVFrame* vf); | |
371 | |
372 public: | |
373 // Constructor for non-object getter | |
374 VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type); | |
375 | |
376 // Constructor for object or non-object setter | |
377 VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, jvalue value); | |
378 | |
379 // Constructor for object getter | |
380 VM_GetOrSetLocal(JavaThread* thread, JavaThread* calling_thread, jint depth, | |
381 int index); | |
382 | |
383 VMOp_Type type() const { return VMOp_GetOrSetLocal; } | |
384 jvalue value() { return _value; } | |
385 jvmtiError result() { return _result; } | |
386 | |
387 bool doit_prologue(); | |
388 void doit(); | |
389 bool allow_nested_vm_operations() const; | |
390 const char* name() const { return "get/set locals"; } | |
391 | |
392 // Check that the klass is assignable to a type with the given signature. | |
393 static bool is_assignable(const char* ty_sign, Klass* klass, Thread* thread); | |
394 }; | |
395 | |
2019 | 396 class VM_GetReceiver : public VM_GetOrSetLocal { |
397 protected: | |
398 virtual bool getting_receiver() const { return true; } | |
399 | |
400 public: | |
401 VM_GetReceiver(JavaThread* thread, JavaThread* calling_thread, jint depth); | |
402 const char* name() const { return "get receiver"; } | |
403 }; | |
404 | |
0 | 405 |
406 /////////////////////////////////////////////////////////////// | |
407 // | |
408 // class JvmtiSuspendControl | |
409 // | |
410 // Convenience routines for suspending and resuming threads. | |
411 // | |
412 // All attempts by JVMTI to suspend and resume threads must go through the | |
413 // JvmtiSuspendControl interface. | |
414 // | |
415 // methods return true if successful | |
416 // | |
417 class JvmtiSuspendControl : public AllStatic { | |
418 public: | |
419 // suspend the thread, taking it to a safepoint | |
420 static bool suspend(JavaThread *java_thread); | |
421 // resume the thread | |
422 static bool resume(JavaThread *java_thread); | |
423 | |
424 static void print(); | |
425 }; | |
426 | |
1983
c760f78e0a53
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
1972
diff
changeset
|
427 |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
428 /** |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
429 * When a thread (such as the compiler thread or VM thread) cannot post a |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
430 * JVMTI event itself because the event needs to be posted from a Java |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
431 * thread, then it can defer the event to the Service thread for posting. |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
432 * The information needed to post the event is encapsulated into this class |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
433 * and then enqueued onto the JvmtiDeferredEventQueue, where the Service |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
434 * thread will pick it up and post it. |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
435 * |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
436 * This is currently only used for posting compiled-method-load and unload |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
437 * events, which we don't want posted from the compiler thread. |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
438 */ |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
439 class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC { |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
440 friend class JvmtiDeferredEventQueue; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
441 private: |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
442 typedef enum { |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
443 TYPE_NONE, |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
444 TYPE_COMPILED_METHOD_LOAD, |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
445 TYPE_COMPILED_METHOD_UNLOAD, |
2301
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
446 TYPE_DYNAMIC_CODE_GENERATED |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
447 } Type; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
448 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
449 Type _type; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
450 union { |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
451 nmethod* compiled_method_load; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
452 struct { |
2342
46a56fac55c7
7024970: 2/3 assert(ServiceThread::is_service_thread(Thread::current())) failed: Service thread must post enqueue
dcubed
parents:
2301
diff
changeset
|
453 nmethod* nm; |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
454 jmethodID method_id; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
455 const void* code_begin; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
456 } compiled_method_unload; |
2301
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
457 struct { |
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
458 const char* name; |
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
459 const void* code_begin; |
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
460 const void* code_end; |
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
461 } dynamic_code_generated; |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
462 } _event_data; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
463 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
464 JvmtiDeferredEvent(Type t) : _type(t) {} |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
465 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
466 public: |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
467 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
468 JvmtiDeferredEvent() : _type(TYPE_NONE) {} |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
469 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
470 // Factory methods |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
471 static JvmtiDeferredEvent compiled_method_load_event(nmethod* nm) |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
472 NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
2342
46a56fac55c7
7024970: 2/3 assert(ServiceThread::is_service_thread(Thread::current())) failed: Service thread must post enqueue
dcubed
parents:
2301
diff
changeset
|
473 static JvmtiDeferredEvent compiled_method_unload_event(nmethod* nm, |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
474 jmethodID id, const void* code) NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
2301
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
475 static JvmtiDeferredEvent dynamic_code_generated_event( |
f91db74a6810
7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents:
2195
diff
changeset
|
476 const char* name, const void* begin, const void* end) |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
477 NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
478 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
479 // Actually posts the event. |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
480 void post() NOT_JVMTI_RETURN; |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
481 }; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
482 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
483 /** |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
484 * Events enqueued on this queue wake up the Service thread which dequeues |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
485 * and posts the events. The Service_lock is required to be held |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
486 * when operating on the queue (except for the "pending" events). |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
487 */ |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
488 class JvmtiDeferredEventQueue : AllStatic { |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
489 friend class JvmtiDeferredEvent; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
490 private: |
6197 | 491 class QueueNode : public CHeapObj<mtInternal> { |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
492 private: |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
493 JvmtiDeferredEvent _event; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
494 QueueNode* _next; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
495 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
496 public: |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
497 QueueNode(const JvmtiDeferredEvent& event) |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
498 : _event(event), _next(NULL) {} |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
499 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
500 const JvmtiDeferredEvent& event() const { return _event; } |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
501 QueueNode* next() const { return _next; } |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
502 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
503 void set_next(QueueNode* next) { _next = next; } |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
504 }; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
505 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
506 static QueueNode* _queue_head; // Hold Service_lock to access |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
507 static QueueNode* _queue_tail; // Hold Service_lock to access |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
508 static volatile QueueNode* _pending_list; // Uses CAS for read/update |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
509 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
510 // Transfers events from the _pending_list to the _queue. |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
511 static void process_pending_events() NOT_JVMTI_RETURN; |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
512 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
513 public: |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
514 // Must be holding Service_lock when calling these |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
515 static bool has_events() NOT_JVMTI_RETURN_(false); |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
516 static void enqueue(const JvmtiDeferredEvent& event) NOT_JVMTI_RETURN; |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
517 static JvmtiDeferredEvent dequeue() NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
518 |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
519 // Used to enqueue events without using a lock, for times (such as during |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
520 // safepoint) when we can't or don't want to lock the Service_lock. |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
521 // |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
522 // Events will be held off to the side until there's a call to |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
523 // dequeue(), enqueue(), or process_pending_events() (all of which require |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
524 // the holding of the Service_lock), and will be enqueued at that time. |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
525 static void add_pending_event(const JvmtiDeferredEvent&) NOT_JVMTI_RETURN; |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
526 }; |
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
2147
diff
changeset
|
527 |
0 | 528 // Utility macro that checks for NULL pointers: |
529 #define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); } | |
1972 | 530 |
531 #endif // SHARE_VM_PRIMS_JVMTIIMPL_HPP |