Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/compiler/compilationPolicy.cpp
40930 views
1
/*
2
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#include "precompiled.hpp"
26
#include "code/scopeDesc.hpp"
27
#include "compiler/compilationPolicy.hpp"
28
#include "compiler/compileBroker.hpp"
29
#include "compiler/compilerOracle.hpp"
30
#include "memory/resourceArea.hpp"
31
#include "oops/methodData.hpp"
32
#include "oops/method.inline.hpp"
33
#include "oops/oop.inline.hpp"
34
#include "prims/jvmtiExport.hpp"
35
#include "runtime/arguments.hpp"
36
#include "runtime/deoptimization.hpp"
37
#include "runtime/frame.hpp"
38
#include "runtime/frame.inline.hpp"
39
#include "runtime/globals_extension.hpp"
40
#include "runtime/handles.inline.hpp"
41
#include "runtime/safepoint.hpp"
42
#include "runtime/safepointVerifiers.hpp"
43
44
#if INCLUDE_JVMCI
45
#include "jvmci/jvmci.hpp"
46
#endif
47
48
#ifdef COMPILER1
49
#include "c1/c1_Compiler.hpp"
50
#endif
51
52
#ifdef COMPILER2
53
#include "opto/c2compiler.hpp"
54
#endif
55
56
jlong CompilationPolicy::_start_time = 0;
57
int CompilationPolicy::_c1_count = 0;
58
int CompilationPolicy::_c2_count = 0;
59
double CompilationPolicy::_increase_threshold_at_ratio = 0;
60
61
void compilationPolicy_init() {
62
CompilationPolicy::initialize();
63
}
64
65
int CompilationPolicy::compiler_count(CompLevel comp_level) {
66
if (is_c1_compile(comp_level)) {
67
return c1_count();
68
} else if (is_c2_compile(comp_level)) {
69
return c2_count();
70
}
71
return 0;
72
}
73
74
// Returns true if m must be compiled before executing it
75
// This is intended to force compiles for methods (usually for
76
// debugging) that would otherwise be interpreted for some reason.
77
bool CompilationPolicy::must_be_compiled(const methodHandle& m, int comp_level) {
78
// Don't allow Xcomp to cause compiles in replay mode
79
if (ReplayCompiles) return false;
80
81
if (m->has_compiled_code()) return false; // already compiled
82
if (!can_be_compiled(m, comp_level)) return false;
83
84
return !UseInterpreter || // must compile all methods
85
(UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods
86
}
87
88
void CompilationPolicy::compile_if_required(const methodHandle& m, TRAPS) {
89
if (must_be_compiled(m)) {
90
// This path is unusual, mostly used by the '-Xcomp' stress test mode.
91
92
if (!THREAD->can_call_java() || THREAD->is_Compiler_thread()) {
93
// don't force compilation, resolve was on behalf of compiler
94
return;
95
}
96
if (m->method_holder()->is_not_initialized()) {
97
// 'is_not_initialized' means not only '!is_initialized', but also that
98
// initialization has not been started yet ('!being_initialized')
99
// Do not force compilation of methods in uninitialized classes.
100
// Note that doing this would throw an assert later,
101
// in CompileBroker::compile_method.
102
// We sometimes use the link resolver to do reflective lookups
103
// even before classes are initialized.
104
return;
105
}
106
CompLevel level = initial_compile_level(m);
107
if (PrintTieredEvents) {
108
print_event(COMPILE, m(), m(), InvocationEntryBci, level);
109
}
110
CompileBroker::compile_method(m, InvocationEntryBci, level, methodHandle(), 0, CompileTask::Reason_MustBeCompiled, THREAD);
111
}
112
}
113
114
static inline CompLevel adjust_level_for_compilability_query(CompLevel comp_level) {
115
if (comp_level == CompLevel_any) {
116
if (CompilerConfig::is_c1_only()) {
117
comp_level = CompLevel_simple;
118
} else if (CompilerConfig::is_c2_or_jvmci_compiler_only()) {
119
comp_level = CompLevel_full_optimization;
120
}
121
}
122
return comp_level;
123
}
124
125
// Returns true if m is allowed to be compiled
126
bool CompilationPolicy::can_be_compiled(const methodHandle& m, int comp_level) {
127
// allow any levels for WhiteBox
128
assert(WhiteBoxAPI || comp_level == CompLevel_any || is_compile(comp_level), "illegal compilation level");
129
130
if (m->is_abstract()) return false;
131
if (DontCompileHugeMethods && m->code_size() > HugeMethodLimit) return false;
132
133
// Math intrinsics should never be compiled as this can lead to
134
// monotonicity problems because the interpreter will prefer the
135
// compiled code to the intrinsic version. This can't happen in
136
// production because the invocation counter can't be incremented
137
// but we shouldn't expose the system to this problem in testing
138
// modes.
139
if (!AbstractInterpreter::can_be_compiled(m)) {
140
return false;
141
}
142
comp_level = adjust_level_for_compilability_query((CompLevel) comp_level);
143
if (comp_level == CompLevel_any || is_compile(comp_level)) {
144
return !m->is_not_compilable(comp_level);
145
}
146
return false;
147
}
148
149
// Returns true if m is allowed to be osr compiled
150
bool CompilationPolicy::can_be_osr_compiled(const methodHandle& m, int comp_level) {
151
bool result = false;
152
comp_level = adjust_level_for_compilability_query((CompLevel) comp_level);
153
if (comp_level == CompLevel_any || is_compile(comp_level)) {
154
result = !m->is_not_osr_compilable(comp_level);
155
}
156
return (result && can_be_compiled(m, comp_level));
157
}
158
159
bool CompilationPolicy::is_compilation_enabled() {
160
// NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler
161
return CompileBroker::should_compile_new_jobs();
162
}
163
164
CompileTask* CompilationPolicy::select_task_helper(CompileQueue* compile_queue) {
165
// Remove unloaded methods from the queue
166
for (CompileTask* task = compile_queue->first(); task != NULL; ) {
167
CompileTask* next = task->next();
168
if (task->is_unloaded()) {
169
compile_queue->remove_and_mark_stale(task);
170
}
171
task = next;
172
}
173
#if INCLUDE_JVMCI
174
if (UseJVMCICompiler && !BackgroundCompilation) {
175
/*
176
* In blocking compilation mode, the CompileBroker will make
177
* compilations submitted by a JVMCI compiler thread non-blocking. These
178
* compilations should be scheduled after all blocking compilations
179
* to service non-compiler related compilations sooner and reduce the
180
* chance of such compilations timing out.
181
*/
182
for (CompileTask* task = compile_queue->first(); task != NULL; task = task->next()) {
183
if (task->is_blocking()) {
184
return task;
185
}
186
}
187
}
188
#endif
189
return compile_queue->first();
190
}
191
192
// Simple methods are as good being compiled with C1 as C2.
193
// Determine if a given method is such a case.
194
bool CompilationPolicy::is_trivial(Method* method) {
195
if (method->is_accessor() ||
196
method->is_constant_getter()) {
197
return true;
198
}
199
return false;
200
}
201
202
bool CompilationPolicy::force_comp_at_level_simple(const methodHandle& method) {
203
if (CompilationModeFlag::quick_internal()) {
204
#if INCLUDE_JVMCI
205
if (UseJVMCICompiler) {
206
AbstractCompiler* comp = CompileBroker::compiler(CompLevel_full_optimization);
207
if (comp != NULL && comp->is_jvmci() && ((JVMCICompiler*) comp)->force_comp_at_level_simple(method)) {
208
return true;
209
}
210
}
211
#endif
212
}
213
return false;
214
}
215
216
CompLevel CompilationPolicy::comp_level(Method* method) {
217
CompiledMethod *nm = method->code();
218
if (nm != NULL && nm->is_in_use()) {
219
return (CompLevel)nm->comp_level();
220
}
221
return CompLevel_none;
222
}
223
224
// Call and loop predicates determine whether a transition to a higher
225
// compilation level should be performed (pointers to predicate functions
226
// are passed to common()).
227
// Tier?LoadFeedback is basically a coefficient that determines of
228
// how many methods per compiler thread can be in the queue before
229
// the threshold values double.
230
class LoopPredicate : AllStatic {
231
public:
232
static bool apply_scaled(const methodHandle& method, CompLevel cur_level, int i, int b, double scale) {
233
double threshold_scaling;
234
if (CompilerOracle::has_option_value(method, CompileCommand::CompileThresholdScaling, threshold_scaling)) {
235
scale *= threshold_scaling;
236
}
237
switch(cur_level) {
238
case CompLevel_none:
239
case CompLevel_limited_profile:
240
return b >= Tier3BackEdgeThreshold * scale;
241
case CompLevel_full_profile:
242
return b >= Tier4BackEdgeThreshold * scale;
243
default:
244
return true;
245
}
246
}
247
248
static bool apply(int i, int b, CompLevel cur_level, const methodHandle& method) {
249
double k = 1;
250
switch(cur_level) {
251
case CompLevel_none:
252
// Fall through
253
case CompLevel_limited_profile: {
254
k = CompilationPolicy::threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
255
break;
256
}
257
case CompLevel_full_profile: {
258
k = CompilationPolicy::threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
259
break;
260
}
261
default:
262
return true;
263
}
264
return apply_scaled(method, cur_level, i, b, k);
265
}
266
};
267
268
class CallPredicate : AllStatic {
269
public:
270
static bool apply_scaled(const methodHandle& method, CompLevel cur_level, int i, int b, double scale) {
271
double threshold_scaling;
272
if (CompilerOracle::has_option_value(method, CompileCommand::CompileThresholdScaling, threshold_scaling)) {
273
scale *= threshold_scaling;
274
}
275
switch(cur_level) {
276
case CompLevel_none:
277
case CompLevel_limited_profile:
278
return (i >= Tier3InvocationThreshold * scale) ||
279
(i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale);
280
case CompLevel_full_profile:
281
return (i >= Tier4InvocationThreshold * scale) ||
282
(i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale);
283
default:
284
return true;
285
}
286
}
287
288
static bool apply(int i, int b, CompLevel cur_level, const methodHandle& method) {
289
double k = 1;
290
switch(cur_level) {
291
case CompLevel_none:
292
case CompLevel_limited_profile: {
293
k = CompilationPolicy::threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
294
break;
295
}
296
case CompLevel_full_profile: {
297
k = CompilationPolicy::threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
298
break;
299
}
300
default:
301
return true;
302
}
303
return apply_scaled(method, cur_level, i, b, k);
304
}
305
};
306
307
double CompilationPolicy::threshold_scale(CompLevel level, int feedback_k) {
308
int comp_count = compiler_count(level);
309
if (comp_count > 0) {
310
double queue_size = CompileBroker::queue_size(level);
311
double k = queue_size / (feedback_k * comp_count) + 1;
312
313
// Increase C1 compile threshold when the code cache is filled more
314
// than specified by IncreaseFirstTierCompileThresholdAt percentage.
315
// The main intention is to keep enough free space for C2 compiled code
316
// to achieve peak performance if the code cache is under stress.
317
if (CompilerConfig::is_tiered() && !CompilationModeFlag::disable_intermediate() && is_c1_compile(level)) {
318
double current_reverse_free_ratio = CodeCache::reverse_free_ratio(CodeCache::get_code_blob_type(level));
319
if (current_reverse_free_ratio > _increase_threshold_at_ratio) {
320
k *= exp(current_reverse_free_ratio - _increase_threshold_at_ratio);
321
}
322
}
323
return k;
324
}
325
return 1;
326
}
327
328
void CompilationPolicy::print_counters(const char* prefix, const Method* m) {
329
int invocation_count = m->invocation_count();
330
int backedge_count = m->backedge_count();
331
MethodData* mdh = m->method_data();
332
int mdo_invocations = 0, mdo_backedges = 0;
333
int mdo_invocations_start = 0, mdo_backedges_start = 0;
334
if (mdh != NULL) {
335
mdo_invocations = mdh->invocation_count();
336
mdo_backedges = mdh->backedge_count();
337
mdo_invocations_start = mdh->invocation_count_start();
338
mdo_backedges_start = mdh->backedge_count_start();
339
}
340
tty->print(" %stotal=%d,%d %smdo=%d(%d),%d(%d)", prefix,
341
invocation_count, backedge_count, prefix,
342
mdo_invocations, mdo_invocations_start,
343
mdo_backedges, mdo_backedges_start);
344
tty->print(" %smax levels=%d,%d", prefix,
345
m->highest_comp_level(), m->highest_osr_comp_level());
346
}
347
348
// Print an event.
349
void CompilationPolicy::print_event(EventType type, const Method* m, const Method* im, int bci, CompLevel level) {
350
bool inlinee_event = m != im;
351
352
ttyLocker tty_lock;
353
tty->print("%lf: [", os::elapsedTime());
354
355
switch(type) {
356
case CALL:
357
tty->print("call");
358
break;
359
case LOOP:
360
tty->print("loop");
361
break;
362
case COMPILE:
363
tty->print("compile");
364
break;
365
case REMOVE_FROM_QUEUE:
366
tty->print("remove-from-queue");
367
break;
368
case UPDATE_IN_QUEUE:
369
tty->print("update-in-queue");
370
break;
371
case REPROFILE:
372
tty->print("reprofile");
373
break;
374
case MAKE_NOT_ENTRANT:
375
tty->print("make-not-entrant");
376
break;
377
default:
378
tty->print("unknown");
379
}
380
381
tty->print(" level=%d ", level);
382
383
ResourceMark rm;
384
char *method_name = m->name_and_sig_as_C_string();
385
tty->print("[%s", method_name);
386
if (inlinee_event) {
387
char *inlinee_name = im->name_and_sig_as_C_string();
388
tty->print(" [%s]] ", inlinee_name);
389
}
390
else tty->print("] ");
391
tty->print("@%d queues=%d,%d", bci, CompileBroker::queue_size(CompLevel_full_profile),
392
CompileBroker::queue_size(CompLevel_full_optimization));
393
394
tty->print(" rate=");
395
if (m->prev_time() == 0) tty->print("n/a");
396
else tty->print("%f", m->rate());
397
398
tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback),
399
threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback));
400
401
if (type != COMPILE) {
402
print_counters("", m);
403
if (inlinee_event) {
404
print_counters("inlinee ", im);
405
}
406
tty->print(" compilable=");
407
bool need_comma = false;
408
if (!m->is_not_compilable(CompLevel_full_profile)) {
409
tty->print("c1");
410
need_comma = true;
411
}
412
if (!m->is_not_osr_compilable(CompLevel_full_profile)) {
413
if (need_comma) tty->print(",");
414
tty->print("c1-osr");
415
need_comma = true;
416
}
417
if (!m->is_not_compilable(CompLevel_full_optimization)) {
418
if (need_comma) tty->print(",");
419
tty->print("c2");
420
need_comma = true;
421
}
422
if (!m->is_not_osr_compilable(CompLevel_full_optimization)) {
423
if (need_comma) tty->print(",");
424
tty->print("c2-osr");
425
}
426
tty->print(" status=");
427
if (m->queued_for_compilation()) {
428
tty->print("in-queue");
429
} else tty->print("idle");
430
}
431
tty->print_cr("]");
432
}
433
434
void CompilationPolicy::initialize() {
435
if (!CompilerConfig::is_interpreter_only()) {
436
int count = CICompilerCount;
437
bool c1_only = CompilerConfig::is_c1_only();
438
bool c2_only = CompilerConfig::is_c2_or_jvmci_compiler_only();
439
440
#ifdef _LP64
441
// Turn on ergonomic compiler count selection
442
if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {
443
FLAG_SET_DEFAULT(CICompilerCountPerCPU, true);
444
}
445
if (CICompilerCountPerCPU) {
446
// Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n
447
int log_cpu = log2i(os::active_processor_count());
448
int loglog_cpu = log2i(MAX2(log_cpu, 1));
449
count = MAX2(log_cpu * loglog_cpu * 3 / 2, 2);
450
// Make sure there is enough space in the code cache to hold all the compiler buffers
451
size_t c1_size = 0;
452
#ifdef COMPILER1
453
c1_size = Compiler::code_buffer_size();
454
#endif
455
size_t c2_size = 0;
456
#ifdef COMPILER2
457
c2_size = C2Compiler::initial_code_buffer_size();
458
#endif
459
size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3);
460
int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size;
461
if (count > max_count) {
462
// Lower the compiler count such that all buffers fit into the code cache
463
count = MAX2(max_count, c1_only ? 1 : 2);
464
}
465
FLAG_SET_ERGO(CICompilerCount, count);
466
}
467
#else
468
// On 32-bit systems, the number of compiler threads is limited to 3.
469
// On these systems, the virtual address space available to the JVM
470
// is usually limited to 2-4 GB (the exact value depends on the platform).
471
// As the compilers (especially C2) can consume a large amount of
472
// memory, scaling the number of compiler threads with the number of
473
// available cores can result in the exhaustion of the address space
474
/// available to the VM and thus cause the VM to crash.
475
if (FLAG_IS_DEFAULT(CICompilerCount)) {
476
count = 3;
477
FLAG_SET_ERGO(CICompilerCount, count);
478
}
479
#endif
480
481
if (c1_only) {
482
// No C2 compiler thread required
483
set_c1_count(count);
484
} else if (c2_only) {
485
set_c2_count(count);
486
} else {
487
set_c1_count(MAX2(count / 3, 1));
488
set_c2_count(MAX2(count - c1_count(), 1));
489
}
490
assert(count == c1_count() + c2_count(), "inconsistent compiler thread count");
491
set_increase_threshold_at_ratio();
492
}
493
set_start_time(nanos_to_millis(os::javaTimeNanos()));
494
}
495
496
497
#ifdef ASSERT
498
bool CompilationPolicy::verify_level(CompLevel level) {
499
if (TieredCompilation && level > TieredStopAtLevel) {
500
return false;
501
}
502
// Check if there is a compiler to process the requested level
503
if (!CompilerConfig::is_c1_enabled() && is_c1_compile(level)) {
504
return false;
505
}
506
if (!CompilerConfig::is_c2_or_jvmci_compiler_enabled() && is_c2_compile(level)) {
507
return false;
508
}
509
510
// Interpreter level is always valid.
511
if (level == CompLevel_none) {
512
return true;
513
}
514
if (CompilationModeFlag::normal()) {
515
return true;
516
} else if (CompilationModeFlag::quick_only()) {
517
return level == CompLevel_simple;
518
} else if (CompilationModeFlag::high_only()) {
519
return level == CompLevel_full_optimization;
520
} else if (CompilationModeFlag::high_only_quick_internal()) {
521
return level == CompLevel_full_optimization || level == CompLevel_simple;
522
}
523
return false;
524
}
525
#endif
526
527
528
CompLevel CompilationPolicy::highest_compile_level() {
529
CompLevel level = CompLevel_none;
530
// Setup the maximum level availible for the current compiler configuration.
531
if (!CompilerConfig::is_interpreter_only()) {
532
if (CompilerConfig::is_c2_or_jvmci_compiler_enabled()) {
533
level = CompLevel_full_optimization;
534
} else if (CompilerConfig::is_c1_enabled()) {
535
if (CompilerConfig::is_c1_simple_only()) {
536
level = CompLevel_simple;
537
} else {
538
level = CompLevel_full_profile;
539
}
540
}
541
}
542
// Clamp the maximum level with TieredStopAtLevel.
543
if (TieredCompilation) {
544
level = MIN2(level, (CompLevel) TieredStopAtLevel);
545
}
546
547
// Fix it up if after the clamping it has become invalid.
548
// Bring it monotonically down depending on the next available level for
549
// the compilation mode.
550
if (!CompilationModeFlag::normal()) {
551
// a) quick_only - levels 2,3,4 are invalid; levels -1,0,1 are valid;
552
// b) high_only - levels 1,2,3 are invalid; levels -1,0,4 are valid;
553
// c) high_only_quick_internal - levels 2,3 are invalid; levels -1,0,1,4 are valid.
554
if (CompilationModeFlag::quick_only()) {
555
if (level == CompLevel_limited_profile || level == CompLevel_full_profile || level == CompLevel_full_optimization) {
556
level = CompLevel_simple;
557
}
558
} else if (CompilationModeFlag::high_only()) {
559
if (level == CompLevel_simple || level == CompLevel_limited_profile || level == CompLevel_full_profile) {
560
level = CompLevel_none;
561
}
562
} else if (CompilationModeFlag::high_only_quick_internal()) {
563
if (level == CompLevel_limited_profile || level == CompLevel_full_profile) {
564
level = CompLevel_simple;
565
}
566
}
567
}
568
569
assert(verify_level(level), "Invalid highest compilation level: %d", level);
570
return level;
571
}
572
573
CompLevel CompilationPolicy::limit_level(CompLevel level) {
574
level = MIN2(level, highest_compile_level());
575
assert(verify_level(level), "Invalid compilation level: %d", level);
576
return level;
577
}
578
579
CompLevel CompilationPolicy::initial_compile_level(const methodHandle& method) {
580
CompLevel level = CompLevel_any;
581
if (CompilationModeFlag::normal()) {
582
level = CompLevel_full_profile;
583
} else if (CompilationModeFlag::quick_only()) {
584
level = CompLevel_simple;
585
} else if (CompilationModeFlag::high_only()) {
586
level = CompLevel_full_optimization;
587
} else if (CompilationModeFlag::high_only_quick_internal()) {
588
if (force_comp_at_level_simple(method)) {
589
level = CompLevel_simple;
590
} else {
591
level = CompLevel_full_optimization;
592
}
593
}
594
assert(level != CompLevel_any, "Unhandled compilation mode");
595
return limit_level(level);
596
}
597
598
// Set carry flags on the counters if necessary
599
void CompilationPolicy::handle_counter_overflow(Method* method) {
600
MethodCounters *mcs = method->method_counters();
601
if (mcs != NULL) {
602
mcs->invocation_counter()->set_carry_on_overflow();
603
mcs->backedge_counter()->set_carry_on_overflow();
604
}
605
MethodData* mdo = method->method_data();
606
if (mdo != NULL) {
607
mdo->invocation_counter()->set_carry_on_overflow();
608
mdo->backedge_counter()->set_carry_on_overflow();
609
}
610
}
611
612
// Called with the queue locked and with at least one element
613
CompileTask* CompilationPolicy::select_task(CompileQueue* compile_queue) {
614
CompileTask *max_blocking_task = NULL;
615
CompileTask *max_task = NULL;
616
Method* max_method = NULL;
617
618
jlong t = nanos_to_millis(os::javaTimeNanos());
619
// Iterate through the queue and find a method with a maximum rate.
620
for (CompileTask* task = compile_queue->first(); task != NULL;) {
621
CompileTask* next_task = task->next();
622
Method* method = task->method();
623
// If a method was unloaded or has been stale for some time, remove it from the queue.
624
// Blocking tasks and tasks submitted from whitebox API don't become stale
625
if (task->is_unloaded() || (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method))) {
626
if (!task->is_unloaded()) {
627
if (PrintTieredEvents) {
628
print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel) task->comp_level());
629
}
630
method->clear_queued_for_compilation();
631
}
632
compile_queue->remove_and_mark_stale(task);
633
task = next_task;
634
continue;
635
}
636
update_rate(t, method);
637
if (max_task == NULL || compare_methods(method, max_method)) {
638
// Select a method with the highest rate
639
max_task = task;
640
max_method = method;
641
}
642
643
if (task->is_blocking()) {
644
if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
645
max_blocking_task = task;
646
}
647
}
648
649
task = next_task;
650
}
651
652
if (max_blocking_task != NULL) {
653
// In blocking compilation mode, the CompileBroker will make
654
// compilations submitted by a JVMCI compiler thread non-blocking. These
655
// compilations should be scheduled after all blocking compilations
656
// to service non-compiler related compilations sooner and reduce the
657
// chance of such compilations timing out.
658
max_task = max_blocking_task;
659
max_method = max_task->method();
660
}
661
662
methodHandle max_method_h(Thread::current(), max_method);
663
664
if (max_task != NULL && max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile &&
665
max_method != NULL && is_method_profiled(max_method_h) && !Arguments::is_compiler_only()) {
666
max_task->set_comp_level(CompLevel_limited_profile);
667
668
if (CompileBroker::compilation_is_complete(max_method_h, max_task->osr_bci(), CompLevel_limited_profile)) {
669
if (PrintTieredEvents) {
670
print_event(REMOVE_FROM_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
671
}
672
compile_queue->remove_and_mark_stale(max_task);
673
max_method->clear_queued_for_compilation();
674
return NULL;
675
}
676
677
if (PrintTieredEvents) {
678
print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
679
}
680
}
681
682
return max_task;
683
}
684
685
void CompilationPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
686
for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) {
687
if (PrintTieredEvents) {
688
print_event(REPROFILE, sd->method(), sd->method(), InvocationEntryBci, CompLevel_none);
689
}
690
MethodData* mdo = sd->method()->method_data();
691
if (mdo != NULL) {
692
mdo->reset_start_counters();
693
}
694
if (sd->is_top()) break;
695
}
696
}
697
698
nmethod* CompilationPolicy::event(const methodHandle& method, const methodHandle& inlinee,
699
int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, TRAPS) {
700
if (PrintTieredEvents) {
701
print_event(bci == InvocationEntryBci ? CALL : LOOP, method(), inlinee(), bci, comp_level);
702
}
703
704
if (comp_level == CompLevel_none &&
705
JvmtiExport::can_post_interpreter_events() &&
706
THREAD->is_interp_only_mode()) {
707
return NULL;
708
}
709
if (ReplayCompiles) {
710
// Don't trigger other compiles in testing mode
711
return NULL;
712
}
713
714
handle_counter_overflow(method());
715
if (method() != inlinee()) {
716
handle_counter_overflow(inlinee());
717
}
718
719
if (bci == InvocationEntryBci) {
720
method_invocation_event(method, inlinee, comp_level, nm, THREAD);
721
} else {
722
// method == inlinee if the event originated in the main method
723
method_back_branch_event(method, inlinee, bci, comp_level, nm, THREAD);
724
// Check if event led to a higher level OSR compilation
725
CompLevel expected_comp_level = MIN2(CompLevel_full_optimization, static_cast<CompLevel>(comp_level + 1));
726
if (!CompilationModeFlag::disable_intermediate() && inlinee->is_not_osr_compilable(expected_comp_level)) {
727
// It's not possble to reach the expected level so fall back to simple.
728
expected_comp_level = CompLevel_simple;
729
}
730
CompLevel max_osr_level = static_cast<CompLevel>(inlinee->highest_osr_comp_level());
731
if (max_osr_level >= expected_comp_level) { // fast check to avoid locking in a typical scenario
732
nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, expected_comp_level, false);
733
assert(osr_nm == NULL || osr_nm->comp_level() >= expected_comp_level, "lookup_osr_nmethod_for is broken");
734
if (osr_nm != NULL && osr_nm->comp_level() != comp_level) {
735
// Perform OSR with new nmethod
736
return osr_nm;
737
}
738
}
739
}
740
return NULL;
741
}
742
743
// Check if the method can be compiled, change level if necessary
744
void CompilationPolicy::compile(const methodHandle& mh, int bci, CompLevel level, TRAPS) {
745
assert(verify_level(level), "Invalid compilation level requested: %d", level);
746
747
if (level == CompLevel_none) {
748
if (mh->has_compiled_code()) {
749
// Happens when we switch to interpreter to profile.
750
MutexLocker ml(Compile_lock);
751
NoSafepointVerifier nsv;
752
if (mh->has_compiled_code()) {
753
mh->code()->make_not_used();
754
}
755
// Deoptimize immediately (we don't have to wait for a compile).
756
JavaThread* jt = THREAD;
757
RegisterMap map(jt, false);
758
frame fr = jt->last_frame().sender(&map);
759
Deoptimization::deoptimize_frame(jt, fr.id());
760
}
761
return;
762
}
763
764
if (!CompilationModeFlag::disable_intermediate()) {
765
// Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
766
// in the interpreter and then compile with C2 (the transition function will request that,
767
// see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
768
// pure C1.
769
if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) {
770
if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
771
compile(mh, bci, CompLevel_simple, THREAD);
772
}
773
return;
774
}
775
if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) {
776
if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) {
777
nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
778
if (osr_nm != NULL && osr_nm->comp_level() > CompLevel_simple) {
779
// Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
780
osr_nm->make_not_entrant();
781
}
782
compile(mh, bci, CompLevel_simple, THREAD);
783
}
784
return;
785
}
786
}
787
if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
788
return;
789
}
790
if (!CompileBroker::compilation_is_in_queue(mh)) {
791
if (PrintTieredEvents) {
792
print_event(COMPILE, mh(), mh(), bci, level);
793
}
794
int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
795
update_rate(nanos_to_millis(os::javaTimeNanos()), mh());
796
CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, THREAD);
797
}
798
}
799
800
// update_rate() is called from select_task() while holding a compile queue lock.
801
void CompilationPolicy::update_rate(jlong t, Method* m) {
802
// Skip update if counters are absent.
803
// Can't allocate them since we are holding compile queue lock.
804
if (m->method_counters() == NULL) return;
805
806
if (is_old(m)) {
807
// We don't remove old methods from the queue,
808
// so we can just zero the rate.
809
m->set_rate(0);
810
return;
811
}
812
813
// We don't update the rate if we've just came out of a safepoint.
814
// delta_s is the time since last safepoint in milliseconds.
815
jlong delta_s = t - SafepointTracing::end_of_last_safepoint_ms();
816
jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
817
// How many events were there since the last time?
818
int event_count = m->invocation_count() + m->backedge_count();
819
int delta_e = event_count - m->prev_event_count();
820
821
// We should be running for at least 1ms.
822
if (delta_s >= TieredRateUpdateMinTime) {
823
// And we must've taken the previous point at least 1ms before.
824
if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) {
825
m->set_prev_time(t);
826
m->set_prev_event_count(event_count);
827
m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond
828
} else {
829
if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) {
830
// If nothing happened for 25ms, zero the rate. Don't modify prev values.
831
m->set_rate(0);
832
}
833
}
834
}
835
}
836
837
// Check if this method has been stale for a given number of milliseconds.
838
// See select_task().
839
bool CompilationPolicy::is_stale(jlong t, jlong timeout, Method* m) {
840
jlong delta_s = t - SafepointTracing::end_of_last_safepoint_ms();
841
jlong delta_t = t - m->prev_time();
842
if (delta_t > timeout && delta_s > timeout) {
843
int event_count = m->invocation_count() + m->backedge_count();
844
int delta_e = event_count - m->prev_event_count();
845
// Return true if there were no events.
846
return delta_e == 0;
847
}
848
return false;
849
}
850
851
// We don't remove old methods from the compile queue even if they have
852
// very low activity. See select_task().
853
bool CompilationPolicy::is_old(Method* method) {
854
return method->invocation_count() > 50000 || method->backedge_count() > 500000;
855
}
856
857
double CompilationPolicy::weight(Method* method) {
858
return (double)(method->rate() + 1) *
859
(method->invocation_count() + 1) * (method->backedge_count() + 1);
860
}
861
862
// Apply heuristics and return true if x should be compiled before y
863
bool CompilationPolicy::compare_methods(Method* x, Method* y) {
864
if (x->highest_comp_level() > y->highest_comp_level()) {
865
// recompilation after deopt
866
return true;
867
} else
868
if (x->highest_comp_level() == y->highest_comp_level()) {
869
if (weight(x) > weight(y)) {
870
return true;
871
}
872
}
873
return false;
874
}
875
876
// Is method profiled enough?
877
bool CompilationPolicy::is_method_profiled(const methodHandle& method) {
878
MethodData* mdo = method->method_data();
879
if (mdo != NULL) {
880
int i = mdo->invocation_count_delta();
881
int b = mdo->backedge_count_delta();
882
return CallPredicate::apply_scaled(method, CompLevel_full_profile, i, b, 1);
883
}
884
return false;
885
}
886
887
888
// Determine is a method is mature.
889
bool CompilationPolicy::is_mature(Method* method) {
890
methodHandle mh(Thread::current(), method);
891
MethodData* mdo = method->method_data();
892
if (mdo != NULL) {
893
int i = mdo->invocation_count();
894
int b = mdo->backedge_count();
895
double k = ProfileMaturityPercentage / 100.0;
896
return CallPredicate::apply_scaled(mh, CompLevel_full_profile, i, b, k) || LoopPredicate::apply_scaled(mh, CompLevel_full_profile, i, b, k);
897
}
898
return false;
899
}
900
901
// If a method is old enough and is still in the interpreter we would want to
902
// start profiling without waiting for the compiled method to arrive.
903
// We also take the load on compilers into the account.
904
bool CompilationPolicy::should_create_mdo(const methodHandle& method, CompLevel cur_level) {
905
if (cur_level != CompLevel_none || force_comp_at_level_simple(method) || CompilationModeFlag::quick_only() || !ProfileInterpreter) {
906
return false;
907
}
908
int i = method->invocation_count();
909
int b = method->backedge_count();
910
double k = Tier0ProfilingStartPercentage / 100.0;
911
912
// If the top level compiler is not keeping up, delay profiling.
913
if (CompileBroker::queue_size(CompLevel_full_optimization) <= Tier0Delay * compiler_count(CompLevel_full_optimization)) {
914
return CallPredicate::apply_scaled(method, CompLevel_full_profile, i, b, k) || LoopPredicate::apply_scaled(method, CompLevel_full_profile, i, b, k);
915
}
916
return false;
917
}
918
919
// Inlining control: if we're compiling a profiled method with C1 and the callee
920
// is known to have OSRed in a C2 version, don't inline it.
921
bool CompilationPolicy::should_not_inline(ciEnv* env, ciMethod* callee) {
922
CompLevel comp_level = (CompLevel)env->comp_level();
923
if (comp_level == CompLevel_full_profile ||
924
comp_level == CompLevel_limited_profile) {
925
return callee->highest_osr_comp_level() == CompLevel_full_optimization;
926
}
927
return false;
928
}
929
930
// Create MDO if necessary.
931
void CompilationPolicy::create_mdo(const methodHandle& mh, JavaThread* THREAD) {
932
if (mh->is_native() ||
933
mh->is_abstract() ||
934
mh->is_accessor() ||
935
mh->is_constant_getter()) {
936
return;
937
}
938
if (mh->method_data() == NULL) {
939
Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR);
940
}
941
if (ProfileInterpreter) {
942
MethodData* mdo = mh->method_data();
943
if (mdo != NULL) {
944
frame last_frame = THREAD->last_frame();
945
if (last_frame.is_interpreted_frame() && mh == last_frame.interpreter_frame_method()) {
946
int bci = last_frame.interpreter_frame_bci();
947
address dp = mdo->bci_to_dp(bci);
948
last_frame.interpreter_frame_set_mdp(dp);
949
}
950
}
951
}
952
}
953
954
955
956
/*
957
* Method states:
958
* 0 - interpreter (CompLevel_none)
959
* 1 - pure C1 (CompLevel_simple)
960
* 2 - C1 with invocation and backedge counting (CompLevel_limited_profile)
961
* 3 - C1 with full profiling (CompLevel_full_profile)
962
* 4 - C2 or Graal (CompLevel_full_optimization)
963
*
964
* Common state transition patterns:
965
* a. 0 -> 3 -> 4.
966
* The most common path. But note that even in this straightforward case
967
* profiling can start at level 0 and finish at level 3.
968
*
969
* b. 0 -> 2 -> 3 -> 4.
970
* This case occurs when the load on C2 is deemed too high. So, instead of transitioning
971
* into state 3 directly and over-profiling while a method is in the C2 queue we transition to
972
* level 2 and wait until the load on C2 decreases. This path is disabled for OSRs.
973
*
974
* c. 0 -> (3->2) -> 4.
975
* In this case we enqueue a method for compilation at level 3, but the C1 queue is long enough
976
* to enable the profiling to fully occur at level 0. In this case we change the compilation level
977
* of the method to 2 while the request is still in-queue, because it'll allow it to run much faster
978
* without full profiling while c2 is compiling.
979
*
980
* d. 0 -> 3 -> 1 or 0 -> 2 -> 1.
981
* After a method was once compiled with C1 it can be identified as trivial and be compiled to
982
* level 1. These transition can also occur if a method can't be compiled with C2 but can with C1.
983
*
984
* e. 0 -> 4.
985
* This can happen if a method fails C1 compilation (it will still be profiled in the interpreter)
986
* or because of a deopt that didn't require reprofiling (compilation won't happen in this case because
987
* the compiled version already exists).
988
*
989
* Note that since state 0 can be reached from any other state via deoptimization different loops
990
* are possible.
991
*
992
*/
993
994
// Common transition function. Given a predicate determines if a method should transition to another level.
995
template<typename Predicate>
996
CompLevel CompilationPolicy::common(const methodHandle& method, CompLevel cur_level, bool disable_feedback) {
997
CompLevel next_level = cur_level;
998
int i = method->invocation_count();
999
int b = method->backedge_count();
1000
1001
if (force_comp_at_level_simple(method)) {
1002
next_level = CompLevel_simple;
1003
} else {
1004
if (is_trivial(method())) {
1005
next_level = CompilationModeFlag::disable_intermediate() ? CompLevel_full_optimization : CompLevel_simple;
1006
} else {
1007
switch(cur_level) {
1008
default: break;
1009
case CompLevel_none:
1010
// If we were at full profile level, would we switch to full opt?
1011
if (common<Predicate>(method, CompLevel_full_profile, disable_feedback) == CompLevel_full_optimization) {
1012
next_level = CompLevel_full_optimization;
1013
} else if (!CompilationModeFlag::disable_intermediate() && Predicate::apply(i, b, cur_level, method)) {
1014
// C1-generated fully profiled code is about 30% slower than the limited profile
1015
// code that has only invocation and backedge counters. The observation is that
1016
// if C2 queue is large enough we can spend too much time in the fully profiled code
1017
// while waiting for C2 to pick the method from the queue. To alleviate this problem
1018
// we introduce a feedback on the C2 queue size. If the C2 queue is sufficiently long
1019
// we choose to compile a limited profiled version and then recompile with full profiling
1020
// when the load on C2 goes down.
1021
if (!disable_feedback && CompileBroker::queue_size(CompLevel_full_optimization) >
1022
Tier3DelayOn * compiler_count(CompLevel_full_optimization)) {
1023
next_level = CompLevel_limited_profile;
1024
} else {
1025
next_level = CompLevel_full_profile;
1026
}
1027
}
1028
break;
1029
case CompLevel_limited_profile:
1030
if (is_method_profiled(method)) {
1031
// Special case: we got here because this method was fully profiled in the interpreter.
1032
next_level = CompLevel_full_optimization;
1033
} else {
1034
MethodData* mdo = method->method_data();
1035
if (mdo != NULL) {
1036
if (mdo->would_profile()) {
1037
if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <=
1038
Tier3DelayOff * compiler_count(CompLevel_full_optimization) &&
1039
Predicate::apply(i, b, cur_level, method))) {
1040
next_level = CompLevel_full_profile;
1041
}
1042
} else {
1043
next_level = CompLevel_full_optimization;
1044
}
1045
} else {
1046
// If there is no MDO we need to profile
1047
if (disable_feedback || (CompileBroker::queue_size(CompLevel_full_optimization) <=
1048
Tier3DelayOff * compiler_count(CompLevel_full_optimization) &&
1049
Predicate::apply(i, b, cur_level, method))) {
1050
next_level = CompLevel_full_profile;
1051
}
1052
}
1053
}
1054
break;
1055
case CompLevel_full_profile:
1056
{
1057
MethodData* mdo = method->method_data();
1058
if (mdo != NULL) {
1059
if (mdo->would_profile() || CompilationModeFlag::disable_intermediate()) {
1060
int mdo_i = mdo->invocation_count_delta();
1061
int mdo_b = mdo->backedge_count_delta();
1062
if (Predicate::apply(mdo_i, mdo_b, cur_level, method)) {
1063
next_level = CompLevel_full_optimization;
1064
}
1065
} else {
1066
next_level = CompLevel_full_optimization;
1067
}
1068
}
1069
}
1070
break;
1071
}
1072
}
1073
}
1074
return (next_level != cur_level) ? limit_level(next_level) : next_level;
1075
}
1076
1077
1078
1079
// Determine if a method should be compiled with a normal entry point at a different level.
1080
CompLevel CompilationPolicy::call_event(const methodHandle& method, CompLevel cur_level, Thread* thread) {
1081
CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), common<LoopPredicate>(method, cur_level, true));
1082
CompLevel next_level = common<CallPredicate>(method, cur_level);
1083
1084
// If OSR method level is greater than the regular method level, the levels should be
1085
// equalized by raising the regular method level in order to avoid OSRs during each
1086
// invocation of the method.
1087
if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) {
1088
MethodData* mdo = method->method_data();
1089
guarantee(mdo != NULL, "MDO should not be NULL");
1090
if (mdo->invocation_count() >= 1) {
1091
next_level = CompLevel_full_optimization;
1092
}
1093
} else {
1094
next_level = MAX2(osr_level, next_level);
1095
}
1096
return next_level;
1097
}
1098
1099
// Determine if we should do an OSR compilation of a given method.
1100
CompLevel CompilationPolicy::loop_event(const methodHandle& method, CompLevel cur_level, Thread* thread) {
1101
CompLevel next_level = common<LoopPredicate>(method, cur_level, true);
1102
if (cur_level == CompLevel_none) {
1103
// If there is a live OSR method that means that we deopted to the interpreter
1104
// for the transition.
1105
CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level);
1106
if (osr_level > CompLevel_none) {
1107
return osr_level;
1108
}
1109
}
1110
return next_level;
1111
}
1112
1113
// Handle the invocation event.
1114
void CompilationPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh,
1115
CompLevel level, CompiledMethod* nm, TRAPS) {
1116
if (should_create_mdo(mh, level)) {
1117
create_mdo(mh, THREAD);
1118
}
1119
CompLevel next_level = call_event(mh, level, THREAD);
1120
if (next_level != level) {
1121
if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) {
1122
compile(mh, InvocationEntryBci, next_level, THREAD);
1123
}
1124
}
1125
}
1126
1127
// Handle the back branch event. Notice that we can compile the method
1128
// with a regular entry from here.
1129
void CompilationPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh,
1130
int bci, CompLevel level, CompiledMethod* nm, TRAPS) {
1131
if (should_create_mdo(mh, level)) {
1132
create_mdo(mh, THREAD);
1133
}
1134
// Check if MDO should be created for the inlined method
1135
if (should_create_mdo(imh, level)) {
1136
create_mdo(imh, THREAD);
1137
}
1138
1139
if (is_compilation_enabled()) {
1140
CompLevel next_osr_level = loop_event(imh, level, THREAD);
1141
CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level();
1142
// At the very least compile the OSR version
1143
if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) {
1144
compile(imh, bci, next_osr_level, CHECK);
1145
}
1146
1147
// Use loop event as an opportunity to also check if there's been
1148
// enough calls.
1149
CompLevel cur_level, next_level;
1150
if (mh() != imh()) { // If there is an enclosing method
1151
{
1152
guarantee(nm != NULL, "Should have nmethod here");
1153
cur_level = comp_level(mh());
1154
next_level = call_event(mh, cur_level, THREAD);
1155
1156
if (max_osr_level == CompLevel_full_optimization) {
1157
// The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts
1158
bool make_not_entrant = false;
1159
if (nm->is_osr_method()) {
1160
// This is an osr method, just make it not entrant and recompile later if needed
1161
make_not_entrant = true;
1162
} else {
1163
if (next_level != CompLevel_full_optimization) {
1164
// next_level is not full opt, so we need to recompile the
1165
// enclosing method without the inlinee
1166
cur_level = CompLevel_none;
1167
make_not_entrant = true;
1168
}
1169
}
1170
if (make_not_entrant) {
1171
if (PrintTieredEvents) {
1172
int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
1173
print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
1174
}
1175
nm->make_not_entrant();
1176
}
1177
}
1178
// Fix up next_level if necessary to avoid deopts
1179
if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) {
1180
next_level = CompLevel_full_profile;
1181
}
1182
if (cur_level != next_level) {
1183
if (!CompileBroker::compilation_is_in_queue(mh)) {
1184
compile(mh, InvocationEntryBci, next_level, THREAD);
1185
}
1186
}
1187
}
1188
} else {
1189
cur_level = comp_level(mh());
1190
next_level = call_event(mh, cur_level, THREAD);
1191
if (next_level != cur_level) {
1192
if (!CompileBroker::compilation_is_in_queue(mh)) {
1193
compile(mh, InvocationEntryBci, next_level, THREAD);
1194
}
1195
}
1196
}
1197
}
1198
}
1199
1200
1201