src/share/vm/compiler/compileBroker.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7022998 Sdiff src/share/vm/compiler

src/share/vm/compiler/compileBroker.cpp

Print this page




 251   assert(!_lock->is_locked(), "Should not be locked when freed");
 252   if (_hot_method != NULL && _hot_method != _method) {
 253     JNIHandles::destroy_global(_hot_method);
 254   }
 255   JNIHandles::destroy_global(_method);
 256 }
 257 
 258 
 259 // ------------------------------------------------------------------
 260 // CompileTask::print
 261 void CompileTask::print() {
 262   tty->print("<CompileTask compile_id=%d ", _compile_id);
 263   tty->print("method=");
 264   ((methodOop)JNIHandles::resolve(_method))->print_name(tty);
 265   tty->print_cr(" osr_bci=%d is_blocking=%s is_complete=%s is_success=%s>",
 266              _osr_bci, bool_to_str(_is_blocking),
 267              bool_to_str(_is_complete), bool_to_str(_is_success));
 268 }
 269 
 270 
 271 void CompileTask::print_compilation(outputStream *st, methodOop method, char* method_name) {
 272   nmethod::print_compilation(st, method_name,/*title*/ NULL, method,
 273                              is_blocking(), compile_id(), osr_bci(), comp_level());
 274 }
 275 
 276 // ------------------------------------------------------------------
 277 // CompileTask::print_line_on_error
 278 //
 279 // This function is called by fatal error handler when the thread
 280 // causing troubles is a compiler thread.
 281 //
 282 // Do not grab any lock, do not allocate memory.
 283 //
 284 // Otherwise it's the same as CompileTask::print_line()
 285 //
 286 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
 287   methodOop method = (methodOop)JNIHandles::resolve(_method);
 288   // print compiler name
 289   st->print("%s:", CompileBroker::compiler(comp_level())->name());
 290   char* method_name = NULL;
 291   if (method != NULL) {
 292     method_name = method->name_and_sig_as_C_string(buf, buflen);
 293   }
 294   print_compilation(st, method, method_name);
 295 }
 296 
 297 // ------------------------------------------------------------------
 298 // CompileTask::print_line
 299 void CompileTask::print_line() {
 300   Thread *thread = Thread::current();
 301   methodHandle method(thread,
 302                       (methodOop)JNIHandles::resolve(method_handle()));
 303   ResourceMark rm(thread);
 304 
 305   ttyLocker ttyl;  // keep the following output all in one block
 306 
 307   // print compiler name if requested
 308   if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name());
 309   print_compilation(tty, method(), NULL);





































































 310 }
 311 


























 312 
 313 // ------------------------------------------------------------------
 314 // CompileTask::log_task
 315 void CompileTask::log_task(xmlStream* log) {
 316   Thread* thread = Thread::current();
 317   methodHandle method(thread,
 318                       (methodOop)JNIHandles::resolve(method_handle()));
 319   ResourceMark rm(thread);
 320 
 321   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
 322   if (_compile_id != 0)   log->print(" compile_id='%d'", _compile_id);
 323   if (_osr_bci != CompileBroker::standard_entry_bci) {
 324     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
 325   } // else compile_kind='c2c'
 326   if (!method.is_null())  log->method(method);
 327   if (_osr_bci != CompileBroker::standard_entry_bci) {
 328     log->print(" osr_bci='%d'", _osr_bci);
 329   }
 330   if (_comp_level != CompLevel_highest_tier) {
 331     log->print(" level='%d'", _comp_level);


1069   if (method->is_old()) {
1070     return NULL;
1071   }
1072 
1073   // JVMTI -- post_compile_event requires jmethod_id() that may require
1074   // a lock the compiling thread can not acquire. Prefetch it here.
1075   if (JvmtiExport::should_post_compiled_method_load()) {
1076     method->jmethod_id();
1077   }
1078 
1079   // If the compiler is shut off due to code cache flushing or otherwise,
1080   // fail out now so blocking compiles dont hang the java thread
1081   if (!should_compile_new_jobs() || (UseCodeCacheFlushing && CodeCache::needs_flushing())) {
1082     CompilationPolicy::policy()->delay_compilation(method());
1083     return NULL;
1084   }
1085 
1086   // do the compilation
1087   if (method->is_native()) {
1088     if (!PreferInterpreterNativeStubs) {
1089       (void) AdapterHandlerLibrary::create_native_wrapper(method);






1090     } else {
1091       return NULL;
1092     }
1093   } else {
1094     compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, CHECK_0);
1095   }
1096 
1097   // return requested nmethod
1098   // We accept a higher level osr method
1099   return osr_bci  == InvocationEntryBci ? method->code() : method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
1100 }
1101 
1102 
1103 // ------------------------------------------------------------------
1104 // CompileBroker::compilation_is_complete
1105 //
1106 // See if compilation of this method is already complete.
1107 bool CompileBroker::compilation_is_complete(methodHandle method,
1108                                             int          osr_bci,
1109                                             int          comp_level) {


1177       tty->cr();
1178     }
1179     method->set_not_compilable_quietly();
1180   }
1181 
1182   return false;
1183 }
1184 
1185 
1186 // ------------------------------------------------------------------
1187 // CompileBroker::assign_compile_id
1188 //
1189 // Assign a serialized id number to this compilation request.  If the
1190 // number falls out of the allowed range, return a 0.  OSR
1191 // compilations may be numbered separately from regular compilations
1192 // if certain debugging flags are used.
1193 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) {
1194   assert(MethodCompileQueue_lock->owner() == Thread::current(),
1195          "must hold the compilation queue lock");
1196   bool is_osr = (osr_bci != standard_entry_bci);
1197   assert(!method->is_native(), "no longer compile natives");
1198   uint id;
1199   if (CICountOSR && is_osr) {
1200     id = ++_osr_compilation_id;
1201     if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) {
1202       return id;
1203     }
1204   } else {
1205     id = ++_compilation_id;
1206     if ((uint)CIStart <= id && id < (uint)CIStop) {
1207       return id;
1208     }
1209   }
1210 
1211   // Method was not in the appropriate compilation range.
1212   method->set_not_compilable_quietly();
1213   return 0;
1214 }
1215 
1216 
1217 // ------------------------------------------------------------------




 251   assert(!_lock->is_locked(), "Should not be locked when freed");
 252   if (_hot_method != NULL && _hot_method != _method) {
 253     JNIHandles::destroy_global(_hot_method);
 254   }
 255   JNIHandles::destroy_global(_method);
 256 }
 257 
 258 
 259 // ------------------------------------------------------------------
 260 // CompileTask::print
 261 void CompileTask::print() {
 262   tty->print("<CompileTask compile_id=%d ", _compile_id);
 263   tty->print("method=");
 264   ((methodOop)JNIHandles::resolve(_method))->print_name(tty);
 265   tty->print_cr(" osr_bci=%d is_blocking=%s is_complete=%s is_success=%s>",
 266              _osr_bci, bool_to_str(_is_blocking),
 267              bool_to_str(_is_complete), bool_to_str(_is_success));
 268 }
 269 
 270 





 271 // ------------------------------------------------------------------
 272 // CompileTask::print_line_on_error
 273 //
 274 // This function is called by fatal error handler when the thread
 275 // causing troubles is a compiler thread.
 276 //
 277 // Do not grab any lock, do not allocate memory.
 278 //
 279 // Otherwise it's the same as CompileTask::print_line()
 280 //
 281 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {

 282   // print compiler name
 283   st->print("%s:", CompileBroker::compiler(comp_level())->name());
 284   print_compilation(st);




 285 }
 286 
 287 // ------------------------------------------------------------------
 288 // CompileTask::print_line
 289 void CompileTask::print_line() {





 290   ttyLocker ttyl;  // keep the following output all in one block

 291   // print compiler name if requested
 292   if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name());
 293   print_compilation();
 294 }
 295 
 296 
 297 // ------------------------------------------------------------------
 298 // CompileTask::print_compilation_impl
 299 void CompileTask::print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level, bool is_osr_method, int osr_bci, bool is_blocking, const char* msg) {
 300   st->print("%7d ", (int) st->time_stamp().milliseconds());  // print timestamp
 301   st->print("%4d ", compile_id);    // print compilation number
 302 
 303   // method attributes
 304   const char compile_type   = is_osr_method                   ? '%' : ' ';
 305   const char sync_char      = method->is_synchronized()       ? 's' : ' ';
 306   const char exception_char = method->has_exception_handler() ? '!' : ' ';
 307   const char blocking_char  = is_blocking                     ? 'b' : ' ';
 308   const char native_char    = method->is_native()             ? 'n' : ' ';
 309 
 310   // print method attributes
 311   st->print("%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char);
 312 
 313   if (TieredCompilation) {
 314     if (comp_level != -1)  st->print("%d ", comp_level);
 315     else                   st->print("- ");
 316   }
 317   st->print("     ");  // more indent
 318 
 319   method->print_short_name(st);
 320   if (is_osr_method) {
 321     st->print(" @ %d", osr_bci);
 322   }
 323   st->print(" (%d bytes)", method->code_size());
 324 
 325   if (msg != NULL) {
 326     st->print("   %s", msg);
 327   }
 328   st->cr();
 329 }
 330 
 331 // ------------------------------------------------------------------
 332 // CompileTask::print_inlining
 333 void CompileTask::print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg) {
 334   //         1234567
 335   st->print("        ");     // print timestamp
 336   //         1234
 337   st->print("     ");        // print compilation number
 338 
 339   // method attributes
 340   const char sync_char      = method->is_synchronized()        ? 's' : ' ';
 341   const char exception_char = method->has_exception_handlers() ? '!' : ' ';
 342   const char monitors_char  = method->has_monitor_bytecodes()  ? 'm' : ' ';
 343 
 344   // print method attributes
 345   st->print(" %c%c%c  ", sync_char, exception_char, monitors_char);
 346 
 347   if (TieredCompilation) {
 348     st->print("  ");
 349   }
 350   st->print("     ");        // more indent
 351   st->print("    ");         // initial inlining indent
 352 
 353   for (int i = 0; i < inline_level; i++)  st->print("  ");
 354 
 355   st->print("@ %d  ", bci);  // print bci
 356   method->print_short_name(st);
 357   st->print(" (%d bytes)", method->code_size());
 358 
 359   if (msg != NULL) {
 360     st->print("   %s", msg);
 361   }
 362   st->cr();
 363 }
 364 
 365 // ------------------------------------------------------------------
 366 // CompileTask::print_inline_indent
 367 void CompileTask::print_inline_indent(int inline_level, outputStream* st) {
 368   //         1234567
 369   st->print("        ");     // print timestamp
 370   //         1234
 371   st->print("     ");        // print compilation number
 372   //         %s!bn
 373   st->print("      ");       // print method attributes
 374   if (TieredCompilation) {
 375     st->print("  ");
 376   }
 377   st->print("     ");        // more indent
 378   st->print("    ");         // initial inlining indent
 379   for (int i = 0; i < inline_level; i++)  st->print("  ");
 380 }
 381 
 382 // ------------------------------------------------------------------
 383 // CompileTask::print_compilation
 384 void CompileTask::print_compilation(outputStream* st) {
 385   oop rem = JNIHandles::resolve(method_handle());
 386   assert(rem != NULL && rem->is_method(), "must be");
 387   methodOop method = (methodOop) rem;
 388   bool is_osr_method = osr_bci() != InvocationEntryBci;
 389   print_compilation_impl(st, method, compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking());
 390 }
 391 
 392 // ------------------------------------------------------------------
 393 // CompileTask::log_task
 394 void CompileTask::log_task(xmlStream* log) {
 395   Thread* thread = Thread::current();
 396   methodHandle method(thread,
 397                       (methodOop)JNIHandles::resolve(method_handle()));
 398   ResourceMark rm(thread);
 399 
 400   // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
 401   if (_compile_id != 0)   log->print(" compile_id='%d'", _compile_id);
 402   if (_osr_bci != CompileBroker::standard_entry_bci) {
 403     log->print(" compile_kind='osr'");  // same as nmethod::compile_kind
 404   } // else compile_kind='c2c'
 405   if (!method.is_null())  log->method(method);
 406   if (_osr_bci != CompileBroker::standard_entry_bci) {
 407     log->print(" osr_bci='%d'", _osr_bci);
 408   }
 409   if (_comp_level != CompLevel_highest_tier) {
 410     log->print(" level='%d'", _comp_level);


1148   if (method->is_old()) {
1149     return NULL;
1150   }
1151 
1152   // JVMTI -- post_compile_event requires jmethod_id() that may require
1153   // a lock the compiling thread can not acquire. Prefetch it here.
1154   if (JvmtiExport::should_post_compiled_method_load()) {
1155     method->jmethod_id();
1156   }
1157 
1158   // If the compiler is shut off due to code cache flushing or otherwise,
1159   // fail out now so blocking compiles dont hang the java thread
1160   if (!should_compile_new_jobs() || (UseCodeCacheFlushing && CodeCache::needs_flushing())) {
1161     CompilationPolicy::policy()->delay_compilation(method());
1162     return NULL;
1163   }
1164 
1165   // do the compilation
1166   if (method->is_native()) {
1167     if (!PreferInterpreterNativeStubs) {
1168       // Acquire our lock.
1169       int compile_id;
1170       {
1171         MutexLocker locker(MethodCompileQueue_lock, THREAD);
1172         compile_id = assign_compile_id(method, standard_entry_bci);
1173       }
1174       (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id);
1175     } else {
1176       return NULL;
1177     }
1178   } else {
1179     compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, CHECK_0);
1180   }
1181 
1182   // return requested nmethod
1183   // We accept a higher level osr method
1184   return osr_bci  == InvocationEntryBci ? method->code() : method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
1185 }
1186 
1187 
1188 // ------------------------------------------------------------------
1189 // CompileBroker::compilation_is_complete
1190 //
1191 // See if compilation of this method is already complete.
1192 bool CompileBroker::compilation_is_complete(methodHandle method,
1193                                             int          osr_bci,
1194                                             int          comp_level) {


1262       tty->cr();
1263     }
1264     method->set_not_compilable_quietly();
1265   }
1266 
1267   return false;
1268 }
1269 
1270 
1271 // ------------------------------------------------------------------
1272 // CompileBroker::assign_compile_id
1273 //
1274 // Assign a serialized id number to this compilation request.  If the
1275 // number falls out of the allowed range, return a 0.  OSR
1276 // compilations may be numbered separately from regular compilations
1277 // if certain debugging flags are used.
1278 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) {
1279   assert(MethodCompileQueue_lock->owner() == Thread::current(),
1280          "must hold the compilation queue lock");
1281   bool is_osr = (osr_bci != standard_entry_bci);

1282   uint id;
1283   if (CICountOSR && is_osr) {
1284     id = ++_osr_compilation_id;
1285     if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) {
1286       return id;
1287     }
1288   } else {
1289     id = ++_compilation_id;
1290     if ((uint)CIStart <= id && id < (uint)CIStop) {
1291       return id;
1292     }
1293   }
1294 
1295   // Method was not in the appropriate compilation range.
1296   method->set_not_compilable_quietly();
1297   return 0;
1298 }
1299 
1300 
1301 // ------------------------------------------------------------------


src/share/vm/compiler/compileBroker.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File