-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8365407: Race condition in MethodTrainingData::verify() #26866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
997b485
b9dde13
3a4690f
289fb74
edc8591
f7d6a4e
c33d94b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,14 @@ void CompilationPolicy::compile_if_required(const methodHandle& m, TRAPS) { | |
} | ||
} | ||
|
||
void CompilationPolicy::replay_training_at_init_impl(InstanceKlass* klass, TRAPS) { | ||
void CompilationPolicy::wait_replay_training_to_finish(JavaThread* current) { | ||
MonitorLocker locker(current, TrainingReplayQueue_lock); | ||
while (!_training_replay_queue.is_empty_unlocked() || _training_replay_queue.is_processing_unlocked()) { | ||
locker.wait(); // let the replay training thread drain the queue | ||
} | ||
} | ||
|
||
void CompilationPolicy::replay_training_at_init_impl(InstanceKlass* klass, JavaThread* current) { | ||
if (!klass->has_init_deps_processed()) { | ||
ResourceMark rm; | ||
log_debug(training)("Replay training: %s", klass->external_name()); | ||
|
@@ -150,11 +157,11 @@ void CompilationPolicy::replay_training_at_init_impl(InstanceKlass* klass, TRAPS | |
assert(klass->has_init_deps_processed(), ""); | ||
if (AOTCompileEagerly) { | ||
ktd->iterate_comp_deps([&](CompileTrainingData* ctd) { | ||
if (ctd->init_deps_left() == 0) { | ||
if (ctd->init_deps_left_acquire() == 0) { | ||
MethodTrainingData* mtd = ctd->method(); | ||
if (mtd->has_holder()) { | ||
const methodHandle mh(THREAD, const_cast<Method*>(mtd->holder())); | ||
CompilationPolicy::maybe_compile_early(mh, THREAD); | ||
const methodHandle mh(current, const_cast<Method*>(mtd->holder())); | ||
CompilationPolicy::maybe_compile_early(mh, current); | ||
} | ||
} | ||
}); | ||
|
@@ -163,10 +170,10 @@ void CompilationPolicy::replay_training_at_init_impl(InstanceKlass* klass, TRAPS | |
} | ||
} | ||
|
||
void CompilationPolicy::replay_training_at_init(InstanceKlass* klass, TRAPS) { | ||
void CompilationPolicy::replay_training_at_init(InstanceKlass* klass, JavaThread* current) { | ||
assert(klass->is_initialized(), ""); | ||
if (TrainingData::have_data() && klass->is_shared()) { | ||
_training_replay_queue.push(klass, TrainingReplayQueue_lock, THREAD); | ||
_training_replay_queue.push(klass, TrainingReplayQueue_lock, current); | ||
} | ||
} | ||
|
||
|
@@ -181,11 +188,12 @@ void CompilationPolicyUtils::Queue<InstanceKlass>::print_on(outputStream* st) { | |
} | ||
} | ||
|
||
void CompilationPolicy::replay_training_at_init_loop(TRAPS) { | ||
while (!CompileBroker::is_compilation_disabled_forever()) { | ||
InstanceKlass* ik = _training_replay_queue.pop(TrainingReplayQueue_lock, THREAD); | ||
void CompilationPolicy::replay_training_at_init_loop(JavaThread* current) { | ||
while (!CompileBroker::is_compilation_disabled_forever() || AOTVerifyTrainingData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it loop forever with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it runs in a dedicated thread. It doesn't need to terminate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment about this. |
||
InstanceKlass* ik = _training_replay_queue.pop(TrainingReplayQueue_lock, current); | ||
if (ik != nullptr) { | ||
replay_training_at_init_impl(ik, THREAD); | ||
replay_training_at_init_impl(ik, current); | ||
_training_replay_queue.processing_done(TrainingReplayQueue_lock, current); | ||
} | ||
} | ||
} | ||
|
@@ -446,7 +454,7 @@ void CompilationPolicy::print_training_data_on(outputStream* st, const char* pr | |
if (ctd == nullptr) { | ||
st->print("null"); | ||
} else { | ||
st->print("%d", ctd->init_deps_left()); | ||
st->print("%d", ctd->init_deps_left_acquire()); | ||
} | ||
} | ||
} | ||
|
@@ -1172,7 +1180,7 @@ CompLevel CompilationPolicy::trained_transition_from_none(const methodHandle& me | |
CompileTrainingData* ctd = mtd->last_toplevel_compile(CompLevel_full_optimization); | ||
assert(ctd != nullptr, "Should have CTD for CompLevel_full_optimization"); | ||
// With SkipTier2IfPossible and all deps satisfied, go to level 4 immediately | ||
if (SkipTier2IfPossible && ctd->init_deps_left() == 0) { | ||
if (SkipTier2IfPossible && ctd->init_deps_left_acquire() == 0) { | ||
if (method->method_data() == nullptr) { | ||
create_mdo(method, THREAD); | ||
} | ||
|
@@ -1200,7 +1208,7 @@ CompLevel CompilationPolicy::trained_transition_from_limited_profile(const metho | |
assert(training_has_profile, "Have to have a profile to be here"); | ||
// Check if the method is ready | ||
CompileTrainingData* ctd = mtd->last_toplevel_compile(CompLevel_full_optimization); | ||
if (ctd != nullptr && ctd->init_deps_left() == 0) { | ||
if (ctd != nullptr && ctd->init_deps_left_acquire() == 0) { | ||
if (method->method_data() == nullptr) { | ||
create_mdo(method, THREAD); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.