annotate src/share/vm/prims/jvmtiImpl.hpp @ 13409:77b028ba548c

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