Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/compiler/compileBroker.cpp
          +++ new/src/share/vm/compiler/compileBroker.cpp
↓ open down ↓ 260 lines elided ↑ open up ↑
 261  261  void CompileTask::print() {
 262  262    tty->print("<CompileTask compile_id=%d ", _compile_id);
 263  263    tty->print("method=");
 264  264    ((methodOop)JNIHandles::resolve(_method))->print_name(tty);
 265  265    tty->print_cr(" osr_bci=%d is_blocking=%s is_complete=%s is_success=%s>",
 266  266               _osr_bci, bool_to_str(_is_blocking),
 267  267               bool_to_str(_is_complete), bool_to_str(_is_success));
 268  268  }
 269  269  
 270  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  271  // ------------------------------------------------------------------
 277  272  // CompileTask::print_line_on_error
 278  273  //
 279  274  // This function is called by fatal error handler when the thread
 280  275  // causing troubles is a compiler thread.
 281  276  //
 282  277  // Do not grab any lock, do not allocate memory.
 283  278  //
 284  279  // Otherwise it's the same as CompileTask::print_line()
 285  280  //
 286  281  void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) {
 287      -  methodOop method = (methodOop)JNIHandles::resolve(_method);
 288  282    // print compiler name
 289  283    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);
      284 +  print_compilation(st);
 295  285  }
 296  286  
 297  287  // ------------------------------------------------------------------
 298  288  // CompileTask::print_line
 299  289  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  290    ttyLocker ttyl;  // keep the following output all in one block
 306      -
 307  291    // print compiler name if requested
 308  292    if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name());
 309      -  print_compilation(tty, method(), NULL);
      293 +  print_compilation();
 310  294  }
 311  295  
 312  296  
 313  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 +// ------------------------------------------------------------------
 314  393  // CompileTask::log_task
 315  394  void CompileTask::log_task(xmlStream* log) {
 316  395    Thread* thread = Thread::current();
 317  396    methodHandle method(thread,
 318  397                        (methodOop)JNIHandles::resolve(method_handle()));
 319  398    ResourceMark rm(thread);
 320  399  
 321  400    // <task id='9' method='M' osr_bci='X' level='1' blocking='1' stamp='1.234'>
 322  401    if (_compile_id != 0)   log->print(" compile_id='%d'", _compile_id);
 323  402    if (_osr_bci != CompileBroker::standard_entry_bci) {
↓ open down ↓ 755 lines elided ↑ open up ↑
1079 1158    // If the compiler is shut off due to code cache flushing or otherwise,
1080 1159    // fail out now so blocking compiles dont hang the java thread
1081 1160    if (!should_compile_new_jobs() || (UseCodeCacheFlushing && CodeCache::needs_flushing())) {
1082 1161      CompilationPolicy::policy()->delay_compilation(method());
1083 1162      return NULL;
1084 1163    }
1085 1164  
1086 1165    // do the compilation
1087 1166    if (method->is_native()) {
1088 1167      if (!PreferInterpreterNativeStubs) {
1089      -      (void) AdapterHandlerLibrary::create_native_wrapper(method);
     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);
1090 1175      } else {
1091 1176        return NULL;
1092 1177      }
1093 1178    } else {
1094 1179      compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, CHECK_0);
1095 1180    }
1096 1181  
1097 1182    // return requested nmethod
1098 1183    // We accept a higher level osr method
1099 1184    return osr_bci  == InvocationEntryBci ? method->code() : method->lookup_osr_nmethod_for(osr_bci, comp_level, false);
↓ open down ↓ 87 lines elided ↑ open up ↑
1187 1272  // CompileBroker::assign_compile_id
1188 1273  //
1189 1274  // Assign a serialized id number to this compilation request.  If the
1190 1275  // number falls out of the allowed range, return a 0.  OSR
1191 1276  // compilations may be numbered separately from regular compilations
1192 1277  // if certain debugging flags are used.
1193 1278  uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) {
1194 1279    assert(MethodCompileQueue_lock->owner() == Thread::current(),
1195 1280           "must hold the compilation queue lock");
1196 1281    bool is_osr = (osr_bci != standard_entry_bci);
1197      -  assert(!method->is_native(), "no longer compile natives");
1198 1282    uint id;
1199 1283    if (CICountOSR && is_osr) {
1200 1284      id = ++_osr_compilation_id;
1201 1285      if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) {
1202 1286        return id;
1203 1287      }
1204 1288    } else {
1205 1289      id = ++_compilation_id;
1206 1290      if ((uint)CIStart <= id && id < (uint)CIStop) {
1207 1291        return id;
↓ open down ↓ 721 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX