Mercurial > hg > truffle
comparison src/share/vm/compiler/compileBroker.cpp @ 3650:0e8a2a629afb
Pass-by compilation broker.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Nov 2011 21:27:28 +0100 |
parents | 9c2c0a182f13 |
children | a31028282e3e |
comparison
equal
deleted
inserted
replaced
3649:5a8c44b5fb80 | 3650:0e8a2a629afb |
---|---|
589 // max is the last element | 589 // max is the last element |
590 assert(task == _last, "Sanity"); | 590 assert(task == _last, "Sanity"); |
591 _last = task->prev(); | 591 _last = task->prev(); |
592 } | 592 } |
593 | 593 |
594 // (tw) Immediately set compiling flag. | |
595 JavaThread::current()->as_CompilerThread()->set_compiling(true); | |
596 --_size; | 594 --_size; |
597 } | 595 } |
598 | 596 |
599 // ------------------------------------------------------------------ | 597 // ------------------------------------------------------------------ |
600 // CompileQueue::print | 598 // CompileQueue::print |
654 if (HAS_PENDING_EXCEPTION) { | 652 if (HAS_PENDING_EXCEPTION) { |
655 CLEAR_PENDING_EXCEPTION; | 653 CLEAR_PENDING_EXCEPTION; |
656 fatal("error inserting method into compile queue"); | 654 fatal("error inserting method into compile queue"); |
657 } | 655 } |
658 } | 656 } |
659 | |
660 // Bootstrap the graal compiler. Compiles all methods until compile queue is empty and no compilation is active. | |
661 void CompileBroker::bootstrap_graal() { | |
662 HandleMark hm; | |
663 Thread* THREAD = Thread::current(); | |
664 tty->print_cr("Bootstrapping graal...."); | |
665 | |
666 GraalCompiler* compiler = GraalCompiler::instance(); | |
667 assert(compiler != NULL, "just checking"); | |
668 | |
669 jlong start = os::javaTimeMillis(); | |
670 add_method_to_queue(SystemDictionary::Object_klass(), vmSymbols::object_initializer_name(), vmSymbols::void_method_signature()); | |
671 add_method_to_queue(SystemDictionary::Object_klass(), vmSymbols::equals_name(), vmSymbols::object_boolean_signature()); | |
672 add_method_to_queue(SystemDictionary::String_klass(), vmSymbols::length_name(), vmSymbols::void_int_signature()); | |
673 add_method_to_queue(SystemDictionary::String_klass(), vmSymbols::object_initializer_name(), vmSymbols::void_method_signature()); | |
674 | |
675 int z = 0; | |
676 while (true) { | |
677 { | |
678 HandleMark hm; | |
679 ResourceMark rm; | |
680 MutexLocker locker(_c1_method_queue->lock(), Thread::current()); | |
681 if (_c1_method_queue->is_empty()) { | |
682 MutexLocker mu(Threads_lock); // grab Threads_lock | |
683 JavaThread* current = Threads::first(); | |
684 bool compiling = false; | |
685 while (current != NULL) { | |
686 if (current->is_Compiler_thread()) { | |
687 CompilerThread* comp_thread = current->as_CompilerThread(); | |
688 if (comp_thread->is_compiling()) { | |
689 if (TraceGraal >= 4) { | |
690 tty->print_cr("Compile queue empty, but following thread is still compiling:"); | |
691 comp_thread->print(); | |
692 } | |
693 compiling = true; | |
694 } | |
695 } | |
696 current = current->next(); | |
697 } | |
698 if (!compiling) { | |
699 break; | |
700 } | |
701 } | |
702 if (TraceGraal >= 5) { | |
703 _c1_method_queue->print(); | |
704 } | |
705 } | |
706 | |
707 { | |
708 //ThreadToNativeFromVM trans(JavaThread::current()); | |
709 os::sleep(THREAD, 10, true); | |
710 } | |
711 ++z; | |
712 } | |
713 | |
714 // Do a full garbage collection. | |
715 Universe::heap()->collect(GCCause::_java_lang_system_gc); | |
716 | |
717 jlong diff = os::javaTimeMillis() - start; | |
718 tty->print_cr("Finished bootstrap in %d ms", diff); | |
719 if (CITime) CompileBroker::print_times(); | |
720 tty->print_cr("==========================================================================="); | |
721 } | |
722 | |
723 | 657 |
724 void CompileBroker::notify_java_queue() { | 658 void CompileBroker::notify_java_queue() { |
725 HandleMark hm; | 659 HandleMark hm; |
726 ResourceMark rm; | 660 ResourceMark rm; |
727 | 661 |
1109 | 1043 |
1110 // Acquire our lock. | 1044 // Acquire our lock. |
1111 { | 1045 { |
1112 MutexLocker locker(queue->lock(), THREAD); | 1046 MutexLocker locker(queue->lock(), THREAD); |
1113 | 1047 |
1114 if (Thread::current()->is_Compiler_thread() && CompilerThread::current()->is_compiling() && !BackgroundCompilation) { | 1048 if (JavaThread::current()->is_compiling() && !BackgroundCompilation) { |
1115 | 1049 |
1116 TRACE_graal_1("Recursive compile %s!", method->name_and_sig_as_C_string()); | 1050 TRACE_graal_1("Recursive compile %s!", method->name_and_sig_as_C_string()); |
1117 method->set_not_compilable(); | 1051 method->set_not_compilable(); |
1118 return; | 1052 return; |
1119 } | 1053 } |
1180 // NOTE: in the event that there are multiple compiler threads and | 1114 // NOTE: in the event that there are multiple compiler threads and |
1181 // there is de-optimization/recompilation, things will get hairy, | 1115 // there is de-optimization/recompilation, things will get hairy, |
1182 // and in that case it's best to protect both the testing (here) of | 1116 // and in that case it's best to protect both the testing (here) of |
1183 // these bits, and their updating (here and elsewhere) under a | 1117 // these bits, and their updating (here and elsewhere) under a |
1184 // common lock. | 1118 // common lock. |
1185 task = create_compile_task(queue, | 1119 /*task = create_compile_task(queue, |
1186 compile_id, method, | 1120 compile_id, method, |
1187 osr_bci, comp_level, | 1121 osr_bci, comp_level, |
1188 hot_method, hot_count, comment, | 1122 hot_method, hot_count, comment, |
1189 blocking); | 1123 blocking);*/ |
1190 } | 1124 } |
1191 | 1125 |
1192 if (blocking) { | 1126 if (!JavaThread::current()->is_compiling()) { |
1127 method->set_queued_for_compilation(); | |
1128 GraalCompiler::instance()->compile_method(method, osr_bci); | |
1129 } | |
1130 /*if (blocking) { | |
1193 wait_for_completion(task); | 1131 wait_for_completion(task); |
1194 } | 1132 }*/ |
1195 } | 1133 } |
1196 | 1134 |
1197 | 1135 |
1198 nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, | 1136 nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, |
1199 int comp_level, | 1137 int comp_level, |
1572 os::current_thread_id(), | 1510 os::current_thread_id(), |
1573 os::current_process_id()); | 1511 os::current_process_id()); |
1574 log->stamp(); | 1512 log->stamp(); |
1575 log->end_elem(); | 1513 log->end_elem(); |
1576 } | 1514 } |
1577 | |
1578 if (UseGraal) { | |
1579 thread->set_compiling(true); // Prevent recursive compilations while the compiler is initializing. | |
1580 ThreadToNativeFromVM trans(JavaThread::current()); | |
1581 GraalCompiler::instance()->initialize(); | |
1582 } | |
1583 | 1515 |
1584 while (true) { | 1516 while (true) { |
1585 { | 1517 { |
1586 // Unset compiling flag. | |
1587 thread->set_compiling(false); | |
1588 | 1518 |
1589 // We need this HandleMark to avoid leaking VM handles. | 1519 // We need this HandleMark to avoid leaking VM handles. |
1590 HandleMark hm(thread); | 1520 HandleMark hm(thread); |
1591 | 1521 |
1592 if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) { | 1522 if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) { |