Mercurial > hg > truffle
annotate src/share/vm/prims/jvmtiManageCapabilities.cpp @ 10136:cc12becb22e7
Merge
author | dcubed |
---|---|
date | Sun, 21 Apr 2013 21:05:02 -0700 |
parents | c2323e2ea62b |
children | abe03600372a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
2 * Copyright (c) 2003, 2010, 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:
1397
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
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:
1397
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "jvmtifiles/jvmtiEnv.hpp" | |
27 #include "prims/jvmtiExport.hpp" | |
28 #include "prims/jvmtiManageCapabilities.hpp" | |
0 | 29 static const jint CAPA_SIZE = (JVMTI_INTERNAL_CAPABILITY_COUNT + 7) / 8; |
30 | |
31 // capabilities which are always potentially available | |
32 jvmtiCapabilities JvmtiManageCapabilities::always_capabilities; | |
33 | |
34 // capabilities which are potentially available during OnLoad | |
35 jvmtiCapabilities JvmtiManageCapabilities::onload_capabilities; | |
36 | |
37 // capabilities which are always potentially available | |
38 // but to only one environment | |
39 jvmtiCapabilities JvmtiManageCapabilities::always_solo_capabilities; | |
40 | |
41 // capabilities which are potentially available during OnLoad | |
42 // but to only one environment | |
43 jvmtiCapabilities JvmtiManageCapabilities::onload_solo_capabilities; | |
44 | |
45 // remaining capabilities which are always potentially available | |
46 // but to only one environment | |
47 jvmtiCapabilities JvmtiManageCapabilities::always_solo_remaining_capabilities; | |
48 | |
49 // remaining capabilities which are potentially available during OnLoad | |
50 // but to only one environment | |
51 jvmtiCapabilities JvmtiManageCapabilities::onload_solo_remaining_capabilities; | |
52 | |
53 // all capabilities ever acquired | |
54 jvmtiCapabilities JvmtiManageCapabilities::acquired_capabilities; | |
55 | |
56 void JvmtiManageCapabilities::initialize() { | |
57 always_capabilities = init_always_capabilities(); | |
58 if (JvmtiEnv::get_phase() != JVMTI_PHASE_ONLOAD) { | |
59 recompute_always_capabilities(); | |
60 } | |
61 onload_capabilities = init_onload_capabilities(); | |
62 always_solo_capabilities = init_always_solo_capabilities(); | |
63 onload_solo_capabilities = init_onload_solo_capabilities(); | |
64 always_solo_remaining_capabilities = init_always_solo_capabilities(); | |
65 onload_solo_remaining_capabilities = init_onload_solo_capabilities(); | |
66 memset(&acquired_capabilities, 0, sizeof(acquired_capabilities)); | |
67 } | |
68 | |
69 // if the capability sets are initialized in the onload phase then | |
70 // it happens before class data sharing (CDS) is initialized. If it | |
71 // turns out that CDS gets disabled then we must adjust the always | |
72 // capabilities. To ensure a consistent view of the capabililties | |
73 // anything we add here should already be in the onload set. | |
74 void JvmtiManageCapabilities::recompute_always_capabilities() { | |
75 if (!UseSharedSpaces) { | |
76 jvmtiCapabilities jc = always_capabilities; | |
77 jc.can_generate_all_class_hook_events = 1; | |
78 always_capabilities = jc; | |
79 } | |
80 } | |
81 | |
82 | |
83 // corresponding init functions | |
84 jvmtiCapabilities JvmtiManageCapabilities::init_always_capabilities() { | |
85 jvmtiCapabilities jc; | |
86 | |
87 memset(&jc, 0, sizeof(jc)); | |
88 jc.can_get_bytecodes = 1; | |
89 jc.can_signal_thread = 1; | |
90 jc.can_get_source_file_name = 1; | |
91 jc.can_get_line_numbers = 1; | |
92 jc.can_get_synthetic_attribute = 1; | |
93 jc.can_get_monitor_info = 1; | |
94 jc.can_get_constant_pool = 1; | |
95 jc.can_generate_monitor_events = 1; | |
96 jc.can_generate_garbage_collection_events = 1; | |
97 jc.can_generate_compiled_method_load_events = 1; | |
98 jc.can_generate_native_method_bind_events = 1; | |
99 jc.can_generate_vm_object_alloc_events = 1; | |
100 if (os::is_thread_cpu_time_supported()) { | |
101 jc.can_get_current_thread_cpu_time = 1; | |
102 jc.can_get_thread_cpu_time = 1; | |
103 } | |
104 jc.can_redefine_classes = 1; | |
105 jc.can_redefine_any_class = 1; | |
106 jc.can_retransform_classes = 1; | |
107 jc.can_retransform_any_class = 1; | |
108 jc.can_set_native_method_prefix = 1; | |
109 jc.can_tag_objects = 1; | |
110 jc.can_generate_object_free_events = 1; | |
111 jc.can_generate_resource_exhaustion_heap_events = 1; | |
112 jc.can_generate_resource_exhaustion_threads_events = 1; | |
113 return jc; | |
114 } | |
115 | |
116 jvmtiCapabilities JvmtiManageCapabilities::init_onload_capabilities() { | |
117 jvmtiCapabilities jc; | |
118 | |
119 memset(&jc, 0, sizeof(jc)); | |
1078 | 120 #ifndef CC_INTERP |
0 | 121 jc.can_pop_frame = 1; |
122 jc.can_force_early_return = 1; | |
1078 | 123 #endif // !CC_INTERP |
0 | 124 jc.can_get_source_debug_extension = 1; |
125 jc.can_access_local_variables = 1; | |
126 jc.can_maintain_original_method_order = 1; | |
127 jc.can_generate_all_class_hook_events = 1; | |
128 jc.can_generate_single_step_events = 1; | |
129 jc.can_generate_exception_events = 1; | |
130 jc.can_generate_frame_pop_events = 1; | |
131 jc.can_generate_method_entry_events = 1; | |
132 jc.can_generate_method_exit_events = 1; | |
133 jc.can_get_owned_monitor_info = 1; | |
134 jc.can_get_owned_monitor_stack_depth_info = 1; | |
135 jc.can_get_current_contended_monitor = 1; | |
136 // jc.can_get_monitor_info = 1; | |
137 jc.can_tag_objects = 1; // TODO: this should have been removed | |
138 jc.can_generate_object_free_events = 1; // TODO: this should have been removed | |
139 return jc; | |
140 } | |
141 | |
142 | |
143 jvmtiCapabilities JvmtiManageCapabilities::init_always_solo_capabilities() { | |
144 jvmtiCapabilities jc; | |
145 | |
146 memset(&jc, 0, sizeof(jc)); | |
147 jc.can_suspend = 1; | |
148 return jc; | |
149 } | |
150 | |
151 | |
152 jvmtiCapabilities JvmtiManageCapabilities::init_onload_solo_capabilities() { | |
153 jvmtiCapabilities jc; | |
154 | |
155 memset(&jc, 0, sizeof(jc)); | |
156 jc.can_generate_field_modification_events = 1; | |
157 jc.can_generate_field_access_events = 1; | |
158 jc.can_generate_breakpoint_events = 1; | |
159 return jc; | |
160 } | |
161 | |
162 | |
163 jvmtiCapabilities *JvmtiManageCapabilities::either(const jvmtiCapabilities *a, const jvmtiCapabilities *b, | |
164 jvmtiCapabilities *result) { | |
165 char *ap = (char *)a; | |
166 char *bp = (char *)b; | |
167 char *resultp = (char *)result; | |
168 | |
169 for (int i = 0; i < CAPA_SIZE; ++i) { | |
170 *resultp++ = *ap++ | *bp++; | |
171 } | |
172 | |
173 return result; | |
174 } | |
175 | |
176 | |
177 jvmtiCapabilities *JvmtiManageCapabilities::both(const jvmtiCapabilities *a, const jvmtiCapabilities *b, | |
178 jvmtiCapabilities *result) { | |
179 char *ap = (char *)a; | |
180 char *bp = (char *)b; | |
181 char *resultp = (char *)result; | |
182 | |
183 for (int i = 0; i < CAPA_SIZE; ++i) { | |
184 *resultp++ = *ap++ & *bp++; | |
185 } | |
186 | |
187 return result; | |
188 } | |
189 | |
190 | |
191 jvmtiCapabilities *JvmtiManageCapabilities::exclude(const jvmtiCapabilities *a, const jvmtiCapabilities *b, | |
192 jvmtiCapabilities *result) { | |
193 char *ap = (char *)a; | |
194 char *bp = (char *)b; | |
195 char *resultp = (char *)result; | |
196 | |
197 for (int i = 0; i < CAPA_SIZE; ++i) { | |
198 *resultp++ = *ap++ & ~*bp++; | |
199 } | |
200 | |
201 return result; | |
202 } | |
203 | |
204 | |
205 bool JvmtiManageCapabilities::has_some(const jvmtiCapabilities *a) { | |
206 char *ap = (char *)a; | |
207 | |
208 for (int i = 0; i < CAPA_SIZE; ++i) { | |
209 if (*ap++ != 0) { | |
210 return true; | |
211 } | |
212 } | |
213 | |
214 return false; | |
215 } | |
216 | |
217 | |
218 void JvmtiManageCapabilities::copy_capabilities(const jvmtiCapabilities *from, jvmtiCapabilities *to) { | |
219 char *ap = (char *)from; | |
220 char *resultp = (char *)to; | |
221 | |
222 for (int i = 0; i < CAPA_SIZE; ++i) { | |
223 *resultp++ = *ap++; | |
224 } | |
225 } | |
226 | |
227 | |
228 void JvmtiManageCapabilities::get_potential_capabilities(const jvmtiCapabilities *current, | |
229 const jvmtiCapabilities *prohibited, | |
230 jvmtiCapabilities *result) { | |
231 // exclude prohibited capabilities, must be before adding current | |
232 exclude(&always_capabilities, prohibited, result); | |
233 | |
234 // must include current since it may possess solo capabilities and now prohibited | |
235 either(result, current, result); | |
236 | |
237 // add other remaining | |
238 either(result, &always_solo_remaining_capabilities, result); | |
239 | |
240 // if this is during OnLoad more capabilities are available | |
241 if (JvmtiEnv::get_phase() == JVMTI_PHASE_ONLOAD) { | |
242 either(result, &onload_capabilities, result); | |
243 either(result, &onload_solo_remaining_capabilities, result); | |
244 } | |
245 } | |
246 | |
247 jvmtiError JvmtiManageCapabilities::add_capabilities(const jvmtiCapabilities *current, | |
248 const jvmtiCapabilities *prohibited, | |
249 const jvmtiCapabilities *desired, | |
250 jvmtiCapabilities *result) { | |
251 // check that the capabilities being added are potential capabilities | |
252 jvmtiCapabilities temp; | |
253 get_potential_capabilities(current, prohibited, &temp); | |
254 if (has_some(exclude(desired, &temp, &temp))) { | |
255 return JVMTI_ERROR_NOT_AVAILABLE; | |
256 } | |
257 | |
258 // add to the set of ever acquired capabilities | |
259 either(&acquired_capabilities, desired, &acquired_capabilities); | |
260 | |
261 // onload capabilities that got added are now permanent - so, also remove from onload | |
262 both(&onload_capabilities, desired, &temp); | |
263 either(&always_capabilities, &temp, &always_capabilities); | |
264 exclude(&onload_capabilities, &temp, &onload_capabilities); | |
265 | |
266 // same for solo capabilities (transferred capabilities in the remaining sets handled as part of standard grab - below) | |
267 both(&onload_solo_capabilities, desired, &temp); | |
268 either(&always_solo_capabilities, &temp, &always_solo_capabilities); | |
269 exclude(&onload_solo_capabilities, &temp, &onload_solo_capabilities); | |
270 | |
271 // remove solo capabilities that are now taken | |
272 exclude(&always_solo_remaining_capabilities, desired, &always_solo_remaining_capabilities); | |
273 exclude(&onload_solo_remaining_capabilities, desired, &onload_solo_remaining_capabilities); | |
274 | |
275 // return the result | |
276 either(current, desired, result); | |
277 | |
278 update(); | |
279 | |
280 return JVMTI_ERROR_NONE; | |
281 } | |
282 | |
283 | |
284 void JvmtiManageCapabilities::relinquish_capabilities(const jvmtiCapabilities *current, | |
285 const jvmtiCapabilities *unwanted, | |
286 jvmtiCapabilities *result) { | |
287 jvmtiCapabilities to_trash; | |
288 jvmtiCapabilities temp; | |
289 | |
290 // can't give up what you don't have | |
291 both(current, unwanted, &to_trash); | |
292 | |
293 // restore solo capabilities but only those that belong | |
294 either(&always_solo_remaining_capabilities, both(&always_solo_capabilities, &to_trash, &temp), | |
295 &always_solo_remaining_capabilities); | |
296 either(&onload_solo_remaining_capabilities, both(&onload_solo_capabilities, &to_trash, &temp), | |
297 &onload_solo_remaining_capabilities); | |
298 | |
299 update(); | |
300 | |
301 // return the result | |
302 exclude(current, unwanted, result); | |
303 } | |
304 | |
305 | |
306 void JvmtiManageCapabilities::update() { | |
307 jvmtiCapabilities avail; | |
308 | |
309 // all capabilities | |
310 either(&always_capabilities, &always_solo_capabilities, &avail); | |
311 | |
312 bool interp_events = | |
313 avail.can_generate_field_access_events || | |
314 avail.can_generate_field_modification_events || | |
315 avail.can_generate_single_step_events || | |
316 avail.can_generate_frame_pop_events || | |
317 avail.can_generate_method_entry_events || | |
318 avail.can_generate_method_exit_events; | |
319 bool enter_all_methods = | |
320 interp_events || | |
321 avail.can_generate_breakpoint_events; | |
2442
c2323e2ea62b
6385687: UseFastEmptyMethods/UseFastAccessorMethods considered harmful
never
parents:
1972
diff
changeset
|
322 if (enter_all_methods) { |
c2323e2ea62b
6385687: UseFastEmptyMethods/UseFastAccessorMethods considered harmful
never
parents:
1972
diff
changeset
|
323 // Disable these when tracking the bytecodes |
c2323e2ea62b
6385687: UseFastEmptyMethods/UseFastAccessorMethods considered harmful
never
parents:
1972
diff
changeset
|
324 UseFastEmptyMethods = false; |
c2323e2ea62b
6385687: UseFastEmptyMethods/UseFastAccessorMethods considered harmful
never
parents:
1972
diff
changeset
|
325 UseFastAccessorMethods = false; |
c2323e2ea62b
6385687: UseFastEmptyMethods/UseFastAccessorMethods considered harmful
never
parents:
1972
diff
changeset
|
326 } |
0 | 327 |
328 if (avail.can_generate_breakpoint_events) { | |
329 RewriteFrequentPairs = false; | |
330 } | |
331 | |
332 // If can_redefine_classes is enabled in the onload phase then we know that the | |
333 // dependency information recorded by the compiler is complete. | |
334 if ((avail.can_redefine_classes || avail.can_retransform_classes) && | |
335 JvmtiEnv::get_phase() == JVMTI_PHASE_ONLOAD) { | |
336 JvmtiExport::set_all_dependencies_are_recorded(true); | |
337 } | |
338 | |
339 JvmtiExport::set_can_get_source_debug_extension(avail.can_get_source_debug_extension); | |
340 JvmtiExport::set_can_maintain_original_method_order(avail.can_maintain_original_method_order); | |
341 JvmtiExport::set_can_post_interpreter_events(interp_events); | |
342 JvmtiExport::set_can_hotswap_or_post_breakpoint( | |
343 avail.can_generate_breakpoint_events || | |
344 avail.can_redefine_classes || | |
345 avail.can_retransform_classes); | |
346 JvmtiExport::set_can_modify_any_class( | |
347 avail.can_generate_breakpoint_events || | |
348 avail.can_generate_all_class_hook_events); | |
349 JvmtiExport::set_can_walk_any_space( | |
350 avail.can_tag_objects); // disable sharing in onload phase | |
1397
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
1213
diff
changeset
|
351 // This controls whether the compilers keep extra locals live to |
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
1213
diff
changeset
|
352 // improve the debugging experience so only set them if the selected |
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
1213
diff
changeset
|
353 // capabilities look like a debugger. |
0 | 354 JvmtiExport::set_can_access_local_variables( |
1397
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
1213
diff
changeset
|
355 avail.can_access_local_variables || |
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
1213
diff
changeset
|
356 avail.can_generate_breakpoint_events || |
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
1213
diff
changeset
|
357 avail.can_generate_frame_pop_events); |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1078
diff
changeset
|
358 JvmtiExport::set_can_post_on_exceptions( |
0 | 359 avail.can_generate_exception_events || |
360 avail.can_generate_frame_pop_events || | |
361 avail.can_generate_method_exit_events); | |
362 JvmtiExport::set_can_post_breakpoint(avail.can_generate_breakpoint_events); | |
363 JvmtiExport::set_can_post_field_access(avail.can_generate_field_access_events); | |
364 JvmtiExport::set_can_post_field_modification(avail.can_generate_field_modification_events); | |
365 JvmtiExport::set_can_post_method_entry(avail.can_generate_method_entry_events); | |
366 JvmtiExport::set_can_post_method_exit(avail.can_generate_method_exit_events || | |
367 avail.can_generate_frame_pop_events); | |
368 JvmtiExport::set_can_pop_frame(avail.can_pop_frame); | |
369 JvmtiExport::set_can_force_early_return(avail.can_force_early_return); | |
370 JvmtiExport::set_should_clean_up_heap_objects(avail.can_generate_breakpoint_events); | |
371 } | |
372 | |
373 #ifndef PRODUCT | |
374 | |
375 void JvmtiManageCapabilities:: print(const jvmtiCapabilities* cap) { | |
376 tty->print_cr("----- capabilities -----"); | |
377 if (cap->can_tag_objects) | |
378 tty->print_cr("can_tag_objects"); | |
379 if (cap->can_generate_field_modification_events) | |
380 tty->print_cr("can_generate_field_modification_events"); | |
381 if (cap->can_generate_field_access_events) | |
382 tty->print_cr("can_generate_field_access_events"); | |
383 if (cap->can_get_bytecodes) | |
384 tty->print_cr("can_get_bytecodes"); | |
385 if (cap->can_get_synthetic_attribute) | |
386 tty->print_cr("can_get_synthetic_attribute"); | |
387 if (cap->can_get_owned_monitor_info) | |
388 tty->print_cr("can_get_owned_monitor_info"); | |
389 if (cap->can_get_current_contended_monitor) | |
390 tty->print_cr("can_get_current_contended_monitor"); | |
391 if (cap->can_get_monitor_info) | |
392 tty->print_cr("can_get_monitor_info"); | |
393 if (cap->can_get_constant_pool) | |
394 tty->print_cr("can_get_constant_pool"); | |
395 if (cap->can_pop_frame) | |
396 tty->print_cr("can_pop_frame"); | |
397 if (cap->can_force_early_return) | |
398 tty->print_cr("can_force_early_return"); | |
399 if (cap->can_redefine_classes) | |
400 tty->print_cr("can_redefine_classes"); | |
401 if (cap->can_retransform_classes) | |
402 tty->print_cr("can_retransform_classes"); | |
403 if (cap->can_signal_thread) | |
404 tty->print_cr("can_signal_thread"); | |
405 if (cap->can_get_source_file_name) | |
406 tty->print_cr("can_get_source_file_name"); | |
407 if (cap->can_get_line_numbers) | |
408 tty->print_cr("can_get_line_numbers"); | |
409 if (cap->can_get_source_debug_extension) | |
410 tty->print_cr("can_get_source_debug_extension"); | |
411 if (cap->can_access_local_variables) | |
412 tty->print_cr("can_access_local_variables"); | |
413 if (cap->can_maintain_original_method_order) | |
414 tty->print_cr("can_maintain_original_method_order"); | |
415 if (cap->can_generate_single_step_events) | |
416 tty->print_cr("can_generate_single_step_events"); | |
417 if (cap->can_generate_exception_events) | |
418 tty->print_cr("can_generate_exception_events"); | |
419 if (cap->can_generate_frame_pop_events) | |
420 tty->print_cr("can_generate_frame_pop_events"); | |
421 if (cap->can_generate_breakpoint_events) | |
422 tty->print_cr("can_generate_breakpoint_events"); | |
423 if (cap->can_suspend) | |
424 tty->print_cr("can_suspend"); | |
425 if (cap->can_redefine_any_class ) | |
426 tty->print_cr("can_redefine_any_class"); | |
427 if (cap->can_retransform_any_class ) | |
428 tty->print_cr("can_retransform_any_class"); | |
429 if (cap->can_get_current_thread_cpu_time) | |
430 tty->print_cr("can_get_current_thread_cpu_time"); | |
431 if (cap->can_get_thread_cpu_time) | |
432 tty->print_cr("can_get_thread_cpu_time"); | |
433 if (cap->can_generate_method_entry_events) | |
434 tty->print_cr("can_generate_method_entry_events"); | |
435 if (cap->can_generate_method_exit_events) | |
436 tty->print_cr("can_generate_method_exit_events"); | |
437 if (cap->can_generate_all_class_hook_events) | |
438 tty->print_cr("can_generate_all_class_hook_events"); | |
439 if (cap->can_generate_compiled_method_load_events) | |
440 tty->print_cr("can_generate_compiled_method_load_events"); | |
441 if (cap->can_generate_monitor_events) | |
442 tty->print_cr("can_generate_monitor_events"); | |
443 if (cap->can_generate_vm_object_alloc_events) | |
444 tty->print_cr("can_generate_vm_object_alloc_events"); | |
445 if (cap->can_generate_native_method_bind_events) | |
446 tty->print_cr("can_generate_native_method_bind_events"); | |
447 if (cap->can_generate_garbage_collection_events) | |
448 tty->print_cr("can_generate_garbage_collection_events"); | |
449 if (cap->can_generate_object_free_events) | |
450 tty->print_cr("can_generate_object_free_events"); | |
451 if (cap->can_generate_resource_exhaustion_heap_events) | |
452 tty->print_cr("can_generate_resource_exhaustion_heap_events"); | |
453 if (cap->can_generate_resource_exhaustion_threads_events) | |
454 tty->print_cr("can_generate_resource_exhaustion_threads_events"); | |
455 } | |
456 | |
457 #endif |