Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/compilationPolicy.cpp @ 1202:5f24d0319e54
4360113: Evict nmethods when code cache gets full
Summary: Speculatively unload the oldest nmethods when code cache gets full.
Reviewed-by: never, kvn
Contributed-by: eric.caspole@amd.com
author | kvn |
---|---|
date | Fri, 29 Jan 2010 09:27:22 -0800 |
parents | ddb7834449d0 |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1201:24128c2ffa87 | 1202:5f24d0319e54 |
---|---|
64 bool CompilationPolicy::mustBeCompiled(methodHandle m) { | 64 bool CompilationPolicy::mustBeCompiled(methodHandle m) { |
65 if (m->has_compiled_code()) return false; // already compiled | 65 if (m->has_compiled_code()) return false; // already compiled |
66 if (!canBeCompiled(m)) return false; | 66 if (!canBeCompiled(m)) return false; |
67 | 67 |
68 return !UseInterpreter || // must compile all methods | 68 return !UseInterpreter || // must compile all methods |
69 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops()); // eagerly compile loop methods | 69 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods |
70 } | 70 } |
71 | 71 |
72 // Returns true if m is allowed to be compiled | 72 // Returns true if m is allowed to be compiled |
73 bool CompilationPolicy::canBeCompiled(methodHandle m) { | 73 bool CompilationPolicy::canBeCompiled(methodHandle m) { |
74 if (m->is_abstract()) return false; | 74 if (m->is_abstract()) return false; |
135 | 135 |
136 int hot_count = m->invocation_count(); | 136 int hot_count = m->invocation_count(); |
137 reset_counter_for_invocation_event(m); | 137 reset_counter_for_invocation_event(m); |
138 const char* comment = "count"; | 138 const char* comment = "count"; |
139 | 139 |
140 if (!delayCompilationDuringStartup() && canBeCompiled(m) && UseCompiler) { | 140 if (!delayCompilationDuringStartup() && canBeCompiled(m) && UseCompiler && CompileBroker::should_compile_new_jobs()) { |
141 nmethod* nm = m->code(); | 141 nmethod* nm = m->code(); |
142 if (nm == NULL ) { | 142 if (nm == NULL ) { |
143 const char* comment = "count"; | 143 const char* comment = "count"; |
144 CompileBroker::compile_method(m, InvocationEntryBci, | 144 CompileBroker::compile_method(m, InvocationEntryBci, |
145 m, hot_count, comment, CHECK); | 145 m, hot_count, comment, CHECK); |
160 assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now."); | 160 assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now."); |
161 | 161 |
162 int hot_count = m->backedge_count(); | 162 int hot_count = m->backedge_count(); |
163 const char* comment = "backedge_count"; | 163 const char* comment = "backedge_count"; |
164 | 164 |
165 if (!m->is_not_osr_compilable() && !delayCompilationDuringStartup() && canBeCompiled(m)) { | 165 if (!m->is_not_osr_compilable() && !delayCompilationDuringStartup() && canBeCompiled(m) && CompileBroker::should_compile_new_jobs()) { |
166 CompileBroker::compile_method(m, loop_top_bci, m, hot_count, comment, CHECK); | 166 CompileBroker::compile_method(m, loop_top_bci, m, hot_count, comment, CHECK); |
167 | 167 |
168 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(loop_top_bci));) | 168 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(loop_top_bci));) |
169 } | 169 } |
170 } | 170 } |
202 | 202 |
203 int hot_count = m->invocation_count(); | 203 int hot_count = m->invocation_count(); |
204 reset_counter_for_invocation_event(m); | 204 reset_counter_for_invocation_event(m); |
205 const char* comment = "count"; | 205 const char* comment = "count"; |
206 | 206 |
207 if (m->code() == NULL && !delayCompilationDuringStartup() && canBeCompiled(m) && UseCompiler) { | 207 if (m->code() == NULL && !delayCompilationDuringStartup() && canBeCompiled(m) && UseCompiler && CompileBroker::should_compile_new_jobs()) { |
208 ResourceMark rm(THREAD); | 208 ResourceMark rm(THREAD); |
209 JavaThread *thread = (JavaThread*)THREAD; | 209 JavaThread *thread = (JavaThread*)THREAD; |
210 frame fr = thread->last_frame(); | 210 frame fr = thread->last_frame(); |
211 assert(fr.is_interpreted_frame(), "must be interpreted"); | 211 assert(fr.is_interpreted_frame(), "must be interpreted"); |
212 assert(fr.interpreter_frame_method() == m(), "bad method"); | 212 assert(fr.interpreter_frame_method() == m(), "bad method"); |
246 assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now."); | 246 assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now."); |
247 | 247 |
248 int hot_count = m->backedge_count(); | 248 int hot_count = m->backedge_count(); |
249 const char* comment = "backedge_count"; | 249 const char* comment = "backedge_count"; |
250 | 250 |
251 if (!m->is_not_osr_compilable() && !delayCompilationDuringStartup() && canBeCompiled(m)) { | 251 if (!m->is_not_osr_compilable() && !delayCompilationDuringStartup() && canBeCompiled(m) && CompileBroker::should_compile_new_jobs()) { |
252 CompileBroker::compile_method(m, loop_top_bci, m, hot_count, comment, CHECK); | 252 CompileBroker::compile_method(m, loop_top_bci, m, hot_count, comment, CHECK); |
253 | 253 |
254 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(loop_top_bci));) | 254 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(loop_top_bci));) |
255 } | 255 } |
256 } | 256 } |