hotspot/src/share/vm/ci/ciEnv.cpp
changeset 22243 91944eab7b92
parent 21727 4a5fc611c9a7
child 22893 e3a2b513713a
equal deleted inserted replaced
22242:07e4f028ec7a 22243:91944eab7b92
  1145 // ------------------------------------------------------------------
  1145 // ------------------------------------------------------------------
  1146 // ciEnv::dump_replay_data*
  1146 // ciEnv::dump_replay_data*
  1147 
  1147 
  1148 // Don't change thread state and acquire any locks.
  1148 // Don't change thread state and acquire any locks.
  1149 // Safe to call from VM error reporter.
  1149 // Safe to call from VM error reporter.
       
  1150 
       
  1151 void ciEnv::dump_compile_data(outputStream* out) {
       
  1152   CompileTask* task = this->task();
       
  1153   Method* method = task->method();
       
  1154   int entry_bci = task->osr_bci();
       
  1155   int comp_level = task->comp_level();
       
  1156   out->print("compile %s %s %s %d %d",
       
  1157                 method->klass_name()->as_quoted_ascii(),
       
  1158                 method->name()->as_quoted_ascii(),
       
  1159                 method->signature()->as_quoted_ascii(),
       
  1160                 entry_bci, comp_level);
       
  1161   if (compiler_data() != NULL) {
       
  1162     if (is_c2_compile(comp_level)) { // C2 or Shark
       
  1163 #ifdef COMPILER2
       
  1164       // Dump C2 inlining data.
       
  1165       ((Compile*)compiler_data())->dump_inline_data(out);
       
  1166 #endif
       
  1167     } else if (is_c1_compile(comp_level)) { // C1
       
  1168 #ifdef COMPILER1
       
  1169       // Dump C1 inlining data.
       
  1170       ((Compilation*)compiler_data())->dump_inline_data(out);
       
  1171 #endif
       
  1172     }
       
  1173   }
       
  1174   out->cr();
       
  1175 }
       
  1176 
  1150 void ciEnv::dump_replay_data_unsafe(outputStream* out) {
  1177 void ciEnv::dump_replay_data_unsafe(outputStream* out) {
  1151   ResourceMark rm;
  1178   ResourceMark rm;
  1152 #if INCLUDE_JVMTI
  1179 #if INCLUDE_JVMTI
  1153   out->print_cr("JvmtiExport can_access_local_variables %d",     _jvmti_can_access_local_variables);
  1180   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);
  1181   out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint);
  1158   GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata();
  1185   GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata();
  1159   out->print_cr("# %d ciObject found", objects->length());
  1186   out->print_cr("# %d ciObject found", objects->length());
  1160   for (int i = 0; i < objects->length(); i++) {
  1187   for (int i = 0; i < objects->length(); i++) {
  1161     objects->at(i)->dump_replay_data(out);
  1188     objects->at(i)->dump_replay_data(out);
  1162   }
  1189   }
  1163   CompileTask* task = this->task();
  1190   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();
  1191   out->flush();
  1174 }
  1192 }
  1175 
  1193 
  1176 void ciEnv::dump_replay_data(outputStream* out) {
  1194 void ciEnv::dump_replay_data(outputStream* out) {
  1177   GUARDED_VM_ENTRY(
  1195   GUARDED_VM_ENTRY(
  1178     MutexLocker ml(Compile_lock);
  1196     MutexLocker ml(Compile_lock);
  1179     dump_replay_data_unsafe(out);
  1197     dump_replay_data_unsafe(out);
  1180   )
  1198   )
  1181 }
  1199 }
       
  1200 
       
  1201 void ciEnv::dump_replay_data(int compile_id) {
       
  1202   static char buffer[O_BUFLEN];
       
  1203   int ret = jio_snprintf(buffer, O_BUFLEN, "replay_pid%p_compid%d.log", os::current_process_id(), compile_id);
       
  1204   if (ret > 0) {
       
  1205     int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
       
  1206     if (fd != -1) {
       
  1207       FILE* replay_data_file = os::open(fd, "w");
       
  1208       if (replay_data_file != NULL) {
       
  1209         fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
       
  1210         dump_replay_data(&replay_data_stream);
       
  1211         tty->print("# Compiler replay data is saved as: ");
       
  1212         tty->print_cr(buffer);
       
  1213       } else {
       
  1214         tty->print_cr("# Can't open file to dump replay data.");
       
  1215       }
       
  1216     }
       
  1217   }
       
  1218 }
       
  1219 
       
  1220 void ciEnv::dump_inline_data(int compile_id) {
       
  1221   static char buffer[O_BUFLEN];
       
  1222   int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id);
       
  1223   if (ret > 0) {
       
  1224     int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
       
  1225     if (fd != -1) {
       
  1226       FILE* inline_data_file = os::open(fd, "w");
       
  1227       if (inline_data_file != NULL) {
       
  1228         fileStream replay_data_stream(inline_data_file, /*need_close=*/true);
       
  1229         GUARDED_VM_ENTRY(
       
  1230           MutexLocker ml(Compile_lock);
       
  1231           dump_compile_data(&replay_data_stream);
       
  1232         )
       
  1233         replay_data_stream.flush();
       
  1234         tty->print("# Compiler inline data is saved as: ");
       
  1235         tty->print_cr(buffer);
       
  1236       } else {
       
  1237         tty->print_cr("# Can't open file to dump inline data.");
       
  1238       }
       
  1239     }
       
  1240   }
       
  1241 }