comparison src/share/vm/ci/ciEnv.cpp @ 14518:d8041d695d19

Merged with jdk9/dev/hotspot changeset 3812c088b945
author twisti
date Tue, 11 Mar 2014 18:45:59 -0700
parents 02f27ecb4f3a 96d2c94bbdd0
children 4ca6dc0799b6
comparison
equal deleted inserted replaced
14141:f97c5ec83832 14518:d8041d695d19
134 _ArrayIndexOutOfBoundsException_instance = NULL; 134 _ArrayIndexOutOfBoundsException_instance = NULL;
135 _ArrayStoreException_instance = NULL; 135 _ArrayStoreException_instance = NULL;
136 _ClassCastException_instance = NULL; 136 _ClassCastException_instance = NULL;
137 _the_null_string = NULL; 137 _the_null_string = NULL;
138 _the_min_jint_string = NULL; 138 _the_min_jint_string = NULL;
139
140 _jvmti_can_hotswap_or_post_breakpoint = false;
141 _jvmti_can_access_local_variables = false;
142 _jvmti_can_post_on_exceptions = false;
143 _jvmti_can_pop_frame = false;
139 } 144 }
140 145
141 ciEnv::ciEnv(Arena* arena) { 146 ciEnv::ciEnv(Arena* arena) {
142 ASSERT_IN_VM; 147 ASSERT_IN_VM;
143 148
184 _ArrayIndexOutOfBoundsException_instance = NULL; 189 _ArrayIndexOutOfBoundsException_instance = NULL;
185 _ArrayStoreException_instance = NULL; 190 _ArrayStoreException_instance = NULL;
186 _ClassCastException_instance = NULL; 191 _ClassCastException_instance = NULL;
187 _the_null_string = NULL; 192 _the_null_string = NULL;
188 _the_min_jint_string = NULL; 193 _the_min_jint_string = NULL;
194
195 _jvmti_can_hotswap_or_post_breakpoint = false;
196 _jvmti_can_access_local_variables = false;
197 _jvmti_can_post_on_exceptions = false;
198 _jvmti_can_pop_frame = false;
189 } 199 }
190 200
191 ciEnv::~ciEnv() { 201 ciEnv::~ciEnv() {
192 CompilerThread* current_thread = CompilerThread::current(); 202 CompilerThread* current_thread = CompilerThread::current();
193 _factory->remove_symbols(); 203 _factory->remove_symbols();
203 // Get Jvmti capabilities under lock to get consistant values. 213 // Get Jvmti capabilities under lock to get consistant values.
204 MutexLocker mu(JvmtiThreadState_lock); 214 MutexLocker mu(JvmtiThreadState_lock);
205 _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint(); 215 _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
206 _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables(); 216 _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables();
207 _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions(); 217 _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions();
218 _jvmti_can_pop_frame = JvmtiExport::can_pop_frame();
219 }
220
221 bool ciEnv::should_retain_local_variables() const {
222 return _jvmti_can_access_local_variables || _jvmti_can_pop_frame;
223 }
224
225 bool ciEnv::jvmti_state_changed() const {
226 if (!_jvmti_can_access_local_variables &&
227 JvmtiExport::can_access_local_variables()) {
228 return true;
229 }
230 if (!_jvmti_can_hotswap_or_post_breakpoint &&
231 JvmtiExport::can_hotswap_or_post_breakpoint()) {
232 return true;
233 }
234 if (!_jvmti_can_post_on_exceptions &&
235 JvmtiExport::can_post_on_exceptions()) {
236 return true;
237 }
238 if (!_jvmti_can_pop_frame &&
239 JvmtiExport::can_pop_frame()) {
240 return true;
241 }
242 return false;
208 } 243 }
209 244
210 // ------------------------------------------------------------------ 245 // ------------------------------------------------------------------
211 // Cache DTrace flags 246 // Cache DTrace flags
212 void ciEnv::cache_dtrace_flags() { 247 void ciEnv::cache_dtrace_flags() {
938 // No safepoints are allowed. Otherwise, class redefinition can occur in between. 973 // No safepoints are allowed. Otherwise, class redefinition can occur in between.
939 MutexLocker ml(Compile_lock); 974 MutexLocker ml(Compile_lock);
940 No_Safepoint_Verifier nsv; 975 No_Safepoint_Verifier nsv;
941 976
942 // Change in Jvmti state may invalidate compilation. 977 // Change in Jvmti state may invalidate compilation.
943 if (!failing() && 978 if (!failing() && jvmti_state_changed()) {
944 ( (!jvmti_can_hotswap_or_post_breakpoint() &&
945 JvmtiExport::can_hotswap_or_post_breakpoint()) ||
946 (!jvmti_can_access_local_variables() &&
947 JvmtiExport::can_access_local_variables()) ||
948 (!jvmti_can_post_on_exceptions() &&
949 JvmtiExport::can_post_on_exceptions()) )) {
950 record_failure("Jvmti state change invalidated dependencies"); 979 record_failure("Jvmti state change invalidated dependencies");
951 } 980 }
952 981
953 // Change in DTrace flags may invalidate compilation. 982 // Change in DTrace flags may invalidate compilation.
954 if (!failing() && 983 if (!failing() &&
1145 // ------------------------------------------------------------------ 1174 // ------------------------------------------------------------------
1146 // ciEnv::dump_replay_data* 1175 // ciEnv::dump_replay_data*
1147 1176
1148 // Don't change thread state and acquire any locks. 1177 // Don't change thread state and acquire any locks.
1149 // Safe to call from VM error reporter. 1178 // Safe to call from VM error reporter.
1179
1180 void ciEnv::dump_compile_data(outputStream* out) {
1181 CompileTask* task = this->task();
1182 Method* method = task->method();
1183 int entry_bci = task->osr_bci();
1184 int comp_level = task->comp_level();
1185 out->print("compile %s %s %s %d %d",
1186 method->klass_name()->as_quoted_ascii(),
1187 method->name()->as_quoted_ascii(),
1188 method->signature()->as_quoted_ascii(),
1189 entry_bci, comp_level);
1190 if (compiler_data() != NULL) {
1191 if (is_c2_compile(comp_level)) { // C2 or Shark
1192 #ifdef COMPILER2
1193 // Dump C2 inlining data.
1194 ((Compile*)compiler_data())->dump_inline_data(out);
1195 #endif
1196 } else if (is_c1_compile(comp_level)) { // C1
1197 #ifdef COMPILER1
1198 // Dump C1 inlining data.
1199 ((Compilation*)compiler_data())->dump_inline_data(out);
1200 #endif
1201 }
1202 }
1203 out->cr();
1204 }
1205
1150 void ciEnv::dump_replay_data_unsafe(outputStream* out) { 1206 void ciEnv::dump_replay_data_unsafe(outputStream* out) {
1151 ResourceMark rm; 1207 ResourceMark rm;
1152 #if INCLUDE_JVMTI 1208 #if INCLUDE_JVMTI
1153 out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables); 1209 out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables);
1154 out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint); 1210 out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint);
1158 GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata(); 1214 GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata();
1159 out->print_cr("# %d ciObject found", objects->length()); 1215 out->print_cr("# %d ciObject found", objects->length());
1160 for (int i = 0; i < objects->length(); i++) { 1216 for (int i = 0; i < objects->length(); i++) {
1161 objects->at(i)->dump_replay_data(out); 1217 objects->at(i)->dump_replay_data(out);
1162 } 1218 }
1163 CompileTask* task = this->task(); 1219 dump_compile_data(out);
1164 Method* method = task->method();
1165 int entry_bci = task->osr_bci();
1166 int comp_level = task->comp_level();
1167 // Klass holder = method->method_holder();
1168 out->print_cr("compile %s %s %s %d %d",
1169 method->klass_name()->as_quoted_ascii(),
1170 method->name()->as_quoted_ascii(),
1171 method->signature()->as_quoted_ascii(),
1172 entry_bci, comp_level);
1173 out->flush(); 1220 out->flush();
1174 } 1221 }
1175 1222
1176 void ciEnv::dump_replay_data(outputStream* out) { 1223 void ciEnv::dump_replay_data(outputStream* out) {
1177 GUARDED_VM_ENTRY( 1224 GUARDED_VM_ENTRY(
1178 MutexLocker ml(Compile_lock); 1225 MutexLocker ml(Compile_lock);
1179 dump_replay_data_unsafe(out); 1226 dump_replay_data_unsafe(out);
1180 ) 1227 )
1181 } 1228 }
1229
1230 void ciEnv::dump_replay_data(int compile_id) {
1231 static char buffer[O_BUFLEN];
1232 int ret = jio_snprintf(buffer, O_BUFLEN, "replay_pid%p_compid%d.log", os::current_process_id(), compile_id);
1233 if (ret > 0) {
1234 int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
1235 if (fd != -1) {
1236 FILE* replay_data_file = os::open(fd, "w");
1237 if (replay_data_file != NULL) {
1238 fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
1239 dump_replay_data(&replay_data_stream);
1240 tty->print("# Compiler replay data is saved as: ");
1241 tty->print_cr(buffer);
1242 } else {
1243 tty->print_cr("# Can't open file to dump replay data.");
1244 }
1245 }
1246 }
1247 }
1248
1249 void ciEnv::dump_inline_data(int compile_id) {
1250 static char buffer[O_BUFLEN];
1251 int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id);
1252 if (ret > 0) {
1253 int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
1254 if (fd != -1) {
1255 FILE* inline_data_file = os::open(fd, "w");
1256 if (inline_data_file != NULL) {
1257 fileStream replay_data_stream(inline_data_file, /*need_close=*/true);
1258 GUARDED_VM_ENTRY(
1259 MutexLocker ml(Compile_lock);
1260 dump_compile_data(&replay_data_stream);
1261 )
1262 replay_data_stream.flush();
1263 tty->print("# Compiler inline data is saved as: ");
1264 tty->print_cr(buffer);
1265 } else {
1266 tty->print_cr("# Can't open file to dump inline data.");
1267 }
1268 }
1269 }
1270 }