27 #include "gc/parallel/gcTaskThread.hpp"
28 #include "gc/shared/gcId.hpp"
29 #include "logging/log.hpp"
30 #include "memory/allocation.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "runtime/atomic.inline.hpp"
34 #include "runtime/handles.hpp"
35 #include "runtime/handles.inline.hpp"
36 #include "runtime/os.hpp"
37 #include "runtime/thread.hpp"
38
39 GCTaskThread::GCTaskThread(GCTaskManager* manager,
40 uint which,
41 uint processor_id) :
42 _manager(manager),
43 _processor_id(processor_id),
44 _time_stamps(NULL),
45 _time_stamp_index(0)
46 {
47 if (!os::create_thread(this, os::pgc_thread))
48 vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GC thread. Out of system resources.");
49
50 set_id(which);
51 set_name("ParGC Thread#%d", which);
52 }
53
54 GCTaskThread::~GCTaskThread() {
55 if (_time_stamps != NULL) {
56 FREE_C_HEAP_ARRAY(GCTaskTimeStamp, _time_stamps);
57 }
58 }
59
60 void GCTaskThread::start() {
61 os::start_thread(this);
62 }
63
64 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
65 guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
66 if (_time_stamps == NULL) {
67 // We allocate the _time_stamps array lazily since logging can be enabled dynamically
68 GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
69 void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL);
|
27 #include "gc/parallel/gcTaskThread.hpp"
28 #include "gc/shared/gcId.hpp"
29 #include "logging/log.hpp"
30 #include "memory/allocation.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "runtime/atomic.inline.hpp"
34 #include "runtime/handles.hpp"
35 #include "runtime/handles.inline.hpp"
36 #include "runtime/os.hpp"
37 #include "runtime/thread.hpp"
38
39 GCTaskThread::GCTaskThread(GCTaskManager* manager,
40 uint which,
41 uint processor_id) :
42 _manager(manager),
43 _processor_id(processor_id),
44 _time_stamps(NULL),
45 _time_stamp_index(0)
46 {
47 set_id(which);
48 set_name("ParGC Thread#%d", which);
49 }
50
51 GCTaskThread::~GCTaskThread() {
52 if (_time_stamps != NULL) {
53 FREE_C_HEAP_ARRAY(GCTaskTimeStamp, _time_stamps);
54 }
55 }
56
57 void GCTaskThread::start() {
58 os::start_thread(this);
59 }
60
61 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
62 guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
63 if (_time_stamps == NULL) {
64 // We allocate the _time_stamps array lazily since logging can be enabled dynamically
65 GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
66 void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL);
|