< prev index next >

src/hotspot/share/compiler/compileBroker.cpp

Print this page




1764     HandleMark hm(thread);
1765 
1766     CompileTask* task = queue->get();
1767     if (task == NULL) {
1768       if (UseDynamicNumberOfCompilerThreads) {
1769         // Access compiler_count under lock to enforce consistency.
1770         MutexLocker only_one(CompileThread_lock);
1771         if (can_remove(thread, true)) {
1772           if (TraceCompilerThreads) {
1773             tty->print_cr("Removing compiler thread %s after " JLONG_FORMAT " ms idle time",
1774                           thread->name(), thread->idle_time_millis());
1775           }
1776           // Free buffer blob, if allocated
1777           if (thread->get_buffer_blob() != NULL) {
1778             MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1779             CodeCache::free(thread->get_buffer_blob());
1780           }
1781           return; // Stop this thread.
1782         }
1783       }
1784       continue;
1785     }
1786 
1787     if (UseDynamicNumberOfCompilerThreads) {
1788       possibly_add_compiler_threads();
1789     }
1790 
1791     // Give compiler threads an extra quanta.  They tend to be bursty and
1792     // this helps the compiler to finish up the job.
1793     if (CompilerThreadHintNoPreempt) {
1794       os::hint_no_preempt();
1795     }
1796 
1797     // Assign the task to the current thread.  Mark this compilation
1798     // thread as active for the profiler.


1799     CompileTaskWrapper ctw(task);
1800     nmethodLocker result_handle;  // (handle for the nmethod produced by this task)
1801     task->set_code_handle(&result_handle);
1802     methodHandle method(thread, task->method());
1803 
1804     // Never compile a method if breakpoints are present in it
1805     if (method()->number_of_breakpoints() == 0) {
1806       // Compile the method.
1807       if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
1808         invoke_compiler_on_method(task);
1809         thread->start_idle_timer();
1810       } else {
1811         // After compilation is disabled, remove remaining methods from queue
1812         method->clear_queued_for_compilation();
1813         task->set_failure_reason("compilation is disabled");





1814       }
1815     }
1816   }
1817 
1818   // Shut down compiler runtime
1819   shutdown_compiler_runtime(thread->compiler(), thread);
1820 }
1821 
1822 // ------------------------------------------------------------------
1823 // CompileBroker::init_compiler_thread_log
1824 //
1825 // Set up state required by +LogCompilation.
1826 void CompileBroker::init_compiler_thread_log() {
1827     CompilerThread* thread = CompilerThread::current();
1828     char  file_name[4*K];
1829     FILE* fp = NULL;
1830     intx thread_id = os::current_thread_id();
1831     for (int try_temp_dir = 1; try_temp_dir >= 0; try_temp_dir--) {
1832       const char* dir = (try_temp_dir ? os::get_temp_directory() : NULL);
1833       if (dir == NULL) {




1764     HandleMark hm(thread);
1765 
1766     CompileTask* task = queue->get();
1767     if (task == NULL) {
1768       if (UseDynamicNumberOfCompilerThreads) {
1769         // Access compiler_count under lock to enforce consistency.
1770         MutexLocker only_one(CompileThread_lock);
1771         if (can_remove(thread, true)) {
1772           if (TraceCompilerThreads) {
1773             tty->print_cr("Removing compiler thread %s after " JLONG_FORMAT " ms idle time",
1774                           thread->name(), thread->idle_time_millis());
1775           }
1776           // Free buffer blob, if allocated
1777           if (thread->get_buffer_blob() != NULL) {
1778             MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1779             CodeCache::free(thread->get_buffer_blob());
1780           }
1781           return; // Stop this thread.
1782         }
1783       }
1784     } else {





1785 
1786       // Give compiler threads an extra quanta.  They tend to be bursty and
1787       // this helps the compiler to finish up the job.
1788       if (CompilerThreadHintNoPreempt) {
1789         os::hint_no_preempt();
1790       }
1791 
1792       // Assign the task to the current thread.  Mark this compilation
1793       // thread as active for the profiler.
1794       // CompileTaskWrapper also keeps the Method* from being deallocated if redefinition
1795       // occurs after fetching the compile task off the queue.
1796       CompileTaskWrapper ctw(task);
1797       nmethodLocker result_handle;  // (handle for the nmethod produced by this task)
1798       task->set_code_handle(&result_handle);
1799       methodHandle method(thread, task->method());
1800 
1801       // Never compile a method if breakpoints are present in it
1802       if (method()->number_of_breakpoints() == 0) {
1803         // Compile the method.
1804         if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) {
1805           invoke_compiler_on_method(task);
1806           thread->start_idle_timer();
1807         } else {
1808           // After compilation is disabled, remove remaining methods from queue
1809           method->clear_queued_for_compilation();
1810           task->set_failure_reason("compilation is disabled");
1811         }
1812       }
1813 
1814       if (UseDynamicNumberOfCompilerThreads) {
1815         possibly_add_compiler_threads();
1816       }
1817     }
1818   }
1819 
1820   // Shut down compiler runtime
1821   shutdown_compiler_runtime(thread->compiler(), thread);
1822 }
1823 
1824 // ------------------------------------------------------------------
1825 // CompileBroker::init_compiler_thread_log
1826 //
1827 // Set up state required by +LogCompilation.
1828 void CompileBroker::init_compiler_thread_log() {
1829     CompilerThread* thread = CompilerThread::current();
1830     char  file_name[4*K];
1831     FILE* fp = NULL;
1832     intx thread_id = os::current_thread_id();
1833     for (int try_temp_dir = 1; try_temp_dir >= 0; try_temp_dir--) {
1834       const char* dir = (try_temp_dir ? os::get_temp_directory() : NULL);
1835       if (dir == NULL) {


< prev index next >