Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/compilationPolicy.cpp @ 4825:20334ed5ed3c
7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS
Summary: Make sure that CompilationPolicy::event() doesn't throw exceptions
Reviewed-by: kvn, never
author | iveresov |
---|---|
date | Thu, 26 Jan 2012 12:15:24 -0800 |
parents | 2c359f27615c |
children | 33df1aeaebbf da91efe96a93 |
comparison
equal
deleted
inserted
replaced
4824:5dbed2f542ff | 4825:20334ed5ed3c |
---|---|
304 else | 304 else |
305 target = (uint)( (ProfileMaturityPercentage * CompileThreshold) / 100 ); | 305 target = (uint)( (ProfileMaturityPercentage * CompileThreshold) / 100 ); |
306 return (current >= initial + target); | 306 return (current >= initial + target); |
307 } | 307 } |
308 | 308 |
309 nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) { | 309 nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, int branch_bci, |
310 int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) { | |
310 assert(comp_level == CompLevel_none, "This should be only called from the interpreter"); | 311 assert(comp_level == CompLevel_none, "This should be only called from the interpreter"); |
311 NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci)); | 312 NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci)); |
312 if (JvmtiExport::can_post_interpreter_events()) { | 313 if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) { |
313 assert(THREAD->is_Java_thread(), "Wrong type of thread"); | 314 // If certain JVMTI events (e.g. frame pop event) are requested then the |
314 if (((JavaThread*)THREAD)->is_interp_only_mode()) { | 315 // thread is forced to remain in interpreted code. This is |
315 // If certain JVMTI events (e.g. frame pop event) are requested then the | 316 // implemented partly by a check in the run_compiled_code |
316 // thread is forced to remain in interpreted code. This is | 317 // section of the interpreter whether we should skip running |
317 // implemented partly by a check in the run_compiled_code | 318 // compiled code, and partly by skipping OSR compiles for |
318 // section of the interpreter whether we should skip running | 319 // interpreted-only threads. |
319 // compiled code, and partly by skipping OSR compiles for | 320 if (bci != InvocationEntryBci) { |
320 // interpreted-only threads. | 321 reset_counter_for_back_branch_event(method); |
321 if (bci != InvocationEntryBci) { | 322 return NULL; |
322 reset_counter_for_back_branch_event(method); | |
323 return NULL; | |
324 } | |
325 } | 323 } |
326 } | 324 } |
327 if (bci == InvocationEntryBci) { | 325 if (bci == InvocationEntryBci) { |
328 // when code cache is full, compilation gets switched off, UseCompiler | 326 // when code cache is full, compilation gets switched off, UseCompiler |
329 // is set to false | 327 // is set to false |
330 if (!method->has_compiled_code() && UseCompiler) { | 328 if (!method->has_compiled_code() && UseCompiler) { |
331 method_invocation_event(method, CHECK_NULL); | 329 method_invocation_event(method, thread); |
332 } else { | 330 } else { |
333 // Force counter overflow on method entry, even if no compilation | 331 // Force counter overflow on method entry, even if no compilation |
334 // happened. (The method_invocation_event call does this also.) | 332 // happened. (The method_invocation_event call does this also.) |
335 reset_counter_for_invocation_event(method); | 333 reset_counter_for_invocation_event(method); |
336 } | 334 } |
342 // counter overflow in a loop => try to do on-stack-replacement | 340 // counter overflow in a loop => try to do on-stack-replacement |
343 nmethod* osr_nm = method->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true); | 341 nmethod* osr_nm = method->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true); |
344 NOT_PRODUCT(trace_osr_request(method, osr_nm, bci)); | 342 NOT_PRODUCT(trace_osr_request(method, osr_nm, bci)); |
345 // when code cache is full, we should not compile any more... | 343 // when code cache is full, we should not compile any more... |
346 if (osr_nm == NULL && UseCompiler) { | 344 if (osr_nm == NULL && UseCompiler) { |
347 method_back_branch_event(method, bci, CHECK_NULL); | 345 method_back_branch_event(method, bci, thread); |
348 osr_nm = method->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true); | 346 osr_nm = method->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true); |
349 } | 347 } |
350 if (osr_nm == NULL) { | 348 if (osr_nm == NULL) { |
351 reset_counter_for_back_branch_event(method); | 349 reset_counter_for_back_branch_event(method); |
352 return NULL; | 350 return NULL; |
393 } | 391 } |
394 #endif // !PRODUCT | 392 #endif // !PRODUCT |
395 | 393 |
396 // SimpleCompPolicy - compile current method | 394 // SimpleCompPolicy - compile current method |
397 | 395 |
398 void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) { | 396 void SimpleCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) { |
399 int hot_count = m->invocation_count(); | 397 int hot_count = m->invocation_count(); |
400 reset_counter_for_invocation_event(m); | 398 reset_counter_for_invocation_event(m); |
401 const char* comment = "count"; | 399 const char* comment = "count"; |
402 | 400 |
403 if (is_compilation_enabled() && can_be_compiled(m)) { | 401 if (is_compilation_enabled() && can_be_compiled(m)) { |
404 nmethod* nm = m->code(); | 402 nmethod* nm = m->code(); |
405 if (nm == NULL ) { | 403 if (nm == NULL ) { |
406 const char* comment = "count"; | 404 const char* comment = "count"; |
407 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, | 405 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, |
408 m, hot_count, comment, CHECK); | 406 m, hot_count, comment, thread); |
409 } | 407 } |
410 } | 408 } |
411 } | 409 } |
412 | 410 |
413 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) { | 411 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
414 int hot_count = m->backedge_count(); | 412 int hot_count = m->backedge_count(); |
415 const char* comment = "backedge_count"; | 413 const char* comment = "backedge_count"; |
416 | 414 |
417 if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) { | 415 if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) { |
418 CompileBroker::compile_method(m, bci, CompLevel_highest_tier, | 416 CompileBroker::compile_method(m, bci, CompLevel_highest_tier, |
419 m, hot_count, comment, CHECK); | 417 m, hot_count, comment, thread); |
420 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) | 418 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) |
421 } | 419 } |
422 } | 420 } |
423 // StackWalkCompPolicy - walk up stack to find a suitable method to compile | 421 // StackWalkCompPolicy - walk up stack to find a suitable method to compile |
424 | 422 |
425 #ifdef COMPILER2 | 423 #ifdef COMPILER2 |
426 const char* StackWalkCompPolicy::_msg = NULL; | 424 const char* StackWalkCompPolicy::_msg = NULL; |
427 | 425 |
428 | 426 |
429 // Consider m for compilation | 427 // Consider m for compilation |
430 void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) { | 428 void StackWalkCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) { |
431 int hot_count = m->invocation_count(); | 429 int hot_count = m->invocation_count(); |
432 reset_counter_for_invocation_event(m); | 430 reset_counter_for_invocation_event(m); |
433 const char* comment = "count"; | 431 const char* comment = "count"; |
434 | 432 |
435 if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) { | 433 if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) { |
436 ResourceMark rm(THREAD); | 434 ResourceMark rm(thread); |
437 JavaThread *thread = (JavaThread*)THREAD; | |
438 frame fr = thread->last_frame(); | 435 frame fr = thread->last_frame(); |
439 assert(fr.is_interpreted_frame(), "must be interpreted"); | 436 assert(fr.is_interpreted_frame(), "must be interpreted"); |
440 assert(fr.interpreter_frame_method() == m(), "bad method"); | 437 assert(fr.interpreter_frame_method() == m(), "bad method"); |
441 | 438 |
442 if (TraceCompilationPolicy) { | 439 if (TraceCompilationPolicy) { |
459 RFrame* top = findTopInlinableFrame(stack); | 456 RFrame* top = findTopInlinableFrame(stack); |
460 if (TimeCompilationPolicy) accumulated_time()->stop(); | 457 if (TimeCompilationPolicy) accumulated_time()->stop(); |
461 assert(top != NULL, "findTopInlinableFrame returned null"); | 458 assert(top != NULL, "findTopInlinableFrame returned null"); |
462 if (TraceCompilationPolicy) top->print(); | 459 if (TraceCompilationPolicy) top->print(); |
463 CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier, | 460 CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier, |
464 m, hot_count, comment, CHECK); | 461 m, hot_count, comment, thread); |
465 } | 462 } |
466 } | 463 } |
467 } | 464 } |
468 | 465 |
469 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) { | 466 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
470 int hot_count = m->backedge_count(); | 467 int hot_count = m->backedge_count(); |
471 const char* comment = "backedge_count"; | 468 const char* comment = "backedge_count"; |
472 | 469 |
473 if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) { | 470 if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) { |
474 CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, CHECK); | 471 CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, thread); |
475 | 472 |
476 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) | 473 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) |
477 } | 474 } |
478 } | 475 } |
479 | 476 |