< prev index next >

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

Print this page




  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);
  70     if (old != NULL) {
  71       // Someone already setup the time stamps
  72       FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
  73     }
  74   }
  75 
  76   return &(_time_stamps[index]);
  77 }
  78 
  79 void GCTaskThread::print_task_time_stamps() {
  80   assert(log_is_enabled(Debug, gc, task, time), "Sanity");
  81   assert(_time_stamps != NULL, "Sanity");
  82 



  83   log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index);
  84   for(uint i=0; i<_time_stamp_index; i++) {
  85     GCTaskTimeStamp* time_stamp = time_stamp_at(i);
  86     log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
  87                               time_stamp->name(),
  88                               time_stamp->entry_time(),
  89                               time_stamp->exit_time());
  90   }
  91 
  92   // Reset after dumping the data
  93   _time_stamp_index = 0;

  94 }
  95 
  96 // GC workers get tasks from the GCTaskManager and execute
  97 // them in this method.  If there are no tasks to execute,
  98 // the GC workers wait in the GCTaskManager's get_task()
  99 // for tasks to be enqueued for execution.
 100 
 101 void GCTaskThread::run() {
 102   // Set up the thread for stack overflow support
 103   this->record_stack_base_and_size();
 104   this->initialize_named_thread();
 105   // Bind yourself to your processor.
 106   if (processor_id() != GCTaskManager::sentinel_worker()) {
 107     if (TraceGCTaskThread) {
 108       tty->print_cr("GCTaskThread::run: "
 109                     "  binding to processor %u", processor_id());
 110     }
 111     if (!os::bind_to_processor(processor_id())) {
 112       DEBUG_ONLY(
 113         warning("Couldn't bind GCTaskThread %u to processor %u",




  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);
  70     if (old != NULL) {
  71       // Someone already setup the time stamps
  72       FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
  73     }
  74   }
  75 
  76   return &(_time_stamps[index]);
  77 }
  78 
  79 void GCTaskThread::print_task_time_stamps() {
  80   assert(log_is_enabled(Debug, gc, task, time), "Sanity");

  81 
  82   // Since _time_stamps is now lazily allocated we need to check that it
  83   // has in fact been allocated when calling this function.
  84   if (_time_stamps != NULL) {
  85     log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index);
  86     for(uint i=0; i<_time_stamp_index; i++) {
  87       GCTaskTimeStamp* time_stamp = time_stamp_at(i);
  88       log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
  89                                 time_stamp->name(),
  90                                 time_stamp->entry_time(),
  91                                 time_stamp->exit_time());
  92     }
  93 
  94     // Reset after dumping the data
  95     _time_stamp_index = 0;
  96   }
  97 }
  98 
  99 // GC workers get tasks from the GCTaskManager and execute
 100 // them in this method.  If there are no tasks to execute,
 101 // the GC workers wait in the GCTaskManager's get_task()
 102 // for tasks to be enqueued for execution.
 103 
 104 void GCTaskThread::run() {
 105   // Set up the thread for stack overflow support
 106   this->record_stack_base_and_size();
 107   this->initialize_named_thread();
 108   // Bind yourself to your processor.
 109   if (processor_id() != GCTaskManager::sentinel_worker()) {
 110     if (TraceGCTaskThread) {
 111       tty->print_cr("GCTaskThread::run: "
 112                     "  binding to processor %u", processor_id());
 113     }
 114     if (!os::bind_to_processor(processor_id())) {
 115       DEBUG_ONLY(
 116         warning("Couldn't bind GCTaskThread %u to processor %u",


< prev index next >