28
28
#include " jvm.h"
29
29
#include " memory/allocation.inline.hpp"
30
30
#include " oops/method.hpp"
31
+ #include " runtime/atomic.hpp"
31
32
#include " runtime/mutexLocker.hpp"
32
33
#include " runtime/os.hpp"
33
34
34
- CompileLog* CompileLog::_first = nullptr ;
35
+ CompileLog* volatile CompileLog::_list_head = nullptr ;
35
36
36
37
// ------------------------------------------------------------------
37
38
// CompileLog::CompileLog
@@ -49,9 +50,12 @@ CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id)
49
50
strcpy ((char *)_file, file_name);
50
51
51
52
// link into the global list
52
- { MutexLocker locker (CompileTaskAlloc_lock);
53
- _next = _first;
54
- _first = this ;
53
+ while (true ) {
54
+ CompileLog* head = Atomic::load_acquire (&_list_head);
55
+ _next = head;
56
+ if (Atomic::cmpxchg (&_list_head, head, this ) == head) {
57
+ break ;
58
+ }
55
59
}
56
60
}
57
61
@@ -202,7 +206,7 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
202
206
if (called_exit) return ;
203
207
called_exit = true ;
204
208
205
- CompileLog* log = _first ;
209
+ CompileLog* log = Atomic::load_acquire (&_list_head) ;
206
210
while (log != nullptr ) {
207
211
log->flush ();
208
212
const char * partial_file = log->file ();
@@ -290,7 +294,7 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
290
294
delete log; // Removes partial file
291
295
log = next_log;
292
296
}
293
- _first = nullptr ;
297
+ Atomic::store (&_list_head, (CompileLog*) nullptr ) ;
294
298
}
295
299
296
300
// ------------------------------------------------------------------
0 commit comments