From 5703deb18bc32125e29be454e4c1ff6bcdcfd186 Mon Sep 17 00:00:00 2001 From: Leo Korinth Date: Mon, 19 Jan 2026 09:35:51 +0100 Subject: [PATCH] Proposal by Stefan J --- src/hotspot/share/gc/shared/workerThread.cpp | 15 ++------------- src/hotspot/share/gc/shared/workerThread.hpp | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/gc/shared/workerThread.cpp b/src/hotspot/share/gc/shared/workerThread.cpp index 24d1928200f..c669c80ac8a 100644 --- a/src/hotspot/share/gc/shared/workerThread.cpp +++ b/src/hotspot/share/gc/shared/workerThread.cpp @@ -93,12 +93,7 @@ void WorkerThreads::initialize_workers() { } } -bool WorkerThreads::should_inject_gc_worker_creation_failure() const { - if (!InjectGCWorkerCreationFailure) { - // Never inject worker creation failure if not explicitly asked to do so - return false; - } - +bool WorkerThreads::allow_creation_failure() const { if (!is_init_completed()) { // Never allow creation failures during VM init return false; @@ -110,16 +105,10 @@ bool WorkerThreads::should_inject_gc_worker_creation_failure() const { } return true; - - // Inject worker creation failure iff all three below conditions hold: - // 1) explicitly asked to do so (InjectGCWorkerCreationFailure); - // 2) outside VM init (before init, the code will kill the process and the uncommon path can not be tested); - // 3) not the first worker (for the same reason as point number 2 if in the future we will implement lazy init of concurrent mark in g1). - return InjectGCWorkerCreationFailure && is_init_completed() && (_created_workers != 0); } WorkerThread* WorkerThreads::create_worker(uint name_suffix) { - if (should_inject_gc_worker_creation_failure()) { + if (InjectGCWorkerCreationFailure && allow_creation_failure()) { return nullptr; } diff --git a/src/hotspot/share/gc/shared/workerThread.hpp b/src/hotspot/share/gc/shared/workerThread.hpp index 86a6504927c..0b4da21ebc4 100644 --- a/src/hotspot/share/gc/shared/workerThread.hpp +++ b/src/hotspot/share/gc/shared/workerThread.hpp @@ -103,7 +103,7 @@ public: WorkerThreads(const char* name, uint max_workers); void initialize_workers(); - bool should_inject_gc_worker_creation_failure() const; + bool allow_creation_failure() const; uint max_workers() const { return _max_workers; } uint created_workers() const { return _created_workers; }