@@ -2114,6 +2114,15 @@ int DirectivesStack::_depth = 0;
2114
2114
CompilerDirectives* DirectivesStack::_top = nullptr ;
2115
2115
CompilerDirectives* DirectivesStack::_bottom = nullptr ;
2116
2116
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
+
2117
2126
// ------------------------------------------------------------------
2118
2127
// CompileBroker::invoke_compiler_on_method
2119
2128
//
@@ -2196,6 +2205,11 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
2196
2205
JVMCIEnv env (thread, &compile_state, __FILE__, __LINE__);
2197
2206
failure_reason = compile_state.failure_reason ();
2198
2207
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
+ }
2199
2213
methodHandle method (thread, target_handle);
2200
2214
runtime = env.runtime ();
2201
2215
runtime->compile_method (&env, jvmci, method, osr_bci);
@@ -2257,10 +2271,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
2257
2271
ci_env.record_method_not_compilable (" no compiler" );
2258
2272
} else if (!ci_env.failing ()) {
2259
2273
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 ();
2264
2275
}
2265
2276
comp->compile_method (&ci_env, target, osr_bci, true , directive);
2266
2277
0 commit comments