Mercurial > hg > graal-jvmci-8
comparison src/share/vm/compiler/compileBroker.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 3eed8712d410 f73af4455d7d |
children | 2a69cbe850a8 |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
137 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; | 137 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; |
138 | 138 |
139 // The installed compiler(s) | 139 // The installed compiler(s) |
140 AbstractCompiler* CompileBroker::_compilers[2]; | 140 AbstractCompiler* CompileBroker::_compilers[2]; |
141 | 141 |
142 // These counters are used for assigning id's to each compilation | 142 // These counters are used to assign an unique ID to each compilation. |
143 uint CompileBroker::_compilation_id = 0; | 143 volatile jint CompileBroker::_compilation_id = 0; |
144 uint CompileBroker::_osr_compilation_id = 0; | 144 volatile jint CompileBroker::_osr_compilation_id = 0; |
145 | 145 |
146 // Debugging information | 146 // Debugging information |
147 int CompileBroker::_last_compile_type = no_compile; | 147 int CompileBroker::_last_compile_type = no_compile; |
148 int CompileBroker::_last_compile_level = CompLevel_none; | 148 int CompileBroker::_last_compile_level = CompLevel_none; |
149 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length]; | 149 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length]; |
211 } | 211 } |
212 | 212 |
213 void log_nmethod(JavaThread* thread, nmethod* nm) { | 213 void log_nmethod(JavaThread* thread, nmethod* nm) { |
214 log(thread, "nmethod %d%s " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]", | 214 log(thread, "nmethod %d%s " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]", |
215 nm->compile_id(), nm->is_osr_method() ? "%" : "", | 215 nm->compile_id(), nm->is_osr_method() ? "%" : "", |
216 nm, nm->code_begin(), nm->code_end()); | 216 p2i(nm), p2i(nm->code_begin()), p2i(nm->code_end())); |
217 } | 217 } |
218 | 218 |
219 void log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) { | 219 void log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) { |
220 StringLogMessage lm; | 220 StringLogMessage lm; |
221 lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason); | 221 lm.print("%4d COMPILE SKIPPED: %s", task->compile_id(), reason); |
1179 } | 1179 } |
1180 | 1180 |
1181 // We now know that this compilation is not pending, complete, | 1181 // We now know that this compilation is not pending, complete, |
1182 // or prohibited. Assign a compile_id to this compilation | 1182 // or prohibited. Assign a compile_id to this compilation |
1183 // and check to see if it is in our [Start..Stop) range. | 1183 // and check to see if it is in our [Start..Stop) range. |
1184 uint compile_id = assign_compile_id(method, osr_bci); | 1184 int compile_id = assign_compile_id(method, osr_bci); |
1185 if (compile_id == 0) { | 1185 if (compile_id == 0) { |
1186 // The compilation falls outside the allowed range. | 1186 // The compilation falls outside the allowed range. |
1187 return; | 1187 return; |
1188 } | 1188 } |
1189 | 1189 |
1351 } | 1351 } |
1352 | 1352 |
1353 // do the compilation | 1353 // do the compilation |
1354 if (method->is_native()) { | 1354 if (method->is_native()) { |
1355 if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { | 1355 if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { |
1356 // Acquire our lock. | |
1357 int compile_id; | |
1358 { | |
1359 MutexLocker locker(MethodCompileQueue_lock, THREAD); | |
1360 compile_id = assign_compile_id(method, standard_entry_bci); | |
1361 } | |
1362 // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that | 1356 // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that |
1363 // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). | 1357 // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). |
1364 // | 1358 // |
1365 // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter | 1359 // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter |
1366 // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. | 1360 // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. |
1367 (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); | 1361 AdapterHandlerLibrary::create_native_wrapper(method); |
1368 } else { | 1362 } else { |
1369 return NULL; | 1363 return NULL; |
1370 } | 1364 } |
1371 } else { | 1365 } else { |
1372 // If the compiler is shut off due to code cache getting full | 1366 // If the compiler is shut off due to code cache getting full |
1465 } | 1459 } |
1466 | 1460 |
1467 return false; | 1461 return false; |
1468 } | 1462 } |
1469 | 1463 |
1470 | 1464 /** |
1471 // ------------------------------------------------------------------ | 1465 * Generate serialized IDs for compilation requests. If certain debugging flags are used |
1472 // CompileBroker::assign_compile_id | 1466 * and the ID is not within the specified range, the method is not compiled and 0 is returned. |
1473 // | 1467 * The function also allows to generate separate compilation IDs for OSR compilations. |
1474 // Assign a serialized id number to this compilation request. If the | 1468 */ |
1475 // number falls out of the allowed range, return a 0. OSR | 1469 int CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { |
1476 // compilations may be numbered separately from regular compilations | 1470 #ifdef ASSERT |
1477 // if certain debugging flags are used. | |
1478 uint CompileBroker::assign_compile_id(methodHandle method, int osr_bci) { | |
1479 assert(MethodCompileQueue_lock->owner() == Thread::current(), | |
1480 "must hold the compilation queue lock"); | |
1481 bool is_osr = (osr_bci != standard_entry_bci); | 1471 bool is_osr = (osr_bci != standard_entry_bci); |
1482 uint id; | 1472 int id; |
1483 if (CICountOSR && is_osr) { | 1473 if (method->is_native()) { |
1484 id = ++_osr_compilation_id; | 1474 assert(!is_osr, "can't be osr"); |
1485 if ((uint)CIStartOSR <= id && id < (uint)CIStopOSR) { | 1475 // Adapters, native wrappers and method handle intrinsics |
1476 // should be generated always. | |
1477 return Atomic::add(1, &_compilation_id); | |
1478 } else if (CICountOSR && is_osr) { | |
1479 id = Atomic::add(1, &_osr_compilation_id); | |
1480 if (CIStartOSR <= id && id < CIStopOSR) { | |
1486 return id; | 1481 return id; |
1487 } | 1482 } |
1488 } else { | 1483 } else { |
1489 id = ++_compilation_id; | 1484 id = Atomic::add(1, &_compilation_id); |
1490 if ((uint)CIStart <= id && id < (uint)CIStop) { | 1485 if (CIStart <= id && id < CIStop) { |
1491 return id; | 1486 return id; |
1492 } | 1487 } |
1493 } | 1488 } |
1494 | 1489 |
1495 // Method was not in the appropriate compilation range. | 1490 // Method was not in the appropriate compilation range. |
1496 method->set_not_compilable_quietly(); | 1491 method->set_not_compilable_quietly(); |
1497 return 0; | 1492 return 0; |
1493 #else | |
1494 // CICountOSR is a develop flag and set to 'false' by default. In a product built, | |
1495 // only _compilation_id is incremented. | |
1496 return Atomic::add(1, &_compilation_id); | |
1497 #endif | |
1498 } | 1498 } |
1499 | 1499 |
1500 | 1500 |
1501 // ------------------------------------------------------------------ | 1501 // ------------------------------------------------------------------ |
1502 // CompileBroker::assign_compile_id_unlocked | 1502 // CompileBroker::assign_compile_id_unlocked |
1847 thread->init_log(log); | 1847 thread->init_log(log); |
1848 | 1848 |
1849 if (xtty != NULL) { | 1849 if (xtty != NULL) { |
1850 ttyLocker ttyl; | 1850 ttyLocker ttyl; |
1851 // Record any per thread log files | 1851 // Record any per thread log files |
1852 xtty->elem("thread_logfile thread='%d' filename='%s'", thread_id, file_name); | 1852 xtty->elem("thread_logfile thread='" INTX_FORMAT "' filename='%s'", thread_id, file_name); |
1853 } | 1853 } |
1854 return; | 1854 return; |
1855 } | 1855 } |
1856 } | 1856 } |
1857 warning("Cannot open log file: %s", file_name); | 1857 warning("Cannot open log file: %s", file_name); |
1878 // Call this from the compiler at convenient points, to poll for _should_block. | 1878 // Call this from the compiler at convenient points, to poll for _should_block. |
1879 void CompileBroker::maybe_block() { | 1879 void CompileBroker::maybe_block() { |
1880 if (_should_block) { | 1880 if (_should_block) { |
1881 #ifndef PRODUCT | 1881 #ifndef PRODUCT |
1882 if (PrintCompilation && (Verbose || WizardMode)) | 1882 if (PrintCompilation && (Verbose || WizardMode)) |
1883 tty->print_cr("compiler thread " INTPTR_FORMAT " poll detects block request", Thread::current()); | 1883 tty->print_cr("compiler thread " INTPTR_FORMAT " poll detects block request", p2i(Thread::current())); |
1884 #endif | 1884 #endif |
1885 ThreadInVMfromNative tivfn(JavaThread::current()); | 1885 ThreadInVMfromNative tivfn(JavaThread::current()); |
1886 } | 1886 } |
1887 } | 1887 } |
1888 | 1888 |
1895 { | 1895 { |
1896 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | 1896 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1897 CodeCache::print_summary(&s, detailed); | 1897 CodeCache::print_summary(&s, detailed); |
1898 } | 1898 } |
1899 ttyLocker ttyl; | 1899 ttyLocker ttyl; |
1900 tty->print(s.as_string()); | 1900 tty->print("%s", s.as_string()); |
1901 } | 1901 } |
1902 | 1902 |
1903 void CompileBroker::post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env) { | 1903 void CompileBroker::post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env) { |
1904 | 1904 |
1905 if (success) { | 1905 if (success) { |
2123 // because log_state() will use locks causing lock conflicts. | 2123 // because log_state() will use locks causing lock conflicts. |
2124 CodeCache::log_state(&s); | 2124 CodeCache::log_state(&s); |
2125 // Lock to prevent tearing | 2125 // Lock to prevent tearing |
2126 ttyLocker ttyl; | 2126 ttyLocker ttyl; |
2127 xtty->begin_elem("code_cache_full"); | 2127 xtty->begin_elem("code_cache_full"); |
2128 xtty->print(s.as_string()); | 2128 xtty->print("%s", s.as_string()); |
2129 xtty->stamp(); | 2129 xtty->stamp(); |
2130 xtty->end_elem(); | 2130 xtty->end_elem(); |
2131 } | 2131 } |
2132 | 2132 |
2133 CodeCache::report_codemem_full(); | 2133 CodeCache::report_codemem_full(); |