comparison src/share/vm/compiler/compileBroker.cpp @ 21559:be896a1983c0

recast all Graal native code as JVMCI code (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 May 2015 15:36:48 +0200
parents 07b088d61d5d
children c28cb37b2e1d
comparison
equal deleted inserted replaced
21558:d563baeca9df 21559:be896a1983c0
47 #include "utilities/dtrace.hpp" 47 #include "utilities/dtrace.hpp"
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 #ifdef GRAAL 52 #ifdef JVMCI
53 #include "graal/graalCompiler.hpp" 53 #include "jvmci/jvmciCompiler.hpp"
54 #ifdef COMPILERGRAAL 54 #ifdef COMPILERJVMCI
55 #include "graal/graalRuntime.hpp" 55 #include "jvmci/jvmciRuntime.hpp"
56 #include "runtime/vframe.hpp" 56 #include "runtime/vframe.hpp"
57 #endif 57 #endif
58 #endif 58 #endif
59 #ifdef COMPILER2 59 #ifdef COMPILER2
60 #include "opto/c2compiler.hpp" 60 #include "opto/c2compiler.hpp"
914 } 914 }
915 #ifndef SHARK 915 #ifndef SHARK
916 // Set the interface to the current compiler(s). 916 // Set the interface to the current compiler(s).
917 int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); 917 int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple);
918 int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); 918 int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization);
919 #ifdef GRAAL 919 #ifdef JVMCI
920 GraalCompiler* graal = new GraalCompiler(); 920 JVMCICompiler* jvmci = new JVMCICompiler();
921 #endif 921 #endif
922 922
923 #if defined(COMPILERGRAAL) 923 #if defined(COMPILERJVMCI)
924 _compilers[1] = graal; 924 _compilers[1] = jvmci;
925 if (FLAG_IS_DEFAULT(GraalThreads)) { 925 if (FLAG_IS_DEFAULT(JVMCIThreads)) {
926 if (!TieredCompilation && FLAG_IS_DEFAULT(BootstrapGraal) || BootstrapGraal) { 926 if (!TieredCompilation && FLAG_IS_DEFAULT(BootstrapJVMCI) || BootstrapJVMCI) {
927 // Graal will bootstrap so give it more threads 927 // JVMCI will bootstrap so give it more threads
928 c2_count = MIN2(32, os::active_processor_count()); 928 c2_count = MIN2(32, os::active_processor_count());
929 } 929 }
930 } else { 930 } else {
931 c2_count = GraalThreads; 931 c2_count = JVMCIThreads;
932 } 932 }
933 if (FLAG_IS_DEFAULT(GraalHostThreads)) { 933 if (FLAG_IS_DEFAULT(JVMCIHostThreads)) {
934 } else { 934 } else {
935 c1_count = GraalHostThreads; 935 c1_count = JVMCIHostThreads;
936 } 936 }
937 #endif // COMPILERGRAAL 937 #endif // COMPILERJVMCI
938 938
939 #ifdef COMPILER1 939 #ifdef COMPILER1
940 if (c1_count > 0) { 940 if (c1_count > 0) {
941 _compilers[0] = new Compiler(); 941 _compilers[0] = new Compiler();
942 } 942 }
1140 } 1140 }
1141 1141
1142 1142
1143 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) { 1143 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) {
1144 EXCEPTION_MARK; 1144 EXCEPTION_MARK;
1145 #if !defined(ZERO) && !defined(SHARK) && !defined(COMPILERGRAAL) 1145 #if !defined(ZERO) && !defined(SHARK) && !defined(COMPILERJVMCI)
1146 assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?"); 1146 assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
1147 #endif // !ZERO && !SHARK && !COMPILERGRAAL 1147 #endif // !ZERO && !SHARK && !COMPILERJVMCI
1148 // Initialize the compilation queue 1148 // Initialize the compilation queue
1149 if (c2_compiler_count > 0) { 1149 if (c2_compiler_count > 0) {
1150 _c2_compile_queue = new CompileQueue("C2 CompileQueue", MethodCompileQueue_lock); 1150 _c2_compile_queue = new CompileQueue("C2 CompileQueue", MethodCompileQueue_lock);
1151 _compilers[1]->set_num_compiler_threads(c2_compiler_count); 1151 _compilers[1]->set_num_compiler_threads(c2_compiler_count);
1152 } 1152 }
1320 } 1320 }
1321 1321
1322 // Should this thread wait for completion of the compile? 1322 // Should this thread wait for completion of the compile?
1323 blocking = is_compile_blocking(); 1323 blocking = is_compile_blocking();
1324 1324
1325 #ifdef COMPILERGRAAL 1325 #ifdef COMPILERJVMCI
1326 if (blocking) { 1326 if (blocking) {
1327 // Don't allow blocking compiles for requests triggered by Graal. 1327 // Don't allow blocking compiles for requests triggered by JVMCI.
1328 if (thread->is_Compiler_thread()) { 1328 if (thread->is_Compiler_thread()) {
1329 blocking = false; 1329 blocking = false;
1330 } 1330 }
1331 1331
1332 // Don't allow blocking compiles if inside a class initializer or while performing class loading 1332 // Don't allow blocking compiles if inside a class initializer or while performing class loading
1340 } 1340 }
1341 } 1341 }
1342 1342
1343 // Don't allow blocking compilation requests to JVMCI 1343 // Don't allow blocking compilation requests to JVMCI
1344 // if JVMCI itself is not yet initialized 1344 // if JVMCI itself is not yet initialized
1345 if (!GraalRuntime::is_HotSpotJVMCIRuntime_initialized() && compiler(comp_level)->is_graal()) { 1345 if (!JVMCIRuntime::is_HotSpotJVMCIRuntime_initialized() && compiler(comp_level)->is_jvmci()) {
1346 blocking = false; 1346 blocking = false;
1347 } 1347 }
1348 1348
1349 // Don't allow blocking compilation requests if we are in GraalRuntime::shutdown 1349 // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
1350 // to avoid deadlock between compiler thread(s) and threads run at shutdown 1350 // to avoid deadlock between compiler thread(s) and threads run at shutdown
1351 // such as the DestroyJavaVM thread. 1351 // such as the DestroyJavaVM thread.
1352 if (GraalRuntime::shutdown_called()) { 1352 if (JVMCIRuntime::shutdown_called()) {
1353 blocking = false; 1353 blocking = false;
1354 } 1354 }
1355 } 1355 }
1356 // Don't allow blocking compiles 1356 // Don't allow blocking compiles
1357 #endif 1357 #endif
2079 int system_dictionary_modification_counter; 2079 int system_dictionary_modification_counter;
2080 { 2080 {
2081 MutexLocker locker(Compile_lock, thread); 2081 MutexLocker locker(Compile_lock, thread);
2082 system_dictionary_modification_counter = SystemDictionary::number_of_modifications(); 2082 system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
2083 } 2083 }
2084 #ifdef COMPILERGRAAL 2084 #ifdef COMPILERJVMCI
2085 if (comp != NULL && comp->is_graal()) { 2085 if (comp != NULL && comp->is_jvmci()) {
2086 GraalCompiler* graal = (GraalCompiler*) comp; 2086 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
2087 2087
2088 TraceTime t1("compilation", &time); 2088 TraceTime t1("compilation", &time);
2089 EventCompilation event; 2089 EventCompilation event;
2090 2090
2091 GraalEnv env(task, system_dictionary_modification_counter); 2091 JVMCIEnv env(task, system_dictionary_modification_counter);
2092 graal->compile_method(target_handle, osr_bci, &env); 2092 jvmci->compile_method(target_handle, osr_bci, &env);
2093 2093
2094 post_compile(thread, task, event, task->code() != NULL, NULL); 2094 post_compile(thread, task, event, task->code() != NULL, NULL);
2095 } else 2095 } else
2096 #endif // COMPILERGRAAL 2096 #endif // COMPILERJVMCI
2097 { 2097 {
2098 2098
2099 NoHandleMark nhm; 2099 NoHandleMark nhm;
2100 ThreadToNativeFromVM ttn(thread); 2100 ThreadToNativeFromVM ttn(thread);
2101 2101
2404 _t_total_compilation.add(time); 2404 _t_total_compilation.add(time);
2405 _peak_compilation_time = time.milliseconds() > _peak_compilation_time ? time.milliseconds() : _peak_compilation_time; 2405 _peak_compilation_time = time.milliseconds() > _peak_compilation_time ? time.milliseconds() : _peak_compilation_time;
2406 2406
2407 if (CITime) { 2407 if (CITime) {
2408 int bytes_compiled = method->code_size() + task->num_inlined_bytecodes(); 2408 int bytes_compiled = method->code_size() + task->num_inlined_bytecodes();
2409 GRAAL_ONLY(CompilerStatistics* stats = compiler(task->comp_level())->stats();) 2409 JVMCI_ONLY(CompilerStatistics* stats = compiler(task->comp_level())->stats();)
2410 if (is_osr) { 2410 if (is_osr) {
2411 _t_osr_compilation.add(time); 2411 _t_osr_compilation.add(time);
2412 _sum_osr_bytes_compiled += bytes_compiled; 2412 _sum_osr_bytes_compiled += bytes_compiled;
2413 GRAAL_ONLY(stats->_osr.update(time, bytes_compiled);) 2413 JVMCI_ONLY(stats->_osr.update(time, bytes_compiled);)
2414 } else { 2414 } else {
2415 _t_standard_compilation.add(time); 2415 _t_standard_compilation.add(time);
2416 _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes(); 2416 _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
2417 GRAAL_ONLY(stats->_standard.update(time, bytes_compiled);) 2417 JVMCI_ONLY(stats->_standard.update(time, bytes_compiled);)
2418 } 2418 }
2419 GRAAL_ONLY(stats->_nmethods_size += code->total_size();) 2419 JVMCI_ONLY(stats->_nmethods_size += code->total_size();)
2420 GRAAL_ONLY(stats->_nmethods_code_size += code->insts_size();) 2420 JVMCI_ONLY(stats->_nmethods_code_size += code->insts_size();)
2421 } 2421 }
2422 2422
2423 if (UsePerfData) { 2423 if (UsePerfData) {
2424 // save the name of the last method compiled 2424 // save the name of the last method compiled
2425 _perf_last_method->set_value(counters->current_method()); 2425 _perf_last_method->set_value(counters->current_method());
2471 } else { 2471 } else {
2472 return (comp->name()); 2472 return (comp->name());
2473 } 2473 }
2474 } 2474 }
2475 2475
2476 #ifdef GRAAL 2476 #ifdef JVMCI
2477 void CompileBroker::print_times(AbstractCompiler* comp) { 2477 void CompileBroker::print_times(AbstractCompiler* comp) {
2478 CompilerStatistics* stats = comp->stats(); 2478 CompilerStatistics* stats = comp->stats();
2479 tty->print_cr(" %s {speed: %d bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}", 2479 tty->print_cr(" %s {speed: %d bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}",
2480 comp->name(), stats->bytes_per_second(), 2480 comp->name(), stats->bytes_per_second(),
2481 stats->_standard._time.seconds(), stats->_standard._bytes, stats->_standard._count, 2481 stats->_standard._time.seconds(), stats->_standard._bytes, stats->_standard._count,
2484 comp->print_timers(); 2484 comp->print_timers();
2485 } 2485 }
2486 #endif 2486 #endif
2487 2487
2488 void CompileBroker::print_times(bool per_compiler, bool aggregate) { 2488 void CompileBroker::print_times(bool per_compiler, bool aggregate) {
2489 #ifdef GRAAL 2489 #ifdef JVMCI
2490 elapsedTimer standard_compilation; 2490 elapsedTimer standard_compilation;
2491 elapsedTimer total_compilation; 2491 elapsedTimer total_compilation;
2492 elapsedTimer osr_compilation; 2492 elapsedTimer osr_compilation;
2493 2493
2494 int standard_bytes_compiled = 0; 2494 int standard_bytes_compiled = 0;
2533 } 2533 }
2534 total_compile_count = osr_compile_count + standard_compile_count; 2534 total_compile_count = osr_compile_count + standard_compile_count;
2535 total_compilation.add(osr_compilation); 2535 total_compilation.add(osr_compilation);
2536 total_compilation.add(standard_compilation); 2536 total_compilation.add(standard_compilation);
2537 2537
2538 #ifndef COMPILERGRAAL 2538 #ifndef COMPILERJVMCI
2539 // In hosted mode, print the Graal compiler specific counters manually. 2539 // In hosted mode, print the JVMCI compiler specific counters manually.
2540 GraalCompiler::print_compilation_timers(); 2540 JVMCICompiler::print_compilation_timers();
2541 #endif 2541 #endif
2542 #else 2542 #else
2543 elapsedTimer standard_compilation = CompileBroker::_t_standard_compilation; 2543 elapsedTimer standard_compilation = CompileBroker::_t_standard_compilation;
2544 elapsedTimer osr_compilation = CompileBroker::_t_osr_compilation; 2544 elapsedTimer osr_compilation = CompileBroker::_t_osr_compilation;
2545 elapsedTimer total_compilation = CompileBroker::_t_total_compilation; 2545 elapsedTimer total_compilation = CompileBroker::_t_total_compilation;