Skip to content

8361397: Rework CompileLog list synchronization #26127

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/hotspot/share/compiler/compileLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
#include "jvm.h"
#include "memory/allocation.inline.hpp"
#include "oops/method.hpp"
#include "runtime/atomic.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"

CompileLog* CompileLog::_first = nullptr;
CompileLog* volatile CompileLog::_list_head = nullptr;

// ------------------------------------------------------------------
// CompileLog::CompileLog
Expand All @@ -49,9 +50,12 @@ CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id)
strcpy((char*)_file, file_name);

// link into the global list
{ MutexLocker locker(CompileTaskAlloc_lock);
_next = _first;
_first = this;
while (true) {
CompileLog* head = Atomic::load_acquire(&_list_head);
_next = head;
if (Atomic::cmpxchg(&_list_head, head, this) == head) {
break;
}
}
}

Expand Down Expand Up @@ -202,7 +206,7 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
if (called_exit) return;
called_exit = true;

CompileLog* log = _first;
CompileLog* log = Atomic::load_acquire(&_list_head);
while (log != nullptr) {
log->flush();
const char* partial_file = log->file();
Expand Down Expand Up @@ -290,7 +294,7 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
delete log; // Removes partial file
log = next_log;
}
_first = nullptr;
Atomic::store(&_list_head, (CompileLog*)nullptr);
}

// ------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/compiler/compileLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CompileLog : public xmlStream {

CompileLog* _next; // static chain of all logs

static CompileLog* _first; // head of static chain
static CompileLog* volatile _list_head; // head of static chain

void va_tag(bool push, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0);

Expand Down