annotate src/share/vm/prims/jvmtiManageCapabilities.cpp @ 1716:be3f9c242c9d

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