Skip to content

Commit 9606cbc

Browse files
author
Doug Simon
committed
8312524: [JVMCI] serviceability/dcmd/compiler/CompilerQueueTest.java fails
Reviewed-by: never, thartmann
1 parent 91fe032 commit 9606cbc

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/hotspot/share/compiler/compileBroker.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,15 @@ int DirectivesStack::_depth = 0;
21142114
CompilerDirectives* DirectivesStack::_top = nullptr;
21152115
CompilerDirectives* DirectivesStack::_bottom = nullptr;
21162116

2117+
// Acquires Compilation_lock and waits for it to be notified
2118+
// as long as WhiteBox::compilation_locked is true.
2119+
static void whitebox_lock_compilation() {
2120+
MonitorLocker locker(Compilation_lock, Mutex::_no_safepoint_check_flag);
2121+
while (WhiteBox::compilation_locked) {
2122+
locker.wait();
2123+
}
2124+
}
2125+
21172126
// ------------------------------------------------------------------
21182127
// CompileBroker::invoke_compiler_on_method
21192128
//
@@ -2196,6 +2205,11 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
21962205
JVMCIEnv env(thread, &compile_state, __FILE__, __LINE__);
21972206
failure_reason = compile_state.failure_reason();
21982207
if (failure_reason == nullptr) {
2208+
if (WhiteBoxAPI && WhiteBox::compilation_locked) {
2209+
// Must switch to native to block
2210+
ThreadToNativeFromVM ttn(thread);
2211+
whitebox_lock_compilation();
2212+
}
21992213
methodHandle method(thread, target_handle);
22002214
runtime = env.runtime();
22012215
runtime->compile_method(&env, jvmci, method, osr_bci);
@@ -2257,10 +2271,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
22572271
ci_env.record_method_not_compilable("no compiler");
22582272
} else if (!ci_env.failing()) {
22592273
if (WhiteBoxAPI && WhiteBox::compilation_locked) {
2260-
MonitorLocker locker(Compilation_lock, Mutex::_no_safepoint_check_flag);
2261-
while (WhiteBox::compilation_locked) {
2262-
locker.wait();
2263-
}
2274+
whitebox_lock_compilation();
22642275
}
22652276
comp->compile_method(&ci_env, target, osr_bci, true, directive);
22662277

0 commit comments

Comments
 (0)