Mercurial > hg > truffle
comparison src/share/vm/compiler/compileBroker.cpp @ 15463:a20be10ad437
made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 02 May 2014 00:36:27 +0200 |
parents | 4062efea018b |
children | 07fac8558d7b |
comparison
equal
deleted
inserted
replaced
15462:05d3f069cff2 | 15463:a20be10ad437 |
---|---|
802 } | 802 } |
803 #endif // COMPILER1 | 803 #endif // COMPILER1 |
804 | 804 |
805 #if defined(COMPILERGRAAL) | 805 #if defined(COMPILERGRAAL) |
806 _compilers[1] = graal; | 806 _compilers[1] = graal; |
807 c2_count = 0; | 807 c2_count = UseGraalCompilationQueue ? 0 : c2_count; |
808 #endif // COMPILERGRAAL | 808 #endif // COMPILERGRAAL |
809 | 809 |
810 #ifdef COMPILER2 | 810 #ifdef COMPILER2 |
811 if (c2_count > 0) { | 811 if (c2_count > 0) { |
812 _compilers[1] = new C2Compiler(); | 812 _compilers[1] = new C2Compiler(); |
1141 // by a compiler thread), and compiled method registration. | 1141 // by a compiler thread), and compiled method registration. |
1142 if (InstanceRefKlass::owns_pending_list_lock(JavaThread::current())) { | 1142 if (InstanceRefKlass::owns_pending_list_lock(JavaThread::current())) { |
1143 return; | 1143 return; |
1144 } | 1144 } |
1145 | 1145 |
1146 #if defined(COMPILERGRAAL) | 1146 #ifdef COMPILERGRAAL |
1147 // In tiered mode we want to only handle highest tier compiles and | 1147 if (UseGraalCompilationQueue) { |
1148 // in non-tiered mode the default level should be | 1148 // In tiered mode we want to only handle highest tier compiles and |
1149 // CompLevel_full_optimization which equals CompLevel_highest_tier. | 1149 // in non-tiered mode the default level should be |
1150 assert(TieredCompilation || comp_level == CompLevel_full_optimization, "incorrect compile level"); | 1150 // CompLevel_full_optimization which equals CompLevel_highest_tier. |
1151 assert(CompLevel_full_optimization == CompLevel_highest_tier, "incorrect level definition"); | 1151 assert(TieredCompilation || comp_level == CompLevel_full_optimization, "incorrect compile level"); |
1152 if (comp_level == CompLevel_full_optimization) { | 1152 assert(CompLevel_full_optimization == CompLevel_highest_tier, "incorrect level definition"); |
1153 if (!JavaThread::current()->is_graal_compiling()) { | 1153 if (comp_level == CompLevel_full_optimization) { |
1154 bool blockingCompilation = is_compile_blocking(method, osr_bci); | 1154 if (!JavaThread::current()->is_graal_compiling()) { |
1155 GraalCompiler::instance()->compile_method(method, osr_bci, blockingCompilation); | 1155 bool blockingCompilation = is_compile_blocking(method, osr_bci); |
1156 } else { | 1156 GraalCompiler::instance()->compile_method(method, osr_bci, NULL, blockingCompilation); |
1157 // Can't enqueue this request because there would be no one to service it, so simply return. | 1157 } else { |
1158 } | 1158 // Can't enqueue this request because there would be no one to service it, so simply return. |
1159 return; | 1159 } |
1160 } | 1160 return; |
1161 assert(TieredCompilation, "should only reach here in tiered mode"); | 1161 } |
1162 assert(TieredCompilation, "should only reach here in tiered mode"); | |
1163 } | |
1162 #endif // COMPILERGRAAL | 1164 #endif // COMPILERGRAAL |
1163 | 1165 |
1164 // Outputs from the following MutexLocker block: | 1166 // Outputs from the following MutexLocker block: |
1165 CompileTask* task = NULL; | 1167 CompileTask* task = NULL; |
1166 bool blocking = false; | 1168 bool blocking = false; |
1879 } | 1881 } |
1880 ttyLocker ttyl; | 1882 ttyLocker ttyl; |
1881 tty->print(s.as_string()); | 1883 tty->print(s.as_string()); |
1882 } | 1884 } |
1883 | 1885 |
1886 void CompileBroker::post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env) { | |
1887 | |
1888 if (success) { | |
1889 task->mark_success(); | |
1890 if (ci_env != NULL) { | |
1891 task->set_num_inlined_bytecodes(ci_env->num_inlined_bytecodes()); | |
1892 } | |
1893 if (_compilation_log != NULL) { | |
1894 nmethod* code = task->code(); | |
1895 if (code != NULL) { | |
1896 _compilation_log->log_nmethod(thread, code); | |
1897 } | |
1898 } | |
1899 } | |
1900 | |
1901 // simulate crash during compilation | |
1902 assert(task->compile_id() != CICrashAt, "just as planned"); | |
1903 if (event.should_commit()) { | |
1904 event.set_method(task->method()); | |
1905 event.set_compileID(task->compile_id()); | |
1906 event.set_compileLevel(task->comp_level()); | |
1907 event.set_succeded(task->is_success()); | |
1908 event.set_isOsr(task->osr_bci() != CompileBroker::standard_entry_bci); | |
1909 event.set_codeSize((task->code() == NULL) ? 0 : task->code()->total_size()); | |
1910 event.set_inlinedBytes(task->num_inlined_bytecodes()); | |
1911 event.commit(); | |
1912 } | |
1913 } | |
1914 | |
1884 // ------------------------------------------------------------------ | 1915 // ------------------------------------------------------------------ |
1885 // CompileBroker::invoke_compiler_on_method | 1916 // CompileBroker::invoke_compiler_on_method |
1886 // | 1917 // |
1887 // Compile a method. | 1918 // Compile a method. |
1888 // | 1919 // |
1927 | 1958 |
1928 // Allocate a new set of JNI handles. | 1959 // Allocate a new set of JNI handles. |
1929 push_jni_handle_block(); | 1960 push_jni_handle_block(); |
1930 Method* target_handle = task->method(); | 1961 Method* target_handle = task->method(); |
1931 int compilable = ciEnv::MethodCompilable; | 1962 int compilable = ciEnv::MethodCompilable; |
1963 AbstractCompiler *comp = compiler(task_level); | |
1964 | |
1965 #ifdef COMPILERGRAAL | |
1966 if (comp != NULL && comp->is_graal()) { | |
1967 assert(!UseGraalCompilationQueue, "should not reach here"); | |
1968 GraalCompiler* graal = (GraalCompiler*) comp; | |
1969 | |
1970 TraceTime t1("compilation", &time); | |
1971 EventCompilation event; | |
1972 | |
1973 graal->compile_method(target_handle, osr_bci, task, false); | |
1974 | |
1975 post_compile(thread, task, event, task->code() != NULL, NULL); | |
1976 } else | |
1977 #endif // COMPILERGRAAL | |
1932 { | 1978 { |
1933 int system_dictionary_modification_counter; | 1979 int system_dictionary_modification_counter; |
1934 { | 1980 { |
1935 MutexLocker locker(Compile_lock, thread); | 1981 MutexLocker locker(Compile_lock, thread); |
1936 system_dictionary_modification_counter = SystemDictionary::number_of_modifications(); | 1982 system_dictionary_modification_counter = SystemDictionary::number_of_modifications(); |
1958 ciMethod* target = ci_env.get_method_from_handle(target_handle); | 2004 ciMethod* target = ci_env.get_method_from_handle(target_handle); |
1959 | 2005 |
1960 TraceTime t1("compilation", &time); | 2006 TraceTime t1("compilation", &time); |
1961 EventCompilation event; | 2007 EventCompilation event; |
1962 | 2008 |
1963 AbstractCompiler *comp = compiler(task_level); | |
1964 if (comp == NULL) { | 2009 if (comp == NULL) { |
1965 ci_env.record_method_not_compilable("no compiler", !TieredCompilation); | 2010 ci_env.record_method_not_compilable("no compiler", !TieredCompilation); |
1966 } else { | 2011 } else { |
1967 comp->compile_method(&ci_env, target, osr_bci); | 2012 comp->compile_method(&ci_env, target, osr_bci); |
1968 } | 2013 } |
1986 FormatBufferResource msg = retry_message != NULL ? | 2031 FormatBufferResource msg = retry_message != NULL ? |
1987 err_msg_res("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) : | 2032 err_msg_res("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) : |
1988 err_msg_res("COMPILE SKIPPED: %s", ci_env.failure_reason()); | 2033 err_msg_res("COMPILE SKIPPED: %s", ci_env.failure_reason()); |
1989 task->print_compilation(tty, msg); | 2034 task->print_compilation(tty, msg); |
1990 } | 2035 } |
1991 } else { | 2036 } |
1992 task->mark_success(); | 2037 |
1993 task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes()); | 2038 post_compile(thread, task, event, !ci_env.failing(), &ci_env); |
1994 if (_compilation_log != NULL) { | |
1995 nmethod* code = task->code(); | |
1996 if (code != NULL) { | |
1997 _compilation_log->log_nmethod(thread, code); | |
1998 } | |
1999 } | |
2000 } | |
2001 // simulate crash during compilation | |
2002 assert(task->compile_id() != CICrashAt, "just as planned"); | |
2003 if (event.should_commit()) { | |
2004 event.set_method(target->get_Method()); | |
2005 event.set_compileID(compile_id); | |
2006 event.set_compileLevel(task->comp_level()); | |
2007 event.set_succeded(task->is_success()); | |
2008 event.set_isOsr(is_osr); | |
2009 event.set_codeSize((task->code() == NULL) ? 0 : task->code()->total_size()); | |
2010 event.set_inlinedBytes(task->num_inlined_bytecodes()); | |
2011 event.commit(); | |
2012 } | |
2013 } | 2039 } |
2014 pop_jni_handle_block(); | 2040 pop_jni_handle_block(); |
2015 | 2041 |
2016 methodHandle method(thread, task->method()); | 2042 methodHandle method(thread, task->method()); |
2017 | 2043 |