Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/compilationPolicy.cpp @ 10132:5b6512efcdc4
Merge
author | dcubed |
---|---|
date | Fri, 19 Apr 2013 16:51:27 -0700 |
parents | 8df6ddda8090 |
children | d1c9384eecb4 |
comparison
equal
deleted
inserted
replaced
10130:6f817ce50129 | 10132:5b6512efcdc4 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
196 // Make sure invocation and backedge counter doesn't overflow again right away | 196 // Make sure invocation and backedge counter doesn't overflow again right away |
197 // as would be the case for native methods. | 197 // as would be the case for native methods. |
198 | 198 |
199 // BUT also make sure the method doesn't look like it was never executed. | 199 // BUT also make sure the method doesn't look like it was never executed. |
200 // Set carry bit and reduce counter's value to min(count, CompileThreshold/2). | 200 // Set carry bit and reduce counter's value to min(count, CompileThreshold/2). |
201 m->invocation_counter()->set_carry(); | 201 MethodCounters* mcs = m->method_counters(); |
202 m->backedge_counter()->set_carry(); | 202 assert(mcs != NULL, "MethodCounters cannot be NULL for profiling"); |
203 mcs->invocation_counter()->set_carry(); | |
204 mcs->backedge_counter()->set_carry(); | |
203 | 205 |
204 assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed"); | 206 assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed"); |
205 } | 207 } |
206 | 208 |
207 void NonTieredCompPolicy::reset_counter_for_back_branch_event(methodHandle m) { | 209 void NonTieredCompPolicy::reset_counter_for_back_branch_event(methodHandle m) { |
208 // Delay next back-branch event but pump up invocation counter to triger | 210 // Delay next back-branch event but pump up invocation counter to triger |
209 // whole method compilation. | 211 // whole method compilation. |
210 InvocationCounter* i = m->invocation_counter(); | 212 MethodCounters* mcs = m->method_counters(); |
211 InvocationCounter* b = m->backedge_counter(); | 213 assert(mcs != NULL, "MethodCounters cannot be NULL for profiling"); |
214 InvocationCounter* i = mcs->invocation_counter(); | |
215 InvocationCounter* b = mcs->backedge_counter(); | |
212 | 216 |
213 // Don't set invocation_counter's value too low otherwise the method will | 217 // Don't set invocation_counter's value too low otherwise the method will |
214 // look like immature (ic < ~5300) which prevents the inlining based on | 218 // look like immature (ic < ~5300) which prevents the inlining based on |
215 // the type profiling. | 219 // the type profiling. |
216 i->set(i->state(), CompileThreshold); | 220 i->set(i->state(), CompileThreshold); |
225 // is done at each safepoint. | 229 // is done at each safepoint. |
226 // | 230 // |
227 class CounterDecay : public AllStatic { | 231 class CounterDecay : public AllStatic { |
228 static jlong _last_timestamp; | 232 static jlong _last_timestamp; |
229 static void do_method(Method* m) { | 233 static void do_method(Method* m) { |
230 m->invocation_counter()->decay(); | 234 MethodCounters* mcs = m->method_counters(); |
235 if (mcs != NULL) { | |
236 mcs->invocation_counter()->decay(); | |
237 } | |
231 } | 238 } |
232 public: | 239 public: |
233 static void decay(); | 240 static void decay(); |
234 static bool is_decay_needed() { | 241 static bool is_decay_needed() { |
235 return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength; | 242 return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength; |
263 } | 270 } |
264 } | 271 } |
265 | 272 |
266 void NonTieredCompPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { | 273 void NonTieredCompPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { |
267 ScopeDesc* sd = trap_scope; | 274 ScopeDesc* sd = trap_scope; |
275 MethodCounters* mcs; | |
276 InvocationCounter* c; | |
268 for (; !sd->is_top(); sd = sd->sender()) { | 277 for (; !sd->is_top(); sd = sd->sender()) { |
269 // Reset ICs of inlined methods, since they can trigger compilations also. | 278 mcs = sd->method()->method_counters(); |
270 sd->method()->invocation_counter()->reset(); | 279 if (mcs != NULL) { |
271 } | 280 // Reset ICs of inlined methods, since they can trigger compilations also. |
272 InvocationCounter* c = sd->method()->invocation_counter(); | 281 mcs->invocation_counter()->reset(); |
273 if (is_osr) { | 282 } |
274 // It was an OSR method, so bump the count higher. | 283 } |
275 c->set(c->state(), CompileThreshold); | 284 mcs = sd->method()->method_counters(); |
276 } else { | 285 if (mcs != NULL) { |
277 c->reset(); | 286 c = mcs->invocation_counter(); |
278 } | 287 if (is_osr) { |
279 sd->method()->backedge_counter()->reset(); | 288 // It was an OSR method, so bump the count higher. |
289 c->set(c->state(), CompileThreshold); | |
290 } else { | |
291 c->reset(); | |
292 } | |
293 mcs->backedge_counter()->reset(); | |
294 } | |
280 } | 295 } |
281 | 296 |
282 // This method can be called by any component of the runtime to notify the policy | 297 // This method can be called by any component of the runtime to notify the policy |
283 // that it's recommended to delay the complation of this method. | 298 // that it's recommended to delay the complation of this method. |
284 void NonTieredCompPolicy::delay_compilation(Method* method) { | 299 void NonTieredCompPolicy::delay_compilation(Method* method) { |
285 method->invocation_counter()->decay(); | 300 MethodCounters* mcs = method->method_counters(); |
286 method->backedge_counter()->decay(); | 301 if (mcs != NULL) { |
302 mcs->invocation_counter()->decay(); | |
303 mcs->backedge_counter()->decay(); | |
304 } | |
287 } | 305 } |
288 | 306 |
289 void NonTieredCompPolicy::disable_compilation(Method* method) { | 307 void NonTieredCompPolicy::disable_compilation(Method* method) { |
290 method->invocation_counter()->set_state(InvocationCounter::wait_for_nothing); | 308 MethodCounters* mcs = method->method_counters(); |
291 method->backedge_counter()->set_state(InvocationCounter::wait_for_nothing); | 309 if (mcs != NULL) { |
310 mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing); | |
311 mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing); | |
312 } | |
292 } | 313 } |
293 | 314 |
294 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) { | 315 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) { |
295 return compile_queue->first(); | 316 return compile_queue->first(); |
296 } | 317 } |
369 } | 390 } |
370 | 391 |
371 #ifndef PRODUCT | 392 #ifndef PRODUCT |
372 void NonTieredCompPolicy::trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci) { | 393 void NonTieredCompPolicy::trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci) { |
373 if (TraceInvocationCounterOverflow) { | 394 if (TraceInvocationCounterOverflow) { |
374 InvocationCounter* ic = m->invocation_counter(); | 395 MethodCounters* mcs = m->method_counters(); |
375 InvocationCounter* bc = m->backedge_counter(); | 396 assert(mcs != NULL, "MethodCounters cannot be NULL for profiling"); |
397 InvocationCounter* ic = mcs->invocation_counter(); | |
398 InvocationCounter* bc = mcs->backedge_counter(); | |
376 ResourceMark rm; | 399 ResourceMark rm; |
377 const char* msg = | 400 const char* msg = |
378 bci == InvocationEntryBci | 401 bci == InvocationEntryBci |
379 ? "comp-policy cntr ovfl @ %d in entry of " | 402 ? "comp-policy cntr ovfl @ %d in entry of " |
380 : "comp-policy cntr ovfl @ %d in loop of "; | 403 : "comp-policy cntr ovfl @ %d in loop of "; |