< prev index next >

src/share/vm/gc/parallel/gcTaskThread.cpp

Print this page
rev 11970 : imported patch task_thread_time_stamps

@@ -54,29 +54,31 @@
   }
 }
 
 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
   guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
-  if (_time_stamps == NULL) {
+  GCTaskTimeStamp* time_stamps = (GCTaskTimeStamp*)OrderAccess::load_ptr_acquire(&_time_stamps);
+  if (time_stamps == NULL) {
     // We allocate the _time_stamps array lazily since logging can be enabled dynamically
-    GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
+    time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
     void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL);
     if (old != NULL) {
       // Someone already setup the time stamps
       FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
     }
   }
 
-  return &(_time_stamps[index]);
+  return &(time_stamps[index]);
 }
 
 void GCTaskThread::print_task_time_stamps() {
   assert(log_is_enabled(Debug, gc, task, time), "Sanity");
 
   // Since _time_stamps is now lazily allocated we need to check that it
   // has in fact been allocated when calling this function.
-  if (_time_stamps != NULL) {
+  GCTaskTimeStamp* time_stamps = (GCTaskTimeStamp*)OrderAccess::load_ptr_acquire(&_time_stamps);
+  if (time_stamps != NULL) {
     log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index);
     for(uint i=0; i<_time_stamp_index; i++) {
       GCTaskTimeStamp* time_stamp = time_stamp_at(i);
       log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
                                 time_stamp->name(),
< prev index next >