19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
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 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
58 guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
59 if (_time_stamps == NULL) {
60 // We allocate the _time_stamps array lazily since logging can be enabled dynamically
61 GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
62 void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL);
63 if (old != NULL) {
64 // Someone already setup the time stamps
65 FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
66 }
67 }
68
69 return &(_time_stamps[index]);
70 }
71
72 void GCTaskThread::print_task_time_stamps() {
73 assert(log_is_enabled(Debug, gc, task, time), "Sanity");
74
75 // Since _time_stamps is now lazily allocated we need to check that it
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
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 #define PARGCTHREAD "ParGC Thread"
40
41 GCTaskThread::GCTaskThread(GCTaskManager* manager,
42 uint which,
43 uint processor_id) :
44 _manager(manager),
45 _processor_id(processor_id),
46 _time_stamps(NULL),
47 _time_stamp_index(0)
48 {
49 set_id(which);
50 set_name(PARGCTHREAD "#%d", which);
51 }
52
53 GCTaskThread::~GCTaskThread() {
54 if (_time_stamps != NULL) {
55 FREE_C_HEAP_ARRAY(GCTaskTimeStamp, _time_stamps);
56 }
57 }
58
59 const char* GCTaskThread::task_name() { return PARGCTHREAD; }
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);
67 if (old != NULL) {
68 // Someone already setup the time stamps
69 FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
70 }
71 }
72
73 return &(_time_stamps[index]);
74 }
75
76 void GCTaskThread::print_task_time_stamps() {
77 assert(log_is_enabled(Debug, gc, task, time), "Sanity");
78
79 // Since _time_stamps is now lazily allocated we need to check that it
|