108 { \
109 Symbol* klass_name = (method)->klass_name(); \
110 Symbol* name = (method)->name(); \
111 Symbol* signature = (method)->signature(); \
112 HOTSPOT_METHOD_COMPILE_END( \
113 comp_name, strlen(comp_name), \
114 (char *) klass_name->bytes(), klass_name->utf8_length(), \
115 (char *) name->bytes(), name->utf8_length(), \
116 (char *) signature->bytes(), signature->utf8_length(), (success)); \
117 }
118 #endif /* USDT2 */
119
120 #else // ndef DTRACE_ENABLED
121
122 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name)
123 #define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success)
124
125 #endif // ndef DTRACE_ENABLED
126
127 bool CompileBroker::_initialized = false;
128 volatile bool CompileBroker::_should_block = false;
129 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation;
130
131 // The installed compiler(s)
132 AbstractCompiler* CompileBroker::_compilers[2];
133
134 // These counters are used for assigning id's to each compilation
135 uint CompileBroker::_compilation_id = 0;
136 uint CompileBroker::_osr_compilation_id = 0;
137
138 // Debugging information
139 int CompileBroker::_last_compile_type = no_compile;
140 int CompileBroker::_last_compile_level = CompLevel_none;
141 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length];
142
143 // Performance counters
144 PerfCounter* CompileBroker::_perf_total_compilation = NULL;
145 PerfCounter* CompileBroker::_perf_osr_compilation = NULL;
146 PerfCounter* CompileBroker::_perf_standard_compilation = NULL;
147
2010
2011 // Note that the queued_for_compilation bits are cleared without
2012 // protection of a mutex. [They were set by the requester thread,
2013 // when adding the task to the complie queue -- at which time the
2014 // compile queue lock was held. Subsequently, we acquired the compile
2015 // queue lock to get this task off the compile queue; thus (to belabour
2016 // the point somewhat) our clearing of the bits must be occurring
2017 // only after the setting of the bits. See also 14012000 above.
2018 method->clear_queued_for_compilation();
2019
2020 #ifdef ASSERT
2021 if (CollectedHeap::fired_fake_oom()) {
2022 // The current compile received a fake OOM during compilation so
2023 // go ahead and exit the VM since the test apparently succeeded
2024 tty->print_cr("*** Shutting down VM after successful fake OOM");
2025 vm_exit(0);
2026 }
2027 #endif
2028 }
2029
2030 // ------------------------------------------------------------------
2031 // CompileBroker::handle_full_code_cache
2032 //
2033 // The CodeCache is full. Print out warning and disable compilation or
2034 // try code cache cleaning so compilation can continue later.
2035 void CompileBroker::handle_full_code_cache() {
2036 UseInterpreter = true;
2037 if (UseCompiler || AlwaysCompileLoopMethods ) {
2038 if (xtty != NULL) {
2039 ResourceMark rm;
2040 stringStream s;
2041 // Dump code cache state into a buffer before locking the tty,
2042 // because log_state() will use locks causing lock conflicts.
2043 CodeCache::log_state(&s);
2044 // Lock to prevent tearing
2045 ttyLocker ttyl;
2046 xtty->begin_elem("code_cache_full");
2047 xtty->print(s.as_string());
2048 xtty->stamp();
2049 xtty->end_elem();
2050 }
2051 warning("CodeCache is full. Compiler has been disabled.");
2052 warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
2053
2054 CodeCache::report_codemem_full();
2055
2056
2057 #ifndef PRODUCT
2058 if (CompileTheWorld || ExitOnFullCodeCache) {
2059 codecache_print(/* detailed= */ true);
2060 before_exit(JavaThread::current());
2061 exit_globals(); // will delete tty
2062 vm_direct_exit(CompileTheWorld ? 0 : 1);
2063 }
2064 #endif
2065 if (UseCodeCacheFlushing) {
2066 // Since code cache is full, immediately stop new compiles
2067 if (CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation)) {
2068 NMethodSweeper::log_sweep("disable_compiler");
2069
2070 // Switch to 'vm_state'. This ensures that possibly_sweep() can be called
2071 // without having to consider the state in which the current thread is.
2072 ThreadInVMfromUnknown in_vm;
2073 NMethodSweeper::possibly_sweep();
2074 }
2075 } else {
2076 disable_compilation_forever();
2077 }
2078 }
2079 codecache_print(/* detailed= */ true);
2080 }
2081
2082 // ------------------------------------------------------------------
2083 // CompileBroker::set_last_compile
2084 //
2085 // Record this compilation for debugging purposes.
2086 void CompileBroker::set_last_compile(CompilerThread* thread, methodHandle method, bool is_osr, int comp_level) {
2087 ResourceMark rm;
2088 char* method_name = method->name()->as_C_string();
2089 strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length);
2090 char current_method[CompilerCounters::cmname_buffer_length];
2091 size_t maxLen = CompilerCounters::cmname_buffer_length;
2092
2093 if (UsePerfData) {
2094 const char* class_name = method->method_holder()->name()->as_C_string();
2095
2096 size_t s1len = strlen(class_name);
2097 size_t s2len = strlen(method_name);
2098
2099 // check if we need to truncate the string
|
108 { \
109 Symbol* klass_name = (method)->klass_name(); \
110 Symbol* name = (method)->name(); \
111 Symbol* signature = (method)->signature(); \
112 HOTSPOT_METHOD_COMPILE_END( \
113 comp_name, strlen(comp_name), \
114 (char *) klass_name->bytes(), klass_name->utf8_length(), \
115 (char *) name->bytes(), name->utf8_length(), \
116 (char *) signature->bytes(), signature->utf8_length(), (success)); \
117 }
118 #endif /* USDT2 */
119
120 #else // ndef DTRACE_ENABLED
121
122 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name)
123 #define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success)
124
125 #endif // ndef DTRACE_ENABLED
126
127 bool CompileBroker::_initialized = false;
128 int CompileBroker::_compilation_warning_counter = -1;
129 volatile bool CompileBroker::_should_block = false;
130 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation;
131
132 // The installed compiler(s)
133 AbstractCompiler* CompileBroker::_compilers[2];
134
135 // These counters are used for assigning id's to each compilation
136 uint CompileBroker::_compilation_id = 0;
137 uint CompileBroker::_osr_compilation_id = 0;
138
139 // Debugging information
140 int CompileBroker::_last_compile_type = no_compile;
141 int CompileBroker::_last_compile_level = CompLevel_none;
142 char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length];
143
144 // Performance counters
145 PerfCounter* CompileBroker::_perf_total_compilation = NULL;
146 PerfCounter* CompileBroker::_perf_osr_compilation = NULL;
147 PerfCounter* CompileBroker::_perf_standard_compilation = NULL;
148
2011
2012 // Note that the queued_for_compilation bits are cleared without
2013 // protection of a mutex. [They were set by the requester thread,
2014 // when adding the task to the complie queue -- at which time the
2015 // compile queue lock was held. Subsequently, we acquired the compile
2016 // queue lock to get this task off the compile queue; thus (to belabour
2017 // the point somewhat) our clearing of the bits must be occurring
2018 // only after the setting of the bits. See also 14012000 above.
2019 method->clear_queued_for_compilation();
2020
2021 #ifdef ASSERT
2022 if (CollectedHeap::fired_fake_oom()) {
2023 // The current compile received a fake OOM during compilation so
2024 // go ahead and exit the VM since the test apparently succeeded
2025 tty->print_cr("*** Shutting down VM after successful fake OOM");
2026 vm_exit(0);
2027 }
2028 #endif
2029 }
2030
2031 /**
2032 * The CodeCache is full. Print out warning and disable compilation
2033 * or try code cache cleaning so compilation can continue later.
2034 */
2035 void CompileBroker::handle_full_code_cache() {
2036 UseInterpreter = true;
2037 if (UseCompiler || AlwaysCompileLoopMethods ) {
2038 if (xtty != NULL) {
2039 ResourceMark rm;
2040 stringStream s;
2041 // Dump code cache state into a buffer before locking the tty,
2042 // because log_state() will use locks causing lock conflicts.
2043 CodeCache::log_state(&s);
2044 // Lock to prevent tearing
2045 ttyLocker ttyl;
2046 xtty->begin_elem("code_cache_full");
2047 xtty->print(s.as_string());
2048 xtty->stamp();
2049 xtty->end_elem();
2050 }
2051
2052 // Increase counter only if compilation is enabled.
2053 if (should_compile_new_jobs()) {
2054 _compilation_warning_counter++;
2055 }
2056
2057 if (should_print_compiler_warning()) {
2058 warning("CodeCache is full. Compiler has been disabled.");
2059 warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
2060 warning("(Printing one such message for every 10th event)");
2061 codecache_print(/* detailed= */ true);
2062 }
2063
2064 CodeCache::report_codemem_full();
2065
2066
2067 #ifndef PRODUCT
2068 if (CompileTheWorld || ExitOnFullCodeCache) {
2069 codecache_print(/* detailed= */ true);
2070 before_exit(JavaThread::current());
2071 exit_globals(); // will delete tty
2072 vm_direct_exit(CompileTheWorld ? 0 : 1);
2073 }
2074 #endif
2075 if (UseCodeCacheFlushing) {
2076 // Since code cache is full, immediately stop new compiles
2077 if (CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation)) {
2078 NMethodSweeper::log_sweep("disable_compiler");
2079 }
2080 // Switch to 'vm_state'. This ensures that possibly_sweep() can be called
2081 // without having to consider the state in which the current thread is.
2082 ThreadInVMfromUnknown in_vm;
2083 NMethodSweeper::possibly_sweep();
2084 } else {
2085 disable_compilation_forever();
2086 }
2087 }
2088 }
2089
2090 // ------------------------------------------------------------------
2091 // CompileBroker::set_last_compile
2092 //
2093 // Record this compilation for debugging purposes.
2094 void CompileBroker::set_last_compile(CompilerThread* thread, methodHandle method, bool is_osr, int comp_level) {
2095 ResourceMark rm;
2096 char* method_name = method->name()->as_C_string();
2097 strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length);
2098 char current_method[CompilerCounters::cmname_buffer_length];
2099 size_t maxLen = CompilerCounters::cmname_buffer_length;
2100
2101 if (UsePerfData) {
2102 const char* class_name = method->method_holder()->name()->as_C_string();
2103
2104 size_t s1len = strlen(class_name);
2105 size_t s2len = strlen(method_name);
2106
2107 // check if we need to truncate the string
|