annotate src/share/vm/prims/jvmtiExtensions.cpp @ 973:ad6585fd4087

6830542: Performance: JVM_DefineClass already verified. Reviewed-by: kamg, phh
author acorn
date Fri, 04 Sep 2009 12:53:02 -0400
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_jvmtiExtensions.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // the list of extension functions
a61af66fc99e Initial load
duke
parents:
diff changeset
29 GrowableArray<jvmtiExtensionFunctionInfo*>* JvmtiExtensions::_ext_functions;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // the list of extension events
a61af66fc99e Initial load
duke
parents:
diff changeset
32 GrowableArray<jvmtiExtensionEventInfo*>* JvmtiExtensions::_ext_events;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // extension function
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, jboolean* enabled, ...) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 if (enabled == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 return JVMTI_ERROR_NULL_POINTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40 *enabled = (jboolean)ClassUnloading;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // register extension functions and events. In this implementation we
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // have a single extension function (to prove the API) that tests if class
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // unloading is enabled or disabled. We also have a single extension event
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // EXT_EVENT_CLASS_UNLOAD which is used to provide the JVMDI_EVENT_CLASS_UNLOAD
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // event. The function and the event are registered here.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 //
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void JvmtiExtensions::register_extensions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _ext_functions = new (ResourceObj::C_HEAP) GrowableArray<jvmtiExtensionFunctionInfo*>(1,true);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _ext_events = new (ResourceObj::C_HEAP) GrowableArray<jvmtiExtensionEventInfo*>(1,true);
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // register our extension function
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static jvmtiParamInfo func_params[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 { (char*)"IsClassUnloadingEnabled", JVMTI_KIND_OUT, JVMTI_TYPE_JBOOLEAN, JNI_FALSE }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 };
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static jvmtiExtensionFunctionInfo ext_func = {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 (jvmtiExtensionFunction)IsClassUnloadingEnabled,
a61af66fc99e Initial load
duke
parents:
diff changeset
60 (char*)"com.sun.hotspot.functions.IsClassUnloadingEnabled",
a61af66fc99e Initial load
duke
parents:
diff changeset
61 (char*)"Tell if class unloading is enabled (-noclassgc)",
a61af66fc99e Initial load
duke
parents:
diff changeset
62 sizeof(func_params)/sizeof(func_params[0]),
a61af66fc99e Initial load
duke
parents:
diff changeset
63 func_params,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 0, // no non-universal errors
a61af66fc99e Initial load
duke
parents:
diff changeset
65 NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
66 };
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _ext_functions->append(&ext_func);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // register our extension event
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 static jvmtiParamInfo event_params[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 { (char*)"JNI Environment", JVMTI_KIND_IN, JVMTI_TYPE_JNIENV, JNI_FALSE },
a61af66fc99e Initial load
duke
parents:
diff changeset
73 { (char*)"Thread", JVMTI_KIND_IN, JVMTI_TYPE_JTHREAD, JNI_FALSE },
a61af66fc99e Initial load
duke
parents:
diff changeset
74 { (char*)"Class", JVMTI_KIND_IN, JVMTI_TYPE_JCLASS, JNI_FALSE }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 };
a61af66fc99e Initial load
duke
parents:
diff changeset
76 static jvmtiExtensionEventInfo ext_event = {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 EXT_EVENT_CLASS_UNLOAD,
a61af66fc99e Initial load
duke
parents:
diff changeset
78 (char*)"com.sun.hotspot.events.ClassUnload",
a61af66fc99e Initial load
duke
parents:
diff changeset
79 (char*)"CLASS_UNLOAD event",
a61af66fc99e Initial load
duke
parents:
diff changeset
80 sizeof(event_params)/sizeof(event_params[0]),
a61af66fc99e Initial load
duke
parents:
diff changeset
81 event_params
a61af66fc99e Initial load
duke
parents:
diff changeset
82 };
a61af66fc99e Initial load
duke
parents:
diff changeset
83 _ext_events->append(&ext_event);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // return the list of extension functions
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 jvmtiError JvmtiExtensions::get_functions(JvmtiEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
90 jint* extension_count_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 jvmtiExtensionFunctionInfo** extensions)
a61af66fc99e Initial load
duke
parents:
diff changeset
92 {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 guarantee(_ext_functions != NULL, "registration not done");
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 ResourceTracker rt(env);
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 jvmtiExtensionFunctionInfo* ext_funcs;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 jvmtiError err = rt.allocate(_ext_functions->length() *
a61af66fc99e Initial load
duke
parents:
diff changeset
99 sizeof(jvmtiExtensionFunctionInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
100 (unsigned char**)&ext_funcs);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 for (int i=0; i<_ext_functions->length(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ext_funcs[i].func = _ext_functions->at(i)->func;
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 char *id = _ext_functions->at(i)->id;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 err = rt.allocate(strlen(id)+1, (unsigned char**)&(ext_funcs[i].id));
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 strcpy(ext_funcs[i].id, id);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 char *desc = _ext_functions->at(i)->short_description;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 err = rt.allocate(strlen(desc)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
117 (unsigned char**)&(ext_funcs[i].short_description));
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 strcpy(ext_funcs[i].short_description, desc);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // params
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 jint param_count = _ext_functions->at(i)->param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ext_funcs[i].param_count = param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 if (param_count == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 ext_funcs[i].params = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 err = rt.allocate(param_count*sizeof(jvmtiParamInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
132 (unsigned char**)&(ext_funcs[i].params));
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 jvmtiParamInfo* src_params = _ext_functions->at(i)->params;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 jvmtiParamInfo* dst_params = ext_funcs[i].params;
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 for (int j=0; j<param_count; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 err = rt.allocate(strlen(src_params[j].name)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
141 (unsigned char**)&(dst_params[j].name));
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 strcpy(dst_params[j].name, src_params[j].name);
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 dst_params[j].kind = src_params[j].kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 dst_params[j].base_type = src_params[j].base_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 dst_params[j].null_ok = src_params[j].null_ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // errors
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 jint error_count = _ext_functions->at(i)->error_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 ext_funcs[i].error_count = error_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (error_count == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 ext_funcs[i].errors = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 err = rt.allocate(error_count*sizeof(jvmtiError),
a61af66fc99e Initial load
duke
parents:
diff changeset
161 (unsigned char**)&(ext_funcs[i].errors));
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 memcpy(ext_funcs[i].errors, _ext_functions->at(i)->errors,
a61af66fc99e Initial load
duke
parents:
diff changeset
166 error_count*sizeof(jvmtiError));
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 *extension_count_ptr = _ext_functions->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
171 *extensions = ext_funcs;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // return the list of extension events
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 jvmtiError JvmtiExtensions::get_events(JvmtiEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
179 jint* extension_count_ptr,
a61af66fc99e Initial load
duke
parents:
diff changeset
180 jvmtiExtensionEventInfo** extensions)
a61af66fc99e Initial load
duke
parents:
diff changeset
181 {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 guarantee(_ext_events != NULL, "registration not done");
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 ResourceTracker rt(env);
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 jvmtiExtensionEventInfo* ext_events;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 jvmtiError err = rt.allocate(_ext_events->length() * sizeof(jvmtiExtensionEventInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
188 (unsigned char**)&ext_events);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 for (int i=0; i<_ext_events->length(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 ext_events[i].extension_event_index = _ext_events->at(i)->extension_event_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 char *id = _ext_events->at(i)->id;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 err = rt.allocate(strlen(id)+1, (unsigned char**)&(ext_events[i].id));
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 strcpy(ext_events[i].id, id);
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 char *desc = _ext_events->at(i)->short_description;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 err = rt.allocate(strlen(desc)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 (unsigned char**)&(ext_events[i].short_description));
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 strcpy(ext_events[i].short_description, desc);
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // params
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 jint param_count = _ext_events->at(i)->param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 ext_events[i].param_count = param_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (param_count == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 ext_events[i].params = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 err = rt.allocate(param_count*sizeof(jvmtiParamInfo),
a61af66fc99e Initial load
duke
parents:
diff changeset
220 (unsigned char**)&(ext_events[i].params));
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 jvmtiParamInfo* src_params = _ext_events->at(i)->params;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 jvmtiParamInfo* dst_params = ext_events[i].params;
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 for (int j=0; j<param_count; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 err = rt.allocate(strlen(src_params[j].name)+1,
a61af66fc99e Initial load
duke
parents:
diff changeset
229 (unsigned char**)&(dst_params[j].name));
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (err != JVMTI_ERROR_NONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233 strcpy(dst_params[j].name, src_params[j].name);
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 dst_params[j].kind = src_params[j].kind;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 dst_params[j].base_type = src_params[j].base_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 dst_params[j].null_ok = src_params[j].null_ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 *extension_count_ptr = _ext_events->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 *extensions = ext_events;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // set callback for an extension event and enable/disable it.
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 jvmtiError JvmtiExtensions::set_event_callback(JvmtiEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
250 jint extension_event_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
251 jvmtiExtensionEvent callback)
a61af66fc99e Initial load
duke
parents:
diff changeset
252 {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 guarantee(_ext_events != NULL, "registration not done");
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 jvmtiExtensionEventInfo* event = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // if there are extension events registered then validate that the
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // extension_event_index matches one of the registered events.
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if (_ext_events != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 for (int i=0; i<_ext_events->length(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 if (_ext_events->at(i)->extension_event_index == extension_event_index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 event = _ext_events->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // invalid event index
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (event == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 JvmtiEventController::set_extension_event_callback(env, extension_event_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 callback);
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }