comparison src/share/vm/compiler/compileBroker.cpp @ 23303:633cf7bea01d

thread waiting for blocking JVMCI compilation should not wait on compiler queue forever (JDK-8148507) [part 2]
author Doug Simon <doug.simon@oracle.com>
date Thu, 04 Feb 2016 19:18:52 +0100
parents 90f7b4c21cfb
children 3ef45d0a6d77
comparison
equal deleted inserted replaced
23302:90f7b4c21cfb 23303:633cf7bea01d
48 #include "utilities/events.hpp" 48 #include "utilities/events.hpp"
49 #ifdef COMPILER1 49 #ifdef COMPILER1
50 #include "c1/c1_Compiler.hpp" 50 #include "c1/c1_Compiler.hpp"
51 #endif 51 #endif
52 #if INCLUDE_JVMCI 52 #if INCLUDE_JVMCI
53 #include "jvmci/jvmciCompiler.hpp"
54 #include "jvmci/jvmciJavaClasses.hpp" 53 #include "jvmci/jvmciJavaClasses.hpp"
55 #ifdef COMPILERJVMCI 54 #ifdef COMPILERJVMCI
56 #include "jvmci/jvmciRuntime.hpp" 55 #include "jvmci/jvmciRuntime.hpp"
57 #include "runtime/vframe.hpp" 56 #include "runtime/vframe.hpp"
58 #endif 57 #endif
1739 * JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE * 1738 * JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE *
1740 * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS. 1739 * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS.
1741 * 1740 *
1742 * @return true if this thread needs to free/recycle the task 1741 * @return true if this thread needs to free/recycle the task
1743 */ 1742 */
1744 bool CompileBroker::wait_for_jvmci_completion(AbstractCompiler* comp, CompileTask* task, JavaThread* thread) { 1743 bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) {
1745 MutexLocker waiter(task->lock(), thread); 1744 MutexLocker waiter(task->lock(), thread);
1746 assert(comp->is_jvmci(), "must be");
1747 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
1748 int progress_wait_attempts = 0; 1745 int progress_wait_attempts = 0;
1749 int methods_compiled = jvmci->approx_num_methods_compiled(); 1746 int methods_compiled = jvmci->methods_compiled();
1750 while (!task->is_complete() && !is_compilation_disabled_forever() && 1747 while (!task->is_complete() && !is_compilation_disabled_forever() &&
1751 task->lock()->wait(!Mutex::_no_safepoint_check_flag, JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) { 1748 task->lock()->wait(!Mutex::_no_safepoint_check_flag, JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) {
1752 CompilerThread* jvmci_compiler_thread = task->jvmci_compiler_thread(); 1749 CompilerThread* jvmci_compiler_thread = task->jvmci_compiler_thread();
1753 1750
1754 bool progress; 1751 bool progress;
1758 } else { 1755 } else {
1759 // Still waiting on JVMCI compiler queue. This thread may be holding a lock 1756 // Still waiting on JVMCI compiler queue. This thread may be holding a lock
1760 // that all JVMCI compiler threads are blocked on. We use the counter for 1757 // that all JVMCI compiler threads are blocked on. We use the counter for
1761 // successful JVMCI compilations to determine whether JVMCI compilation 1758 // successful JVMCI compilations to determine whether JVMCI compilation
1762 // is still making progress through the JVMCI compiler queue. 1759 // is still making progress through the JVMCI compiler queue.
1763 progress = jvmci->approx_num_methods_compiled() != methods_compiled; 1760 progress = jvmci->methods_compiled() != methods_compiled;
1764 } 1761 }
1765 1762
1766 if (!progress) { 1763 if (!progress) {
1767 if (++progress_wait_attempts == JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS) { 1764 if (++progress_wait_attempts == JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS) {
1768 if (PrintCompilation) { 1765 if (PrintCompilation) {
1771 break; 1768 break;
1772 } 1769 }
1773 } else { 1770 } else {
1774 progress_wait_attempts = 0; 1771 progress_wait_attempts = 0;
1775 if (jvmci_compiler_thread == NULL) { 1772 if (jvmci_compiler_thread == NULL) {
1776 methods_compiled = jvmci->approx_num_methods_compiled(); 1773 methods_compiled = jvmci->methods_compiled();
1777 } 1774 }
1778 } 1775 }
1779 } 1776 }
1780 task->clear_waiter(); 1777 task->clear_waiter();
1781 return task->is_complete(); 1778 return task->is_complete();
1799 methodHandle method(thread, task->method()); 1796 methodHandle method(thread, task->method());
1800 bool free_task = true; 1797 bool free_task = true;
1801 #ifdef COMPILERJVMCI 1798 #ifdef COMPILERJVMCI
1802 AbstractCompiler* comp = compiler(task->comp_level()); 1799 AbstractCompiler* comp = compiler(task->comp_level());
1803 if (comp->is_jvmci()) { 1800 if (comp->is_jvmci()) {
1804 free_task = wait_for_jvmci_completion(comp, task, thread); 1801 free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread);
1805 } else 1802 } else
1806 #endif 1803 #endif
1807 { 1804 {
1808 MutexLocker waiter(task->lock(), thread); 1805 MutexLocker waiter(task->lock(), thread);
1809 while (!task->is_complete() && !is_compilation_disabled_forever()) { 1806 while (!task->is_complete() && !is_compilation_disabled_forever()) {