Mercurial > hg > graal-compiler
comparison src/share/vm/compiler/compileBroker.cpp @ 2405:3d58a4983660
7022998: JSR 292 recursive method handle calls inline themselves infinitely
Reviewed-by: never, kvn
author | twisti |
---|---|
date | Mon, 28 Mar 2011 03:58:07 -0700 |
parents | 1927db75dd85 |
children | e863062e521d |
comparison
equal
deleted
inserted
replaced
2404:b40d4fa697bf | 2405:3d58a4983660 |
---|---|
266 _osr_bci, bool_to_str(_is_blocking), | 266 _osr_bci, bool_to_str(_is_blocking), |
267 bool_to_str(_is_complete), bool_to_str(_is_success)); | 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 // CompileTask::print_line_on_error | 272 // CompileTask::print_line_on_error |
278 // | 273 // |
279 // This function is called by fatal error handler when the thread | 274 // This function is called by fatal error handler when the thread |
280 // causing troubles is a compiler thread. | 275 // causing troubles is a compiler thread. |
282 // Do not grab any lock, do not allocate memory. | 277 // Do not grab any lock, do not allocate memory. |
283 // | 278 // |
284 // Otherwise it's the same as CompileTask::print_line() | 279 // Otherwise it's the same as CompileTask::print_line() |
285 // | 280 // |
286 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) { | 281 void CompileTask::print_line_on_error(outputStream* st, char* buf, int buflen) { |
287 methodOop method = (methodOop)JNIHandles::resolve(_method); | |
288 // print compiler name | 282 // print compiler name |
289 st->print("%s:", CompileBroker::compiler(comp_level())->name()); | 283 st->print("%s:", CompileBroker::compiler(comp_level())->name()); |
290 char* method_name = NULL; | 284 print_compilation(st); |
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 } | 285 } |
296 | 286 |
297 // ------------------------------------------------------------------ | 287 // ------------------------------------------------------------------ |
298 // CompileTask::print_line | 288 // CompileTask::print_line |
299 void CompileTask::print_line() { | 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 ttyLocker ttyl; // keep the following output all in one block | 290 ttyLocker ttyl; // keep the following output all in one block |
306 | |
307 // print compiler name if requested | 291 // print compiler name if requested |
308 if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name()); | 292 if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler(comp_level())->name()); |
309 print_compilation(tty, method(), NULL); | 293 print_compilation(); |
310 } | 294 } |
311 | 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 } | |
312 | 391 |
313 // ------------------------------------------------------------------ | 392 // ------------------------------------------------------------------ |
314 // CompileTask::log_task | 393 // CompileTask::log_task |
315 void CompileTask::log_task(xmlStream* log) { | 394 void CompileTask::log_task(xmlStream* log) { |
316 Thread* thread = Thread::current(); | 395 Thread* thread = Thread::current(); |
1084 } | 1163 } |
1085 | 1164 |
1086 // do the compilation | 1165 // do the compilation |
1087 if (method->is_native()) { | 1166 if (method->is_native()) { |
1088 if (!PreferInterpreterNativeStubs) { | 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 } else { | 1175 } else { |
1091 return NULL; | 1176 return NULL; |
1092 } | 1177 } |
1093 } else { | 1178 } else { |
1094 compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, CHECK_0); | 1179 compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, CHECK_0); |
1192 // if certain debugging flags are used. | 1277 // if certain debugging flags are used. |
1193 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { | 1278 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { |
1194 assert(MethodCompileQueue_lock->owner() == Thread::current(), | 1279 assert(MethodCompileQueue_lock->owner() == Thread::current(), |
1195 "must hold the compilation queue lock"); | 1280 "must hold the compilation queue lock"); |
1196 bool is_osr = (osr_bci != standard_entry_bci); | 1281 bool is_osr = (osr_bci != standard_entry_bci); |
1197 assert(!method->is_native(), "no longer compile natives"); | |
1198 uint id; | 1282 uint id; |
1199 if (CICountOSR && is_osr) { | 1283 if (CICountOSR && is_osr) { |
1200 id = ++_osr_compilation_id; | 1284 id = ++_osr_compilation_id; |
1201 if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { | 1285 if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { |
1202 return id; | 1286 return id; |