comparison src/share/vm/compiler/compileBroker.cpp @ 23404:3ef45d0a6d77

Remove jvmci VM configuration, and backport UseJVMCICompiler flag.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 24 May 2016 13:51:28 +0200
parents 633cf7bea01d
children f84a5ac3be22
comparison
equal deleted inserted replaced
23403:5342deb9bf53 23404:3ef45d0a6d77
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/jvmciJavaClasses.hpp" 53 #include "jvmci/jvmciJavaClasses.hpp"
54 #ifdef COMPILERJVMCI
55 #include "jvmci/jvmciRuntime.hpp" 54 #include "jvmci/jvmciRuntime.hpp"
56 #include "runtime/vframe.hpp" 55 #include "runtime/vframe.hpp"
57 #endif
58 #endif 56 #endif
59 #ifdef COMPILER2 57 #ifdef COMPILER2
60 #include "opto/c2compiler.hpp" 58 #include "opto/c2compiler.hpp"
61 #endif 59 #endif
62 #ifdef SHARK 60 #ifdef SHARK
235 } 233 }
236 234
237 CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) { 235 CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) {
238 CompilerThread* thread = CompilerThread::current(); 236 CompilerThread* thread = CompilerThread::current();
239 thread->set_task(task); 237 thread->set_task(task);
240 #ifdef COMPILERJVMCI 238 #if INCLUDE_JVMCI
241 if (task->is_blocking() && CompileBroker::compiler(task->comp_level())->is_jvmci()) { 239 if (task->is_blocking() && CompileBroker::compiler(task->comp_level())->is_jvmci()) {
242 task->set_jvmci_compiler_thread(thread); 240 task->set_jvmci_compiler_thread(thread);
243 } 241 }
244 #endif 242 #endif
245 CompileLog* log = thread->log(); 243 CompileLog* log = thread->log();
257 if (task->is_blocking()) { 255 if (task->is_blocking()) {
258 bool free_task = false; 256 bool free_task = false;
259 { 257 {
260 MutexLocker notifier(task->lock(), thread); 258 MutexLocker notifier(task->lock(), thread);
261 task->mark_complete(); 259 task->mark_complete();
262 #ifdef COMPILERJVMCI 260 #if INCLUDE_JVMCI
263 if (CompileBroker::compiler(task->comp_level())->is_jvmci()) { 261 if (CompileBroker::compiler(task->comp_level())->is_jvmci()) {
264 if (!task->has_waiter()) { 262 if (!task->has_waiter()) {
265 // The waiting thread timed out and thus did not free the task. 263 // The waiting thread timed out and thus did not free the task.
266 free_task = true; 264 free_task = true;
267 } 265 }
303 _task_free_list = task->next(); 301 _task_free_list = task->next();
304 task->set_next(NULL); 302 task->set_next(NULL);
305 } else { 303 } else {
306 task = new CompileTask(); 304 task = new CompileTask();
307 DEBUG_ONLY(_num_allocated_tasks++;) 305 DEBUG_ONLY(_num_allocated_tasks++;)
308 NOT_COMPILERJVMCI(assert (_num_allocated_tasks < 10000, "Leaking compilation tasks?");) 306 NOT_JVMCI(assert (_num_allocated_tasks < 10000, "Leaking compilation tasks?");)
309 task->set_next(NULL); 307 task->set_next(NULL);
310 task->set_is_free(true); 308 task->set_is_free(true);
311 } 309 }
312 assert(task->is_free(), "Task must be free."); 310 assert(task->is_free(), "Task must be free.");
313 task->set_is_free(false); 311 task->set_is_free(false);
345 _compile_id = compile_id; 343 _compile_id = compile_id;
346 _method = method(); 344 _method = method();
347 _method_holder = JNIHandles::make_global(method->method_holder()->klass_holder()); 345 _method_holder = JNIHandles::make_global(method->method_holder()->klass_holder());
348 _osr_bci = osr_bci; 346 _osr_bci = osr_bci;
349 _is_blocking = is_blocking; 347 _is_blocking = is_blocking;
350 COMPILERJVMCI_PRESENT(_has_waiter = CompileBroker::compiler(comp_level)->is_jvmci();) 348 #if INCLUDE_JVMCI
351 COMPILERJVMCI_PRESENT(_jvmci_compiler_thread = NULL;) 349 _has_waiter = CompileBroker::compiler(comp_level)->is_jvmci();
350 _jvmci_compiler_thread = NULL;
351 #endif
352 _comp_level = comp_level; 352 _comp_level = comp_level;
353 _num_inlined_bytecodes = 0; 353 _num_inlined_bytecodes = 0;
354 354
355 _is_complete = false; 355 _is_complete = false;
356 _is_success = false; 356 _is_success = false;
941 // Set the interface to the current compiler(s). 941 // Set the interface to the current compiler(s).
942 int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); 942 int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple);
943 int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); 943 int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);
944 #if INCLUDE_JVMCI 944 #if INCLUDE_JVMCI
945 JVMCICompiler* jvmci = new JVMCICompiler(); 945 JVMCICompiler* jvmci = new JVMCICompiler();
946 if (UseJVMCICompiler) {
947 _compilers[1] = jvmci;
948 if (FLAG_IS_DEFAULT(JVMCIThreads)) {
949 if (BootstrapJVMCI) {
950 // JVMCI will bootstrap so give it more threads
951 c2_count = MIN2(32, os::active_processor_count());
952 }
953 } else {
954 c2_count = JVMCIThreads;
955 }
956 if (FLAG_IS_DEFAULT(JVMCIHostThreads)) {
957 } else {
958 c1_count = JVMCIHostThreads;
959 }
960 if (!UseInterpreter || !BackgroundCompilation) {
961 // Force initialization of JVMCI compiler otherwise JVMCI
962 // compilations will not block until JVMCI is initialized
963 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
964 ResourceMark rm;
965 TempNewSymbol getCompiler = SymbolTable::new_symbol("getCompiler", CHECK);
966 TempNewSymbol sig = SymbolTable::new_symbol("()Ljdk/vm/ci/runtime/JVMCICompiler;", CHECK);
967 Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
968 JavaValue result(T_OBJECT);
969 JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK);
970 }
971 }
972 #ifndef COMPILER2
973 else {
974 c2_count = 0;
975 }
946 #endif 976 #endif
947 977 #endif // INCLUDE_JVMCI
948 #if defined(COMPILERJVMCI)
949 _compilers[1] = jvmci;
950 if (FLAG_IS_DEFAULT(JVMCIThreads)) {
951 if (BootstrapJVMCI) {
952 // JVMCI will bootstrap so give it more threads
953 c2_count = MIN2(32, os::active_processor_count());
954 }
955 } else {
956 c2_count = JVMCIThreads;
957 }
958 if (FLAG_IS_DEFAULT(JVMCIHostThreads)) {
959 } else {
960 c1_count = JVMCIHostThreads;
961 }
962 if (!UseInterpreter || !BackgroundCompilation) {
963 // Force initialization of JVMCI compiler otherwise JVMCI
964 // compilations will not block until JVMCI is initialized
965 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
966 ResourceMark rm;
967 TempNewSymbol getCompiler = SymbolTable::new_symbol("getCompiler", CHECK);
968 TempNewSymbol sig = SymbolTable::new_symbol("()Ljdk/vm/ci/runtime/JVMCICompiler;", CHECK);
969 Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
970 JavaValue result(T_OBJECT);
971 JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK);
972 }
973 #endif // COMPILERJVMCI
974 978
975 #ifdef COMPILER1 979 #ifdef COMPILER1
976 if (c1_count > 0) { 980 if (c1_count > 0) {
977 _compilers[0] = new Compiler(); 981 _compilers[0] = new Compiler();
978 } 982 }
979 #endif // COMPILER1 983 #endif // COMPILER1
980 984
981 #ifdef COMPILER2 985 #ifdef COMPILER2
982 if (c2_count > 0) { 986 if (true JVMCI_ONLY( && !UseJVMCICompiler)) {
983 _compilers[1] = new C2Compiler(); 987 if (c2_count > 0) {
988 _compilers[1] = new C2Compiler();
989 }
984 } 990 }
985 #endif // COMPILER2 991 #endif // COMPILER2
986 992
987 #else // SHARK 993 #else // SHARK
988 int c1_count = 0; 994 int c1_count = 0;
1176 } 1182 }
1177 1183
1178 1184
1179 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) { 1185 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) {
1180 EXCEPTION_MARK; 1186 EXCEPTION_MARK;
1181 #if !defined(ZERO) && !defined(SHARK) && !defined(COMPILERJVMCI) 1187 #if !defined(ZERO) && !defined(SHARK)
1182 assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?"); 1188 assert(c2_compiler_count > 0 || c1_compiler_count > 0 JVMCI_ONLY(|| UseJVMCICompiler), "No compilers?");
1183 #endif // !ZERO && !SHARK && !COMPILERJVMCI 1189 #endif // !ZERO && !SHARK
1184 // Initialize the compilation queue 1190 // Initialize the compilation queue
1185 if (c2_compiler_count > 0) { 1191 if (c2_compiler_count > 0) {
1186 _c2_compile_queue = new CompileQueue("C2 CompileQueue", MethodCompileQueue_lock); 1192 _c2_compile_queue = new CompileQueue("C2 CompileQueue", MethodCompileQueue_lock);
1187 _compilers[1]->set_num_compiler_threads(c2_compiler_count); 1193 _compilers[1]->set_num_compiler_threads(c2_compiler_count);
1188 } 1194 }
1356 } 1362 }
1357 1363
1358 // Should this thread wait for completion of the compile? 1364 // Should this thread wait for completion of the compile?
1359 blocking = is_compile_blocking(); 1365 blocking = is_compile_blocking();
1360 1366
1361 #ifdef COMPILERJVMCI 1367 #if INCLUDE_JVMCI
1362 if (blocking) { 1368 if (UseJVMCICompiler && blocking) {
1363 // Don't allow blocking compiles for requests triggered by JVMCI. 1369 // Don't allow blocking compiles for requests triggered by JVMCI.
1364 if (thread->is_Compiler_thread()) { 1370 if (thread->is_Compiler_thread()) {
1365 blocking = false; 1371 blocking = false;
1366 } 1372 }
1367 1373
1720 blocking); 1726 blocking);
1721 queue->add(new_task); 1727 queue->add(new_task);
1722 return new_task; 1728 return new_task;
1723 } 1729 }
1724 1730
1725 #ifdef COMPILERJVMCI 1731 #if INCLUDE_JVMCI
1726 // The number of milliseconds to wait before checking if 1732 // The number of milliseconds to wait before checking if
1727 // JVMCI compilation has made progress. 1733 // JVMCI compilation has made progress.
1728 static const long JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE = 500; 1734 static const long JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE = 500;
1729 1735
1730 // The number of JVMCI compilation progress checks that must fail 1736 // The number of JVMCI compilation progress checks that must fail
1793 JavaThread* thread = JavaThread::current(); 1799 JavaThread* thread = JavaThread::current();
1794 thread->set_blocked_on_compilation(true); 1800 thread->set_blocked_on_compilation(true);
1795 1801
1796 methodHandle method(thread, task->method()); 1802 methodHandle method(thread, task->method());
1797 bool free_task = true; 1803 bool free_task = true;
1798 #ifdef COMPILERJVMCI 1804 #if INCLUDE_JVMCI
1799 AbstractCompiler* comp = compiler(task->comp_level()); 1805 AbstractCompiler* comp = compiler(task->comp_level());
1800 if (comp->is_jvmci()) { 1806 if (comp->is_jvmci()) {
1801 free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread); 1807 free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread);
1802 } else 1808 } else
1803 #endif 1809 #endif
2181 int system_dictionary_modification_counter; 2187 int system_dictionary_modification_counter;
2182 { 2188 {
2183 MutexLocker locker(Compile_lock, thread); 2189 MutexLocker locker(Compile_lock, thread);
2184 system_dictionary_modification_counter = SystemDictionary::number_of_modifications(); 2190 system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
2185 } 2191 }
2186 #ifdef COMPILERJVMCI 2192 #if INCLUDE_JVMCI
2187 if (comp != NULL && comp->is_jvmci()) { 2193 if (comp != NULL && comp->is_jvmci()) {
2188 JVMCICompiler* jvmci = (JVMCICompiler*) comp; 2194 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
2189 2195
2190 TraceTime t1("compilation", &time); 2196 TraceTime t1("compilation", &time);
2191 EventCompilation event; 2197 EventCompilation event;
2201 retry_message = "not retryable"; 2207 retry_message = "not retryable";
2202 compilable = ciEnv::MethodCompilable_not_at_tier; 2208 compilable = ciEnv::MethodCompilable_not_at_tier;
2203 } 2209 }
2204 2210
2205 } else 2211 } else
2206 #endif // COMPILERJVMCI 2212 #endif // INCLUDE_JVMCI
2207 { 2213 {
2208 NoHandleMark nhm; 2214 NoHandleMark nhm;
2209 ThreadToNativeFromVM ttn(thread); 2215 ThreadToNativeFromVM ttn(thread);
2210 2216
2211 ciEnv ci_env(task, system_dictionary_modification_counter); 2217 ciEnv ci_env(task, system_dictionary_modification_counter);
2648 } 2654 }
2649 total_compile_count = osr_compile_count + standard_compile_count; 2655 total_compile_count = osr_compile_count + standard_compile_count;
2650 total_compilation.add(osr_compilation); 2656 total_compilation.add(osr_compilation);
2651 total_compilation.add(standard_compilation); 2657 total_compilation.add(standard_compilation);
2652 2658
2653 #ifndef COMPILERJVMCI 2659 if (!UseJVMCICompiler) {
2654 // In hosted mode, print the JVMCI compiler specific counters manually. 2660 // In hosted mode, print the JVMCI compiler specific counters manually.
2655 JVMCICompiler::print_compilation_timers(); 2661 JVMCICompiler::print_compilation_timers();
2656 #endif 2662 }
2657 #else 2663 #else
2658 elapsedTimer standard_compilation = CompileBroker::_t_standard_compilation; 2664 elapsedTimer standard_compilation = CompileBroker::_t_standard_compilation;
2659 elapsedTimer osr_compilation = CompileBroker::_t_osr_compilation; 2665 elapsedTimer osr_compilation = CompileBroker::_t_osr_compilation;
2660 elapsedTimer total_compilation = CompileBroker::_t_total_compilation; 2666 elapsedTimer total_compilation = CompileBroker::_t_total_compilation;
2661 2667