Mercurial > hg > graal-compiler
comparison src/share/vm/compiler/compileBroker.cpp @ 12355:cefad50507d8
Merge with hs25-b53
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 11 Oct 2013 10:38:03 +0200 |
parents | 836a62f43af9 510fbd28919c |
children | 359f7e70ae7f |
comparison
equal
deleted
inserted
replaced
12058:ccb4f2af2319 | 12355:cefad50507d8 |
---|---|
635 // Get the next CompileTask from a CompileQueue | 635 // Get the next CompileTask from a CompileQueue |
636 CompileTask* CompileQueue::get() { | 636 CompileTask* CompileQueue::get() { |
637 NMethodSweeper::possibly_sweep(); | 637 NMethodSweeper::possibly_sweep(); |
638 | 638 |
639 MutexLocker locker(lock()); | 639 MutexLocker locker(lock()); |
640 // Wait for an available CompileTask. | 640 // If _first is NULL we have no more compile jobs. There are two reasons for |
641 // having no compile jobs: First, we compiled everything we wanted. Second, | |
642 // we ran out of code cache so compilation has been disabled. In the latter | |
643 // case we perform code cache sweeps to free memory such that we can re-enable | |
644 // compilation. | |
641 while (_first == NULL) { | 645 while (_first == NULL) { |
642 // There is no work to be done right now. Wait. | 646 if (UseCodeCacheFlushing && !CompileBroker::should_compile_new_jobs()) { |
643 if (UseCodeCacheFlushing && (!CompileBroker::should_compile_new_jobs() || CodeCache::needs_flushing())) { | 647 // Wait a certain amount of time to possibly do another sweep. |
644 // During the emergency sweeping periods, wake up and sweep occasionally | 648 // We must wait until stack scanning has happened so that we can |
645 bool timedout = lock()->wait(!Mutex::_no_safepoint_check_flag, NmethodSweepCheckInterval*1000); | 649 // transition a method's state from 'not_entrant' to 'zombie'. |
646 if (timedout) { | 650 long wait_time = NmethodSweepCheckInterval * 1000; |
651 if (FLAG_IS_DEFAULT(NmethodSweepCheckInterval)) { | |
652 // Only one thread at a time can do sweeping. Scale the | |
653 // wait time according to the number of compiler threads. | |
654 // As a result, the next sweep is likely to happen every 100ms | |
655 // with an arbitrary number of threads that do sweeping. | |
656 wait_time = 100 * CICompilerCount; | |
657 } | |
658 bool timeout = lock()->wait(!Mutex::_no_safepoint_check_flag, wait_time); | |
659 if (timeout) { | |
647 MutexUnlocker ul(lock()); | 660 MutexUnlocker ul(lock()); |
648 // When otherwise not busy, run nmethod sweeping | |
649 NMethodSweeper::possibly_sweep(); | 661 NMethodSweeper::possibly_sweep(); |
650 } | 662 } |
651 } else { | 663 } else { |
652 // During normal operation no need to wake up on timer | 664 // If there are no compilation tasks and we can compile new jobs |
665 // (i.e., there is enough free space in the code cache) there is | |
666 // no need to invoke the sweeper. As a result, the hotness of methods | |
667 // remains unchanged. This behavior is desired, since we want to keep | |
668 // the stable state, i.e., we do not want to evict methods from the | |
669 // code cache if it is unnecessary. | |
653 lock()->wait(); | 670 lock()->wait(); |
654 } | 671 } |
655 } | 672 } |
656 CompileTask* task = CompilationPolicy::policy()->select_task(this); | 673 CompileTask* task = CompilationPolicy::policy()->select_task(this); |
657 remove(task); | 674 remove(task); |
1244 if (method_code != NULL) { | 1261 if (method_code != NULL) { |
1245 if (compilation_is_complete(method, osr_bci, comp_level)) { | 1262 if (compilation_is_complete(method, osr_bci, comp_level)) { |
1246 return method_code; | 1263 return method_code; |
1247 } | 1264 } |
1248 } | 1265 } |
1249 if (method->is_not_compilable(comp_level)) return NULL; | 1266 if (method->is_not_compilable(comp_level)) { |
1250 | 1267 return NULL; |
1251 if (UseCodeCacheFlushing) { | 1268 } |
1252 nmethod* saved = CodeCache::reanimate_saved_code(method()); | |
1253 if (saved != NULL) { | |
1254 method->set_code(method, saved); | |
1255 return saved; | |
1256 } | |
1257 } | |
1258 | |
1259 } else { | 1269 } else { |
1260 // osr compilation | 1270 // osr compilation |
1261 #ifndef TIERED | 1271 #ifndef TIERED |
1262 // seems like an assert of dubious value | 1272 // seems like an assert of dubious value |
1263 assert(comp_level == CompLevel_highest_tier, | 1273 assert(comp_level == CompLevel_highest_tier, |
1602 HandleMark hm(thread); | 1612 HandleMark hm(thread); |
1603 | 1613 |
1604 if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { | 1614 if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { |
1605 // the code cache is really full | 1615 // the code cache is really full |
1606 handle_full_code_cache(); | 1616 handle_full_code_cache(); |
1607 } else if (UseCodeCacheFlushing && CodeCache::needs_flushing()) { | |
1608 // Attempt to start cleaning the code cache while there is still a little headroom | |
1609 NMethodSweeper::handle_full_code_cache(false); | |
1610 } | 1617 } |
1611 | 1618 |
1612 CompileTask* task = queue->get(); | 1619 CompileTask* task = queue->get(); |
1613 | 1620 |
1614 // Give compiler threads an extra quanta. They tend to be bursty and | 1621 // Give compiler threads an extra quanta. They tend to be bursty and |
1735 { | 1742 { |
1736 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | 1743 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1737 CodeCache::print_summary(&s, detailed); | 1744 CodeCache::print_summary(&s, detailed); |
1738 } | 1745 } |
1739 ttyLocker ttyl; | 1746 ttyLocker ttyl; |
1740 tty->print_cr(s.as_string()); | 1747 tty->print(s.as_string()); |
1741 } | 1748 } |
1742 | 1749 |
1743 // ------------------------------------------------------------------ | 1750 // ------------------------------------------------------------------ |
1744 // CompileBroker::invoke_compiler_on_method | 1751 // CompileBroker::invoke_compiler_on_method |
1745 // | 1752 // |
1960 exit_globals(); // will delete tty | 1967 exit_globals(); // will delete tty |
1961 vm_direct_exit(CompileTheWorld ? 0 : 1); | 1968 vm_direct_exit(CompileTheWorld ? 0 : 1); |
1962 } | 1969 } |
1963 #endif | 1970 #endif |
1964 if (UseCodeCacheFlushing) { | 1971 if (UseCodeCacheFlushing) { |
1965 NMethodSweeper::handle_full_code_cache(true); | 1972 // Since code cache is full, immediately stop new compiles |
1973 if (CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation)) { | |
1974 NMethodSweeper::log_sweep("disable_compiler"); | |
1975 NMethodSweeper::possibly_sweep(); | |
1976 } | |
1966 } else { | 1977 } else { |
1967 UseCompiler = false; | 1978 UseCompiler = false; |
1968 AlwaysCompileLoopMethods = false; | 1979 AlwaysCompileLoopMethods = false; |
1969 } | 1980 } |
1970 } | 1981 } |