27 #include "memory/resourceArea.hpp" |
27 #include "memory/resourceArea.hpp" |
28 #include "runtime/arguments.hpp" |
28 #include "runtime/arguments.hpp" |
29 #include "runtime/simpleThresholdPolicy.hpp" |
29 #include "runtime/simpleThresholdPolicy.hpp" |
30 #include "runtime/simpleThresholdPolicy.inline.hpp" |
30 #include "runtime/simpleThresholdPolicy.inline.hpp" |
31 #include "code/scopeDesc.hpp" |
31 #include "code/scopeDesc.hpp" |
|
32 #if INCLUDE_JVMCI |
|
33 #include "jvmci/jvmciRuntime.hpp" |
|
34 #endif |
32 |
35 |
33 |
36 |
34 void SimpleThresholdPolicy::print_counters(const char* prefix, methodHandle mh) { |
37 void SimpleThresholdPolicy::print_counters(const char* prefix, methodHandle mh) { |
35 int invocation_count = mh->invocation_count(); |
38 int invocation_count = mh->invocation_count(); |
36 int backedge_count = mh->backedge_count(); |
39 int backedge_count = mh->backedge_count(); |
352 } |
355 } |
353 return MIN2(next_level, (CompLevel)TieredStopAtLevel); |
356 return MIN2(next_level, (CompLevel)TieredStopAtLevel); |
354 } |
357 } |
355 |
358 |
356 // Determine if a method should be compiled with a normal entry point at a different level. |
359 // Determine if a method should be compiled with a normal entry point at a different level. |
357 CompLevel SimpleThresholdPolicy::call_event(Method* method, CompLevel cur_level) { |
360 CompLevel SimpleThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread* thread) { |
358 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
361 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
359 common(&SimpleThresholdPolicy::loop_predicate, method, cur_level)); |
362 common(&SimpleThresholdPolicy::loop_predicate, method, cur_level)); |
360 CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level); |
363 CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level); |
361 |
364 |
362 // If OSR method level is greater than the regular method level, the levels should be |
365 // If OSR method level is greater than the regular method level, the levels should be |
369 next_level = CompLevel_full_optimization; |
372 next_level = CompLevel_full_optimization; |
370 } |
373 } |
371 } else { |
374 } else { |
372 next_level = MAX2(osr_level, next_level); |
375 next_level = MAX2(osr_level, next_level); |
373 } |
376 } |
374 |
377 #if INCLUDE_JVMCI |
|
378 if (UseJVMCICompiler) { |
|
379 next_level = JVMCIRuntime::adjust_comp_level(method, false, next_level, thread); |
|
380 } |
|
381 #endif |
375 return next_level; |
382 return next_level; |
376 } |
383 } |
377 |
384 |
378 // Determine if we should do an OSR compilation of a given method. |
385 // Determine if we should do an OSR compilation of a given method. |
379 CompLevel SimpleThresholdPolicy::loop_event(Method* method, CompLevel cur_level) { |
386 CompLevel SimpleThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) { |
380 CompLevel next_level = common(&SimpleThresholdPolicy::loop_predicate, method, cur_level); |
387 CompLevel next_level = common(&SimpleThresholdPolicy::loop_predicate, method, cur_level); |
381 if (cur_level == CompLevel_none) { |
388 if (cur_level == CompLevel_none) { |
382 // If there is a live OSR method that means that we deopted to the interpreter |
389 // If there is a live OSR method that means that we deopted to the interpreter |
383 // for the transition. |
390 // for the transition. |
384 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
391 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
385 if (osr_level > CompLevel_none) { |
392 if (osr_level > CompLevel_none) { |
386 return osr_level; |
393 return osr_level; |
387 } |
394 } |
388 } |
395 } |
|
396 #if INCLUDE_JVMCI |
|
397 if (UseJVMCICompiler) { |
|
398 next_level = JVMCIRuntime::adjust_comp_level(method, true, next_level, thread); |
|
399 } |
|
400 #endif |
389 return next_level; |
401 return next_level; |
390 } |
402 } |
391 |
403 |
392 |
404 |
393 // Handle the invocation event. |
405 // Handle the invocation event. |
394 void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, |
406 void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, |
395 CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
407 CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
396 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
408 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
397 CompLevel next_level = call_event(mh(), level); |
409 CompLevel next_level = call_event(mh(), level, thread); |
398 if (next_level != level) { |
410 if (next_level != level) { |
399 compile(mh, InvocationEntryBci, next_level, thread); |
411 compile(mh, InvocationEntryBci, next_level, thread); |
400 } |
412 } |
401 } |
413 } |
402 } |
414 } |
408 // If the method is already compiling, quickly bail out. |
420 // If the method is already compiling, quickly bail out. |
409 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
421 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
410 // Use loop event as an opportunity to also check there's been |
422 // Use loop event as an opportunity to also check there's been |
411 // enough calls. |
423 // enough calls. |
412 CompLevel cur_level = comp_level(mh()); |
424 CompLevel cur_level = comp_level(mh()); |
413 CompLevel next_level = call_event(mh(), cur_level); |
425 CompLevel next_level = call_event(mh(), cur_level, thread); |
414 CompLevel next_osr_level = loop_event(mh(), level); |
426 CompLevel next_osr_level = loop_event(mh(), level, thread); |
415 |
427 |
416 next_level = MAX2(next_level, |
428 next_level = MAX2(next_level, |
417 next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level); |
429 next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level); |
418 bool is_compiling = false; |
430 bool is_compiling = false; |
419 if (next_level != cur_level) { |
431 if (next_level != cur_level) { |